You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used the GitHub search to find a similar question and didn't find it.
I searched the FastAPI documentation, with the integrated search.
I already searched in Google "How to X in FastAPI" and didn't find any information.
I already read and followed all the tutorial in the docs and didn't find an answer.
I already checked if it is not related to FastAPI but to Pydantic.
I already checked if it is not related to FastAPI but to Swagger UI.
I already checked if it is not related to FastAPI but to ReDoc.
Commit to Help
I commit to help with one of those options 👆
Example Code
# Example what we wantclassAuthClass(SecurityBase):
model=APIKey.construct(in_=APIKeyIn.header, name="Authorization")
scheme_name="token"def__init__(self, scopes: list[str] = []):
self.openapi_extra= {"required scopes": ", ".join(scopes)}
...
asyncdef__call__(...): ...
@router.post('/')defupdate_list(
user=Depends(AuthClass(scopes=["print.user.create"])),
): ...
Description
We implemented a bit complicated class for OAuth-like authorisation. Now we want to add some fields to OpenAPI specification in automatic way, e.g. required auth scopes to use API route. I've inspected the whole FastAPI code and almost sure that this functionality does not currently exist. Is is right? If it is, I have a feature request =) It doesn't seem to be difficult
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
We implemented a bit complicated class for OAuth-like authorisation. Now we want to add some fields to OpenAPI specification in automatic way, e.g. required auth scopes to use API route. I've inspected the whole FastAPI code and almost sure that this functionality does not currently exist. Is is right? If it is, I have a feature request =) It doesn't seem to be difficult
Operating System
Other
Operating System Details
No response
FastAPI Version
N/A
Python Version
3.11+
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions