Identity Lib
This Python package contains utilities enabling nicer error descriptions in OpenAPI specs generated by FastAPI.
Use
Install fastapi-openapierrors using pip:
pip install fastapi-openapierrors
The module can then be used as fastapi_openapierrors to annotate routes:
from fastapi import FastAPI
from fastapi_openapierrors import NotFoundResponse, BadRequestResponse
from pydantic import BaseModel
app = FastAPI()
class Widget(BaseModel):
name: str
@api.get(
'/widget/{name}',
summary="Get a single widget",
description="Get a single widget by name",
response_model=Widget,
responses={400: BadRequestResponse, 404: NotFoundResponse}
)
async def get_widget(
name: str = Path(
...,
example=f"frobnicator2000",
title="The name of the widget"
)):
# FastAPI automatically returns a Bad Request response if the request does
# not match the route.
# Look for widget by name.
widget, was_found = get_widget_by_name(name)
if not was_found:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)
return widget
Developer quickstart
This project contains a dockerized testing environment which wraps tox.
Tests can be run using the ./test.sh command:
# Run all PyTest tests and Flake8 checks
$ ./test.sh
# Run just PyTest
$ ./test.sh -e py3
# Run a single test file within PyTest
$ ./test.sh -e py3 -- tests/test_identifiers.py
# Run a single test file within PyTest with verbose logging
$ ./test.sh -e py3 -- tests/test_identifiers.py -vvv
Metadata
Release files for fastapi-openapierrors 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| fastapi-openapierrors-0.9.0.tar.gz | 3.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_openapierrors-0.9.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.8 kB
Release files / fastapi-openapierrors-0.9.0.tar.gz
| Download URL | fastapi-openapierrors-0.9.0.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a053f84ac99097c15a5bf370c407c4fdbcdefd3f5967b97cc2f2d4dec4d39da
|
|
BLAKE2b-256 checksum How to use checksums |
3d496427c124678eb2044f110d7bb14dc5c7954bec6f9acf4e009448e7bddc28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
|
Release files / fastapi_openapierrors-0.9.0-py3-none-any.whl
| Download URL | fastapi_openapierrors-0.9.0-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aefa0769a333cf73c406d01e5188b1c1427a7e960c440491b8d46af67964360b
|
|
BLAKE2b-256 checksum How to use checksums |
0401b89238396b943ced9e1e39f68523b75975b2b3167584826205d94beae702
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
|
Security for fastapi-openapierrors 0.9.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.