Skip to content

Commit 926ff86

Browse files
authored
fix(event-handler): fix operation tags schema generation (#3528)
1 parent 8573c28 commit 926ff86

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

aws_lambda_powertools/event_handler/api_gateway.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ def _openapi_operation_metadata(self, operation_ids: Set[str]) -> Dict[str, Any]
559559

560560
# Ensure tags is added to the operation
561561
if self.tags:
562-
operation["tags"] = [{"name": tag for tag in self.tags}]
562+
operation["tags"] = self.tags
563563

564564
# Ensure summary is added to the operation
565565
operation["summary"] = self._openapi_operation_summary()

aws_lambda_powertools/event_handler/openapi/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ class Config:
380380

381381
# https://swagger.io/specification/#operation-object
382382
class Operation(BaseModel):
383-
tags: Optional[List[Tag]] = None
383+
tags: Optional[List[str]] = None
384384
summary: Optional[str] = None
385385
description: Optional[str] = None
386386
externalDocs: Optional[ExternalDocumentation] = None

tests/functional/event_handler/test_openapi_params.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
Parameter,
1111
ParameterInType,
1212
Schema,
13-
Tag,
1413
)
1514
from aws_lambda_powertools.event_handler.openapi.params import (
1615
Body,
@@ -119,7 +118,7 @@ def handler(
119118
assert get.summary == "Get Users"
120119
assert get.operationId == "GetUsers"
121120
assert get.description == "Get paginated users"
122-
assert get.tags == [Tag(name="Users")]
121+
assert get.tags == ["Users"]
123122

124123
parameter = get.parameters[0]
125124
assert parameter.required is False
@@ -378,7 +377,7 @@ def handler():
378377
assert len(get.tags) == 1
379378

380379
tag = get.tags[0]
381-
assert tag.name == "Users"
380+
assert tag == "Users"
382381

383382

384383
def test_openapi_with_excluded_operations():
@@ -421,7 +420,7 @@ def handler():
421420
schema = app.get_openapi_schema()
422421
tags = schema.paths["/example-resource"].put.tags
423422
assert len(tags) == 1
424-
assert tags[0].name == "Example"
423+
assert tags[0] == "Example"
425424

426425

427426
def test_create_header():

0 commit comments

Comments
 (0)