fastapi-doc-http-response 0.0.3
This is a Python package that simplifies the definition of standard HTTP responses for FastAPI APIs.
License: MIT
Requires Python: >=3.10
Keywords: fastapi,http,response,api,documentation

> Para ler este README em portugês do Brasil, clique [aqui](https://github.com/tharlesamaro/fastapi-doc-http-response/blob/main/README_br.md).

## FastAPI Doc HTTP Response

[![codecov](https://codecov.io/gh/tharlesamaro/fastapi-doc-http-response/branch/main/graph/badge.svg?token=VAY93FNZCA)](https://codecov.io/gh/tharlesamaro/fastapi-doc-http-response)

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:

```bash
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:

```python
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](https://opensource.org/license/mit/). See the [LICENSE](https://github.com/tharlesamaro/fastapi-doc-http-response/blob/main/LICENSE) file for details.