test_openapi_schema() — fastapi Function Reference
Architecture documentation for the test_openapi_schema() function in test_union_body.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 72a18592_756d_4c8d_2261_c29dbab31ce5["test_openapi_schema()"] 5bdcd235_beb0_edf1_0e51_f0ed90902764["test_union_body.py"] 72a18592_756d_4c8d_2261_c29dbab31ce5 -->|defined in| 5bdcd235_beb0_edf1_0e51_f0ed90902764 style 72a18592_756d_4c8d_2261_c29dbab31ce5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_union_body.py lines 39–136
def test_openapi_schema():
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": {
"/items/": {
"post": {
"responses": {
"200": {
"description": "Successful Response",
"content": {"application/json": {"schema": {}}},
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
},
},
},
"summary": "Save Union Body",
"operationId": "save_union_body_items__post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"title": "Item",
"anyOf": [
{"$ref": "#/components/schemas/OtherItem"},
{"$ref": "#/components/schemas/Item"},
],
}
}
},
"required": True,
},
}
}
},
"components": {
"schemas": {
"OtherItem": {
"title": "OtherItem",
"required": ["price"],
"type": "object",
"properties": {"price": {"title": "Price", "type": "integer"}},
},
"Item": {
"title": "Item",
"type": "object",
"properties": {
"name": {
"title": "Name",
"anyOf": [{"type": "string"}, {"type": "null"}],
}
},
},
"ValidationError": {
"title": "ValidationError",
"required": ["loc", "msg", "type"],
"type": "object",
"properties": {
"loc": {
"title": "Location",
"type": "array",
"items": {
"anyOf": [{"type": "string"}, {"type": "integer"}]
},
},
"msg": {"title": "Message", "type": "string"},
"type": {"title": "Error Type", "type": "string"},
"input": {"title": "Input"},
"ctx": {"title": "Context", "type": "object"},
},
},
Domain
Subdomains
Defined In
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.py.
Where is test_openapi_schema() defined?
test_openapi_schema() is defined in tests/test_union_body.py at line 39.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free