Skip to main content

Para ler este README em portugês do Brasil, clique aqui.

FastAPI Doc HTTP Response

codecov

FastAPI Doc HTTP Response is a Python package that facilitates the definition of standard HTTP responses for FastAPI APIs and allows for easy addition of HTTP returns to the API documentation. With this package, you can easily create standard responses for the most common HTTP status codes.

FastAPI provides automatic documentation for your routes, including the expected HTTP responses for each route. By default, FastAPI only includes a few HTTP return codes in the documentation. With FastAPI Doc HTTP Response, you can easily add other HTTP return codes, ensuring that your API documentation is complete and accurate.

Installation

You can install FastAPI Doc HTTP Response using pip:

pip install fastapi-doc-http-response

Usage

To use FastAPI Doc HTTP Response in your FastAPI application, simply import the get_responses function from the package and call it with a list of HTTP status codes that you want to define:

from fastapi import FastAPI
from fastapi_doc_http_response import get_responses

app = FastAPI()


@app.get("/xpto", responses=get_responses(201, 400, 401, 403))
async def xpto():
    # ...

The code above will define the following standard HTTP responses for the /xpto route:

  • 201 Created
  • 400 Bad Request
  • 401 Unauthorized
  • 403 Forbidden

These return codes will also be automatically added to the API documentation generated by FastAPI.

Note that it is not necessary to define an HTTP return code for the 200 OK and 422 Unprocessable Entity statuses, as they are already defined by default by FastAPI.

Supported HTTP Return Codes

The HTTP return codes supported by FastAPI Doc HTTP Response are:

  • 100 Continue
  • 201 Created
  • 202 Accepted
  • 203 Non-Authoritative Information
  • 204 No Content
  • 206 Partial Content
  • 207 Multi-Status
  • 208 Already Reported
  • 226 IM Used
  • 300 Multiple Choices
  • 301 Moved Permanently
  • 302 Found
  • 303 See Other
  • 304 Not Modified
  • 305 Use Proxy
  • 306 Switch Proxy
  • 307 Temporary Redirect
  • 308 Permanent Redirect
  • 400 Bad Request
  • 401 Unauthorized
  • 402 Payment Required
  • 403 Forbidden
  • 404 Not Found
  • 405 Method Not Allowed
  • 406 Not Acceptable
  • 407 Proxy Authentication Required
  • 408 Request Timeout
  • 409 Conflict
  • 410 Gone
  • 411 Length Required
  • 412 Precondition Failed
  • 413 Payload Too Large
  • 414 URI Too Long
  • 416 Range Not Satisfiable
  • 417 Expectation Failed
  • 418 I'm a teapot
  • 420 Enhance Your Calm
  • 423 Locked
  • 424 Failed Dependency
  • 425 Unordered Collection
  • 426 Upgrade Required
  • 429 Too Many Requests
  • 431 Request Header Fields Too Large
  • 444 No Response
  • 449 Retry With
  • 450 Blocked by Windows Parental Controls
  • 451 Unavailable For Legal Reasons
  • 494 Request Header Too Large
  • 500 Internal Server Error

License

This package is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for fastapi-doc-http-response 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastapi-doc-http-response 0.0.3
File Size Uploaded Provenance Actions
fastapi_doc_http_response-0.0.3.tar.gz 5.6 kB Without provenance Details for fastapi_doc_http_response-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fastapi-doc-http-response 0.0.3
File Interpreter ABI Platform Actions
fastapi_doc_http_response-0.0.3-py3-none-any.whl Python 3 none any Details for fastapi_doc_http_response-0.0.3-py3-none-any.whl

Total release size: 12.2 kB

Release files / fastapi_doc_http_response-0.0.3.tar.gz

Download URL fastapi_doc_http_response-0.0.3.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b3ad451d4724ea3387a501097d48ae5bdc877293c7e19268202a33a8cf61206b
BLAKE2b-256 checksum
How to use checksums
199564972f9a22d9d3cbed9cb0d9aac9c1f913a0b68c496edd942f1b7b92c926
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / fastapi_doc_http_response-0.0.3-py3-none-any.whl

Download URL fastapi_doc_http_response-0.0.3-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e1f685789f2a3e02b3908db274450ceb831eb1a1f21d3ce4257033aa1808e47
BLAKE2b-256 checksum
How to use checksums
56726c64cda86c0afbbd3eb2d4f227e7c84abdfa8bc3a69d77f743b16cc53536
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Security for fastapi-doc-http-response 0.0.3

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.

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page