Skip to main content

This is a Python package that simplifies the definition of standard HTTP responses for FastAPI APIs.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_doc_http_response-0.0.3.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file fastapi_doc_http_response-0.0.3.tar.gz.

File metadata

File hashes

Hashes for fastapi_doc_http_response-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b3ad451d4724ea3387a501097d48ae5bdc877293c7e19268202a33a8cf61206b
MD5 d8b63e365ddc54c7dfba40e481099727
BLAKE2b-256 199564972f9a22d9d3cbed9cb0d9aac9c1f913a0b68c496edd942f1b7b92c926

See more details on using hashes here.

File details

Details for the file fastapi_doc_http_response-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_doc_http_response-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9e1f685789f2a3e02b3908db274450ceb831eb1a1f21d3ce4257033aa1808e47
MD5 5d3c5c76f43adc3da3c5fe076ba42e6e
BLAKE2b-256 56726c64cda86c0afbbd3eb2d4f227e7c84abdfa8bc3a69d77f743b16cc53536

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page