Skip to main content

Add openapi docs to flask app using Flask-Pydantic

Project description

Flask-Pydantic-Docs

Installation

python3 -m pip install Flask-Pydantic-Docs

Usage

Example

# necessary imports

app = Flask(__name___)
openapi = OpenAPI()

access_denied = APIError(code=403, msg="Access Denied")

@app.route("/post", methods=["POST"])
@openapi_docs(response=ResponseModel, tags=["demo"], exceptions=[access_denied])
@validate()
def post(body: BodyModel, query: QueryModel):
    return ResponseModel(
        id=id_,
        age=query.age,
        name=body.name,
        nickname=body.nickname,
    )
...

openapi.register(app)

Add Auth Security Schemes

# necessary imports, app and model definition

openapi = OpenAPI(
    extra_props={
        "components": {
            "securitySchemes": {
                "bearerAuth": {
                    "type": "http",
                    "scheme": "bearer",
                    "bearerFormat": "JWT",
                    "in": "header",
                }
            }
        },
        "security": [{"bearerAuth": []}]
    },
)

...

openapi.register(app)

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

Flask-Pydantic-Docs-0.0.8.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Flask_Pydantic_Docs-0.0.8-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file Flask-Pydantic-Docs-0.0.8.tar.gz.

File metadata

  • Download URL: Flask-Pydantic-Docs-0.0.8.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using 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.3 CPython/3.7.11

File hashes

Hashes for Flask-Pydantic-Docs-0.0.8.tar.gz
Algorithm Hash digest
SHA256 9afa053b2e93f99d1b689f5cb5e6d4698029c0798d070f4c0072155d1738791a
MD5 b2ed6761600a66b3b39c1be078094f8b
BLAKE2b-256 962ddbf253fc3239dd70d88621be2e2d4baa9bb6f2cee5d8049186b30db53633

See more details on using hashes here.

File details

Details for the file Flask_Pydantic_Docs-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: Flask_Pydantic_Docs-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using 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.3 CPython/3.7.11

File hashes

Hashes for Flask_Pydantic_Docs-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 be52bdcbbe4f12bb929a3f92cb44808e1b3b4246870358b001919401a78f2b51
MD5 8e739846c273200b103495a33b3f7aeb
BLAKE2b-256 1b6526a41d8a7cb4b7bcfd7576cb9a7076554391f87c560acf8586c7994323cb

See more details on using hashes here.

Supported by

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