Specify securitySchemes description in OpenAPI #9013
Unanswered
and-semakin
asked this question in
Questions
Replies: 1 comment
-
@and-semakin This was already handled by #1757 . Can you mark this discussion as answered? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First check
Description
According to the OpenAPI scheme, there is an optional
description
field that can be specified for any authentication type. For example, here it is forOAuth2
: https://github.com/OAI/OpenAPI-Specification/blob/42a9e3d4eddade52363a5c4fac852e80681c2fe5/schemas/v3.0/schema.yaml#L831-L832.If we look at FastAPI's own code, we also find it: https://github.com/tiangolo/fastapi/blob/33be5fc8baa02bae949e1986f1821dae8f84f487/fastapi/openapi/models.py#L258.
Unfortunately, there is no easy way to fill this field for pre-defined security dependencies because none of them accept the
description
parameter.Example
What I want to achieve as a result is the following OpenAPI spec fragment:
The solution you would like
All child classes of
SecurityBase
(i.e.HTTPBase
,OAuth2
,OpenIdConnect
, etc) should acceptdescription
as an optional argument in the__init__
method and properly configure itsself.model
attribute using this description.Environment
0.62.0
3.8.6
Additional context
Note: there is also a bug in Swagger UI that prevents the description from being shown up. But we at least need to support it on the FastAPI side.
Beta Was this translation helpful? Give feedback.
All reactions