test_openapi_schema() — fastapi Function Reference
Architecture documentation for the test_openapi_schema() function in test_union_body_discriminator_annotated.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD d2a9b853_014b_2d4e_420d_a2ca91508013["test_openapi_schema()"] 2085b234_c53e_638c_3dcf_8d81fbaa1f3d["test_union_body_discriminator_annotated.py"] d2a9b853_014b_2d4e_420d_a2ca91508013 -->|defined in| 2085b234_c53e_638c_3dcf_8d81fbaa1f3d style d2a9b853_014b_2d4e_420d_a2ca91508013 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_union_body_discriminator_annotated.py lines 60–203
def test_openapi_schema(client: TestClient) -> None:
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
"/pet/assignment": {
"post": {
"summary": "Create Pet Assignment",
"operationId": "create_pet_assignment_pet_assignment_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"anyOf": [
{"$ref": "#/components/schemas/Cat"},
{"$ref": "#/components/schemas/Dog"},
],
"title": "Pet",
}
}
},
"required": True,
},
"responses": {
"200": {
"description": "Successful Response",
"content": {"application/json": {"schema": {}}},
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
},
},
},
}
},
"/pet/annotated": {
"post": {
"summary": "Create Pet Annotated",
"operationId": "create_pet_annotated_pet_annotated_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"oneOf": [
{"$ref": "#/components/schemas/Cat"},
{"$ref": "#/components/schemas/Dog"},
],
"title": "Pet",
}
}
},
"required": True,
},
"responses": {
"200": {
"description": "Successful Response",
"content": {"application/json": {"schema": {}}},
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
},
},
},
}
},
},
Domain
Subdomains
Source
Frequently Asked Questions
What does test_openapi_schema() do?
test_openapi_schema() is a function in the fastapi codebase, defined in tests/test_union_body_discriminator_annotated.py.
Where is test_openapi_schema() defined?
test_openapi_schema() is defined in tests/test_union_body_discriminator_annotated.py at line 60.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free