Skip to content

Commit 139107a

Browse files
chore: update swagger ui files (#7914)
1 parent a3255e9 commit 139107a

File tree

3 files changed

+43
-13
lines changed

3 files changed

+43
-13
lines changed

aws_lambda_powertools/event_handler/openapi/swagger_ui/swagger-ui-bundle.min.js

Lines changed: 2 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aws_lambda_powertools/event_handler/openapi/swagger_ui/swagger-ui.min.css

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/functional/event_handler/_pydantic/test_openapi_swagger.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import warnings
55

66
import pytest
7+
from pydantic import BaseModel, ConfigDict
78

89
from aws_lambda_powertools.event_handler import APIGatewayRestResolver
910
from aws_lambda_powertools.event_handler.openapi.swagger_ui import OAuth2Config
@@ -125,3 +126,40 @@ def test_openapi_swagger_oauth2_with_powertools_dev(monkeypatch):
125126
)
126127

127128
monkeypatch.delenv("POWERTOOLS_DEV")
129+
130+
131+
def test_openapi_swagger_schema_title_property():
132+
"""Test that schema title property is correctly included in OpenAPI spec.
133+
134+
This test ensures that when a Pydantic model has a custom title defined
135+
via ConfigDict, it is properly reflected in the OpenAPI schema.
136+
See: https://github.com/aws-powertools/powertools-lambda-python/issues/7670
137+
"""
138+
app = APIGatewayRestResolver(enable_validation=True)
139+
app.enable_swagger()
140+
141+
@app.get("/todos")
142+
def get_todos() -> ToDoWithTitle:
143+
return ToDoWithTitle(task="test")
144+
145+
event = load_event("apiGatewayProxyEvent.json")
146+
event["path"] = "/swagger"
147+
event["queryStringParameters"] = {"format": "json"}
148+
149+
result = app(event, {})
150+
151+
assert result["statusCode"] == 200
152+
body = json.loads(result["body"])
153+
154+
# Verify the schema has the title property set
155+
assert "components" in body
156+
assert "schemas" in body["components"]
157+
assert "ToDoWithTitle" in body["components"]["schemas"]
158+
assert body["components"]["schemas"]["ToDoWithTitle"]["title"] == "todoTitle"
159+
160+
161+
class ToDoWithTitle(BaseModel):
162+
"""Model with custom title for testing schema title property."""
163+
164+
model_config = ConfigDict(title="todoTitle")
165+
task: str

0 commit comments

Comments
 (0)