Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions tests/test_openapi_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ def method_test_deprecated_example_examples(
return dict(i=param2, f=param3)


class Payload(Schema):
# Duplicated Schema name with another fields
s: str


@api.post("/test-duplicated-payload-name", response=Response)
def method_duplicated_payload_name(request, data: Payload):
return data.dict()


def test_schema_views(client: Client):
assert client.get("/api/").status_code == 404
assert client.get("/api/docs").status_code == 200
Expand Down Expand Up @@ -240,6 +250,42 @@ def test_schema(schema):
}


def test_duplicated_payload_names(schema):
openapi_schemas = schema["components"]["schemas"]

assert openapi_schemas["Payload"] == {
"properties": {
"f": {
"title": "F",
"type": "number",
},
"i": {
"title": "I",
"type": "integer",
},
},
"required": [
"i",
"f",
],
"title": "Payload",
"type": "object",
}
assert openapi_schemas["Payload2"] == {
"properties": {
"s": {
"title": "S",
"type": "string",
},
},
"required": [
"s",
],
"title": "Payload2",
"type": "object",
}


def test_schema_alias(schema):
method = schema["paths"]["/api/test-alias"]["post"]

Expand Down
Loading