Skip to content

Commit 901daf3

Browse files
committed
fix: increase coverage
1 parent 635fadc commit 901daf3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/functional/event_handler/test_openapi_responses.py

+21
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,27 @@ def handler():
5454
assert 422 not in responses.keys()
5555

5656

57+
def test_openapi_200_custom_schema():
58+
app = APIGatewayRestResolver(enable_validation=True)
59+
60+
class User(BaseModel):
61+
pass
62+
63+
@app.get(
64+
"/",
65+
responses={200: {"description": "Custom response", "content": {"application/json": {"schema": User.schema()}}}},
66+
)
67+
def handler():
68+
return {"message": "hello world"}
69+
70+
schema = app.get_openapi_schema()
71+
responses = schema.paths["/"].get.responses
72+
assert 200 in responses.keys()
73+
74+
assert responses[200].description == "Custom response"
75+
assert responses[200].content["application/json"].schema_.title == "User"
76+
77+
5778
def test_openapi_union_response():
5879
app = APIGatewayRestResolver(enable_validation=True)
5980

0 commit comments

Comments
 (0)