Giter Site home page Giter Site logo

vladned / fastapi-responses Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kludex/fastapi-responses

0.0 0.0 0.0 146 KB

Find HTTPExceptions and turn them into documented responses! :tada:

Home Page: https://github.com/Kludex/fastapi-responses

License: MIT License

Python 96.40% Makefile 3.60%

fastapi-responses's Introduction

FastAPI Responses

Latest Commit
Package version

Find HTTPExceptions and turn them into documented responses. ๐ŸŽ‰

Installation

pip install fastapi-responses

Usage

The simplest use case happens when we have a single exception being raised. We don't want to document the possible response manually, so FastAPI Responses comes in handy.

from fastapi import FastAPI, HTTPException
from fastapi_responses import custom_openapi

app = FastAPI()

app.openapi = custom_openapi(app)

@app.get("/{item_id}")
def get_item(item_id: int):
    if item_id == 0:
        raise HTTPException(status_code=404, detail="Item not found.")
    return "Item exists!"

Without FastAPI Responses

With FastAPI Responses

Roadmap

  • Extract HTTPException from stack.
  • Extract any exception and document based on the exception_handler container.
  • Accept Python objects on HTTPException instantiation.

License

This project is licensed under the terms of the MIT license.

fastapi-responses's People

Contributors

kludex avatar ricardo-emanuel01 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.