quart-schema icon indicating copy to clipboard operation
quart-schema copied to clipboard

`HttpSecurityScheme` uses wrong bearerFormat attribute name

Open DanielHabenicht opened this issue 1 year ago • 1 comments

The generated OpenAPI schema is invalid if the bearer_format option is specified:

QuartSchema(
    app,
    security=[{"bearerAuth": []}],
    security_schemes={"bearerAuth": {"type": "http", "bearer_format": "JWT", "scheme": "bearer"}},
)

# because of
@dataclass
class HttpSecurityScheme(SecuritySchemeBase):
    scheme: str
    bearer_format: Optional[str] = None
    type: Literal["http"] = "http"

Resulting Schema:

// ...
        "securitySchemes": {
            "bearerAuth": {
                "bearer_format": "JWT",
                "scheme": "bearer",
                "type": "http"
            }
        }

It should be bearerFormat as specified: https://spec.openapis.org/oas/v3.1.0#fixed-fields-22

DanielHabenicht avatar Jul 23 '24 10:07 DanielHabenicht

Should I make a PR where the attribute is aliased?

@dataclass
class HttpSecurityScheme(SecuritySchemeBase):
    scheme: str
    bearer_format: Optional[str] = Field(None, alias='bearerFormat')
    type: Literal["http"] = "http"

Or do you want to handle it centrally for all attributes?

DanielHabenicht avatar Jul 23 '24 14:07 DanielHabenicht

Thanks, this was a bug fixed in 04d5a27b969977db529dd6d68539bff4750017f6

pgjones avatar Dec 31 '24 20:12 pgjones