Extend OpenAPI schema to collect HTTPExceptions.
Project description
FastAPI Responses
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.1.tar.gz
.
File metadata
- Download URL: fastapi-responses-0.2.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.7 CPython/3.8.11 Linux/5.8.0-59-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f40f626c03a886611043575b1d68df89cebfa342513248287ef72ce1af46ae5b |
|
MD5 | 44f9b5f458e5288d59e6bccfbccb41ed |
|
BLAKE2b-256 | 5bb2157e6782c7accde82699d33b0216363ed632c062f67cfb2f801ac3072e70 |
File details
Details for the file fastapi_responses-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: fastapi_responses-0.2.1-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.7 CPython/3.8.11 Linux/5.8.0-59-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fad40993503de7196cd5625813dc8208f58d024239a774457097eb6aef70bf1b |
|
MD5 | be0b5260cb2ea5cd45d13bb16b85499d |
|
BLAKE2b-256 | adb14f4d0e1094c931fd0e5203a47833cb0637881a8d1cdac773bf74c5a63c19 |