Skip to content

Bug: openAPI generation - operation requestBody description only on schema output, not at higher level needed for html #3539

Closed
@MCR2019

Description

@MCR2019

Expected Behaviour

When creating an operation such as a PUT with a body parameter, the body parameter description should be populated on the output at the requestBody level (when generating the spec with app.get_openapi_json_schema() ).

Current Behaviour

When creating an operation such as a PUT with a body parameter, the body parameter description only appears in the output under schema (when generating the spec with app.get_openapi_json_schema() ).

Current output shows requestBody description only at the schema level, this means that when redocly is used to create an html file from the spec the description does not appear.
For the path parameter the descrition is populated at two levels which means it does appear in the redocly generated html.

Current output:
image

OAS 3.1.0 looks as though it is possible to populate the description on the requestBody object as well:
image

Code snippet

from typing import Dict, Any

from aws_lambda_powertools.event_handler import APIGatewayRestResolver
from aws_lambda_powertools.event_handler.openapi.params import Body, Path
from aws_lambda_powertools.shared.types import Annotated

app = APIGatewayRestResolver(enable_validation=True)


@app.put(
    "/example-resource/<path_parameter>",
)
def put(
        path_parameter: Annotated[str, Path(description="test path description appears at schema and higher level", example="example01")],
        event_body: Annotated[Dict[str, Any], Body(description="test body description only appears at schema level")]
):
    pass


if __name__ == "__main__":
    print(app.get_openapi_json_schema())

Possible Solution

Populate description on the requestBody object as well as the schema.

Steps to Reproduce

Create an operation with a request body and add a description to the Body object.
Add a path parameter with a description to the operation.
Note on the output where description is populated in two places for the path parameter and only in one place for the body.
Optional -> Can generate a .html using redocly to confirm which of the descriptions makes it into the generated documentation.

Powertools for AWS Lambda (Python) version

2.30.2

AWS Lambda function runtime

3.10

Packaging format used

PyPi

Debugging logs

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions