Expected Behaviour
Given the following route in our application:
@app.patch("/event-types/<event_type_id>/approved-consumers")
def patch_approved_consumers(
event_type_id: str,
approved_consumers: Annotated[list[ApprovedConsumersPatchOperation], Body()],
content_type: Annotated[
Literal["application/json-patch+json"],
Header(alias="Content-Type"),
],
) -> EventTypeModel:
"""Patch approved consumers for an EventType."""
return approved_consumers_controller.patch_approved_consumers(
event_type_id, approved_consumers
)
We would expect the following snippet in our OpenAPI spec:
"requestBody": {
"content": {
"application/json-patch+json": {
"schema": {
"items": {
"$ref": "#/components/schemas/ApprovedConsumersPatchOperation"
},
"type": "array",
"title": "Approved Consumers"
}
}
},
"required": true
},
Current Behaviour
However currently this generates:
"/event-types/{event_type_id}/approved-consumers": {
"patch": {
"summary": "PATCH /event-types/{event_type_id}/approved-consumers",
"operationId": "patch_approved_consumers",
"parameters": [
{
"required": true,
"schema": {
"type": "string",
"title": "Event Type Id"
},
"name": "event_type_id",
"in": "path"
},
{
"required": true,
"schema": {
"type": "string",
"const": "application/json-patch+json",
"title": "Content-Type"
},
"name": "content-type",
"in": "header"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/ApprovedConsumersPatchOperation"
},
"type": "array",
"title": "Approved Consumers"
}
}
},
"required": true
},
Code snippet
@app.patch("/event-types/<event_type_id>/approved-consumers")
def patch_approved_consumers(
event_type_id: str,
approved_consumers: Annotated[list[ApprovedConsumersPatchOperation], Body()],
content_type: Annotated[
Literal["application/json-patch+json"],
Header(alias="Content-Type"),
],
) -> EventTypeModel:
"""Patch approved consumers for an EventType."""
return approved_consumers_controller.patch_approved_consumers(
event_type_id, approved_consumers
)
Possible Solution
Couple headers should be treated as special cases:
https://swagger.io/docs/specification/v3_0/describing-parameters/#header-parameters
Steps to Reproduce
- define route
- generate openapi spec from it
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.13
Packaging format used
PyPi
Debugging logs
Expected Behaviour
Given the following route in our application:
We would expect the following snippet in our OpenAPI spec:
Current Behaviour
However currently this generates:
Code snippet
Possible Solution
Couple headers should be treated as special cases:
https://swagger.io/docs/specification/v3_0/describing-parameters/#header-parameters
Steps to Reproduce
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.13
Packaging format used
PyPi
Debugging logs