'FastAPI swagger don't use custom header
I want to add "Authorization" header to the my FastAPI application. I did it by documentation, but when i try to execute request in the swagger - it doesn't work(swagger don't use custom header), i have "Missing Authorization Header" error Error in the swagger
Solution 1:[1]
That is because OpenAPI specs restrict you from declaring Authorization
header. Other headers that are restricted are Accept
and Content-Type
. User HTTPBearer
instead.
Source: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#fixed-fields-10
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Eli Halych |