Extend OpenAPI schema to collect HTTPExceptions.
Project description
FastAPI Responses
This package is not stable. Do not use in production!
Find HTTPExceptions and turn them into documented responses. :tada:
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fastapi-responses-0.2.0.tar.gz
.
File metadata
- Download URL: fastapi-responses-0.2.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.5 Linux/5.4.0-56-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8345ab30b94fc03fb6924b04add38769cf7d2982438648a8f15e665249b6318 |
|
MD5 | f818278c73bd76b35cd86a683e7cb65e |
|
BLAKE2b-256 | 019571e305c36ec7bf127902cba8a0dee8f2e328577fa314f9bb56fd9c82d2c9 |
File details
Details for the file fastapi_responses-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: fastapi_responses-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.5 Linux/5.4.0-56-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a55cdab9108102e3bb7dd7db2806728f86cc241da8aebd35a323aa0f2751f5bc |
|
MD5 | 7eb8711f19b7ff4d481b774b14ba836e |
|
BLAKE2b-256 | 3a3304940bd194a30bf04a552d18971ef456e950ffd3123cf74750b082c19e41 |