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___)

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
# add routes on app or blueprint
app.register_blueprint(some_blueprint)
...

# register openapi docs blueprint to `app`
add_openapi_spec(
    app,
    extra_props={
        "components": {
            "securitySchemes": {
                "bearerAuth": {
                    "type": "http",
                    "scheme": "bearer",
                    "bearerFormat": "JWT",
                    "in": "header",
                }
            }
        },
        "security": [{"bearerAuth": []}]
    },
)

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.5.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.5-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: Flask-Pydantic-Docs-0.0.5.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.5.tar.gz
Algorithm Hash digest
SHA256 cf30f59b8b731456b4b66028c1f3d8753f643a0e850cf01c900c751ab5dd97b4
MD5 52294e3b7d94731fab3909dbf8671a5e
BLAKE2b-256 94494156df19075397c0fe4c136ec8c742379b16ea67669eb605e1cf5e741c49

See more details on using hashes here.

File details

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

File metadata

  • Download URL: Flask_Pydantic_Docs-0.0.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f18165d3dd764cbefee029b9c8b5916f90d29c8db9d03ce0017c2879b4f9aca1
MD5 b394738473a99f608a8363a2469a2c90
BLAKE2b-256 71ed6868d2e1968491868b81421414bc9300f0c29886afbd5959909ba3bbc5ac

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