Skip to content

Commit e243200

Browse files
committed
fix: pydantic2 models
1 parent 76f3a32 commit e243200

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

aws_lambda_powertools/event_handler/openapi/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ class Operation(BaseModel):
373373
parameters: Optional[List[Union[Parameter, Reference]]] = None
374374
requestBody: Optional[Union[RequestBody, Reference]] = None
375375
# Using Any for Specification Extensions
376-
responses: Optional[Dict[str, Union[Response, Any]]] = None
376+
responses: Optional[Dict[int, Union[Response, Any]]] = None
377377
callbacks: Optional[Dict[str, Union[Dict[str, "PathItem"], Reference]]] = None
378378
deprecated: Optional[bool] = None
379379
security: Optional[List[Dict[str, List[str]]]] = None

tests/functional/event_handler/test_openapi_params.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def handler():
3939
assert get.operationId == "handler__get"
4040

4141
assert get.responses is not None
42-
assert "200" in get.responses.keys()
43-
response = get.responses["200"]
42+
assert 200 in get.responses.keys()
43+
response = get.responses[200]
4444
assert response.description == "Successful Response"
4545

4646
assert JSON_CONTENT_TYPE in response.content
@@ -140,7 +140,7 @@ def handler() -> str:
140140
get = schema.paths["/"].get
141141
assert get.parameters is None
142142

143-
response = get.responses["200"].content[JSON_CONTENT_TYPE]
143+
response = get.responses[200].content[JSON_CONTENT_TYPE]
144144
assert response.schema_.title == "Return"
145145
assert response.schema_.type == "string"
146146

@@ -161,7 +161,7 @@ def handler() -> User:
161161
get = schema.paths["/"].get
162162
assert get.parameters is None
163163

164-
response = get.responses["200"].content[JSON_CONTENT_TYPE]
164+
response = get.responses[200].content[JSON_CONTENT_TYPE]
165165
reference = response.schema_
166166
assert reference.ref == "#/components/schemas/User"
167167

@@ -214,7 +214,7 @@ def handler() -> User:
214214
get = schema.paths["/"].get
215215
assert get.parameters is None
216216

217-
response = get.responses["200"].content[JSON_CONTENT_TYPE]
217+
response = get.responses[200].content[JSON_CONTENT_TYPE]
218218
reference = response.schema_
219219
assert reference.ref == "#/components/schemas/User"
220220

tests/functional/event_handler/test_openapi_responses.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ def handler():
1010

1111
schema = app.get_openapi_schema()
1212
responses = schema.paths["/"].get.responses
13-
assert "200" in responses.keys()
14-
assert responses["200"].description == "Successful Response"
13+
assert 200 in responses.keys()
14+
assert responses[200].description == "Successful Response"
1515

16-
assert "422" in responses.keys()
17-
assert responses["422"].description == "Validation Error"
16+
assert 422 in responses.keys()
17+
assert responses[422].description == "Validation Error"
1818

1919

2020
def test_openapi_200_response_with_description():
@@ -26,11 +26,11 @@ def handler():
2626

2727
schema = app.get_openapi_schema()
2828
responses = schema.paths["/"].get.responses
29-
assert "200" in responses.keys()
30-
assert responses["200"].description == "Custom response"
29+
assert 200 in responses.keys()
30+
assert responses[200].description == "Custom response"
3131

32-
assert "422" in responses.keys()
33-
assert responses["422"].description == "Validation Error"
32+
assert 422 in responses.keys()
33+
assert responses[422].description == "Validation Error"
3434

3535

3636
def test_openapi_200_custom_response():
@@ -42,8 +42,8 @@ def handler():
4242

4343
schema = app.get_openapi_schema()
4444
responses = schema.paths["/"].get.responses
45-
assert "202" in responses.keys()
46-
assert responses["202"].description == "Custom response"
45+
assert 202 in responses.keys()
46+
assert responses[202].description == "Custom response"
4747

48-
assert "200" not in responses.keys()
49-
assert "422" not in responses.keys()
48+
assert 200 not in responses.keys()
49+
assert 422 not in responses.keys()

0 commit comments

Comments
 (0)