generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 461
Open
Labels
Description
Expected Behaviour
OpenApi schemas should display the title property instead of the name in the swaggerUI html page, when specified.
Current Behaviour
The title is never shown, although present in the openapi specification, which properly generates the title property, derived from pydantic models.
This seems like a similar issue to this one.
Code snippet
from pydantic import AwareDatetime, BaseModel, ConfigDict, Field
import requests
from requests import Response
from aws_lambda_powertools import Logger, Tracer
from aws_lambda_powertools.event_handler import APIGatewayRestResolver
from aws_lambda_powertools.logging import correlation_paths
from aws_lambda_powertools.utilities.typing import LambdaContext
class ToDo(BaseModel):
model_config = ConfigDict(
from_attributes=True,
title="todoTitle",
)
tracer = Tracer()
logger = Logger()
app = APIGatewayRestResolver()
app.enable_swagger(path="/swagger")
@app.get("/todos")
@tracer.capture_method
def get_todos()->ToDo:
return ToDo()
@logger.inject_lambda_context(correlation_id_path=correlation_paths.API_GATEWAY_REST)
@tracer.capture_lambda_handler
def lambda_handler(event: dict, context: LambdaContext) -> dict:
return app.resolve(event, context)Possible Solution
Minified JS version of swaggerUi might be outdated, as in the https://editor.swagger.io/ it seems to work, and there have been fixes in the swaggerui repo for a similar issue, as linked above.
Steps to Reproduce
- Create an api gateway following the snippet above
- Open the swaggerUI hosted at /swagger
- The ToDo schema does not show the defined title, but the pydantic model's name
- Open the /swagger?format=json and check the schema has the title property set
- Paste the json format in https://editor.swagger.io/, the title is shown instead of the name
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.12
Packaging format used
Lambda Layers
Debugging logs
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Backlog