pgjones / quart-schema

Quart-Schema is a Quart extension that provides schema validation and auto-generated API documentation.
MIT License
78 stars 23 forks source link

Swagger UI doesn't add required headers in request #51

Closed PrasannaVenkadesh closed 1 year ago

PrasannaVenkadesh commented 1 year ago

Quart: 0.18.4 Quart-schema: 0.16.0 Pydantic: 1.10.11

Code sample

@dataclass
class AuthHeader:
    authorization: str

@app.get("/users")
@validate_headers(AuthHeader)
async def get_users(headers):
    print(headers)
    return {"message": "success"}, 200

In the resulting openapi.json and the swagger UI, the Authorization header field is rendered, but while trying out a sample request, even after adding value to the header field, the header is not included in the resulting request. Please refer screenshot below.

image

PrasannaVenkadesh commented 1 year ago

Ok, looks like I have to add security scheme for Authorization and as per Swagger documentation if 'Authorization" header is added as part of custom header, it will be ignored. Not a bug. Closing.

https://github.com/swagger-api/swagger-ui/issues/5643#issuecomment-538412105