fastapi-http-response


Namefastapi-http-response JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/tharlesamaro/fastapi-doc-http-response
SummaryThis is a Python package that simplifies the definition of standard HTTP responses for FastAPI APIs.
upload_time2023-03-13 02:00:56
maintainer
docs_urlNone
authorTharles Amaro
requires_python>=3.10
licenseMIT
keywords fastapi http response api documentation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            > 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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tharlesamaro/fastapi-doc-http-response",
    "name": "fastapi-http-response",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "fastapi,http,response,api,documentation",
    "author": "Tharles Amaro",
    "author_email": "tharlesamaro@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b6/08/4b8829f85234f4a97a1bb7e4b6e75df48a1bdf10aa08ce545307e95ae331/fastapi_http_response-0.0.2.tar.gz",
    "platform": null,
    "description": "> Para ler este README em portug\u00eas do Brasil, clique [aqui](https://github.com/tharlesamaro/fastapi-doc-http-response/blob/main/README_br.md).\n\n## FastAPI Doc HTTP Response\n\n[![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)\n\nFastAPI 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.\n\nFastAPI 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.\n\n### Installation\n\nYou can install FastAPI Doc HTTP Response using pip:\n\n```bash\npip install fastapi-doc-http-response\n```\n\n### Usage\n\nTo 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:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi_doc_http_response import get_responses\n\napp = FastAPI()\n\n\n@app.get(\"/xpto\", responses=get_responses(201, 400, 401, 403))\nasync def xpto():\n    # ...\n```\n\nThe code above will define the following standard HTTP responses for the `/xpto` route:\n\n- 201 Created\n- 400 Bad Request\n- 401 Unauthorized\n- 403 Forbidden\n\nThese return codes will also be automatically added to the API documentation generated by FastAPI.\n\nNote 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.\n\n### Supported HTTP Return Codes\n\nThe HTTP return codes supported by FastAPI Doc HTTP Response are:\n\n- 100 Continue\n- 201 Created\n- 202 Accepted\n- 203 Non-Authoritative Information\n- 204 No Content\n- 206 Partial Content\n- 207 Multi-Status\n- 208 Already Reported\n- 226 IM Used\n- 300 Multiple Choices\n- 301 Moved Permanently\n- 302 Found\n- 303 See Other\n- 304 Not Modified\n- 305 Use Proxy\n- 306 Switch Proxy\n- 307 Temporary Redirect\n- 308 Permanent Redirect\n- 400 Bad Request\n- 401 Unauthorized\n- 402 Payment Required\n- 403 Forbidden\n- 404 Not Found\n- 405 Method Not Allowed\n- 406 Not Acceptable\n- 407 Proxy Authentication Required\n- 408 Request Timeout\n- 409 Conflict\n- 410 Gone\n- 411 Length Required\n- 412 Precondition Failed\n- 413 Payload Too Large\n- 414 URI Too Long\n- 416 Range Not Satisfiable\n- 417 Expectation Failed\n- 418 I'm a teapot\n- 420 Enhance Your Calm\n- 423 Locked\n- 424 Failed Dependency\n- 425 Unordered Collection\n- 426 Upgrade Required\n- 429 Too Many Requests\n- 431 Request Header Fields Too Large\n- 444 No Response\n- 449 Retry With\n- 450 Blocked by Windows Parental Controls\n- 451 Unavailable For Legal Reasons\n- 494 Request Header Too Large\n- 500 Internal Server Error\n\n### License\nThis 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.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "This is a Python package that simplifies the definition of standard HTTP responses for FastAPI APIs.",
    "version": "0.0.2",
    "split_keywords": [
        "fastapi",
        "http",
        "response",
        "api",
        "documentation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e2ee1e636f35ee3b301909050a116d78c4cc579eb762cbd3664902e63f32cbd9",
                "md5": "c936e6f894b0a1dad3adcedfc941f752",
                "sha256": "942f8aa319c91270496ac6f8637259ffdec29dcc094033ea0c0ac52a16f919b5"
            },
            "downloads": -1,
            "filename": "fastapi_http_response-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c936e6f894b0a1dad3adcedfc941f752",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 6558,
            "upload_time": "2023-03-13T02:00:54",
            "upload_time_iso_8601": "2023-03-13T02:00:54.919355Z",
            "url": "https://files.pythonhosted.org/packages/e2/ee/1e636f35ee3b301909050a116d78c4cc579eb762cbd3664902e63f32cbd9/fastapi_http_response-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b6084b8829f85234f4a97a1bb7e4b6e75df48a1bdf10aa08ce545307e95ae331",
                "md5": "c0cec4f1db2b59d2425d84066906e7d0",
                "sha256": "138b8bb7c9a960f3f4f59dca87f0277c655a422f6f5da399c5f253c839f02cb1"
            },
            "downloads": -1,
            "filename": "fastapi_http_response-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "c0cec4f1db2b59d2425d84066906e7d0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 5653,
            "upload_time": "2023-03-13T02:00:56",
            "upload_time_iso_8601": "2023-03-13T02:00:56.683679Z",
            "url": "https://files.pythonhosted.org/packages/b6/08/4b8829f85234f4a97a1bb7e4b6e75df48a1bdf10aa08ce545307e95ae331/fastapi_http_response-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-13 02:00:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "tharlesamaro",
    "github_project": "fastapi-doc-http-response",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "fastapi-http-response"
}
        
Elapsed time: 0.04493s