In APIFlask, can auth be used to protect the Swagger endpoints?

74 Views Asked by At

I have an APIFlask app that servers Swagger UI and OpenAPI spec endpoints. (/docs and /openapi.json, respectively.)

I have successfully implementer JWT-based Bearer auth to protect my own endpoints, but I don't see any obvious way to protect the auto-generated Swagger UI and OpenAPI spec endpoints.

Suggestions?

1

There are 1 best solutions below

0
Notscientific Farmer On BEST ANSWER

From version 2.1.0, we can add the auth decorators with the SPEC_DECORATORS or DOCS_DECORATORS configuration.

See more with: https://apiflask.com/openapi/#protect-openapi-endpoints