Skip to content

Commit

Permalink
fix(event-handler): fix operation tags schema generation (#3528)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenfonseca authored Dec 18, 2023
1 parent 8573c28 commit 926ff86
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion aws_lambda_powertools/event_handler/api_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def _openapi_operation_metadata(self, operation_ids: Set[str]) -> Dict[str, Any]

# Ensure tags is added to the operation
if self.tags:
operation["tags"] = [{"name": tag for tag in self.tags}]
operation["tags"] = self.tags

# Ensure summary is added to the operation
operation["summary"] = self._openapi_operation_summary()
Expand Down
2 changes: 1 addition & 1 deletion aws_lambda_powertools/event_handler/openapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class Config:

# https://swagger.io/specification/#operation-object
class Operation(BaseModel):
tags: Optional[List[Tag]] = None
tags: Optional[List[str]] = None
summary: Optional[str] = None
description: Optional[str] = None
externalDocs: Optional[ExternalDocumentation] = None
Expand Down
7 changes: 3 additions & 4 deletions tests/functional/event_handler/test_openapi_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
Parameter,
ParameterInType,
Schema,
Tag,
)
from aws_lambda_powertools.event_handler.openapi.params import (
Body,
Expand Down Expand Up @@ -119,7 +118,7 @@ def handler(
assert get.summary == "Get Users"
assert get.operationId == "GetUsers"
assert get.description == "Get paginated users"
assert get.tags == [Tag(name="Users")]
assert get.tags == ["Users"]

parameter = get.parameters[0]
assert parameter.required is False
Expand Down Expand Up @@ -378,7 +377,7 @@ def handler():
assert len(get.tags) == 1

tag = get.tags[0]
assert tag.name == "Users"
assert tag == "Users"


def test_openapi_with_excluded_operations():
Expand Down Expand Up @@ -421,7 +420,7 @@ def handler():
schema = app.get_openapi_schema()
tags = schema.paths["/example-resource"].put.tags
assert len(tags) == 1
assert tags[0].name == "Example"
assert tags[0] == "Example"


def test_create_header():
Expand Down

0 comments on commit 926ff86

Please sign in to comment.