test_openapi_schema() — fastapi Function Reference
Architecture documentation for the test_openapi_schema() function in test_schema_extra_examples.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD b4c1b3db_c0b3_d44b_7817_a5d4c5e5d3c7["test_openapi_schema()"] 3fe4836c_ae70_fc66_8f09_91aac47b55e8["test_schema_extra_examples.py"] b4c1b3db_c0b3_d44b_7817_a5d4c5e5d3c7 -->|defined in| 3fe4836c_ae70_fc66_8f09_91aac47b55e8 562dc8b3_7513_1235_4e0a_83c83e613a74["create_app()"] b4c1b3db_c0b3_d44b_7817_a5d4c5e5d3c7 -->|calls| 562dc8b3_7513_1235_4e0a_83c83e613a74 style b4c1b3db_c0b3_d44b_7817_a5d4c5e5d3c7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_schema_extra_examples.py lines 255–859
def test_openapi_schema():
"""
Test that example overrides work:
* pydantic model schema_extra is included
* Body(example={}) overrides schema_extra in pydantic model
* Body(examples{}) overrides Body(example={}) and schema_extra in pydantic model
"""
app = create_app()
client = TestClient(app)
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": {
"/schema_extra/": {
"post": {
"summary": "Schema Extra",
"operationId": "schema_extra_schema_extra__post",
"requestBody": {
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/Item"}
}
},
"required": True,
},
"responses": {
"200": {
"description": "Successful Response",
"content": {"application/json": {"schema": {}}},
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
},
},
},
}
},
"/example/": {
"post": {
"summary": "Example",
"operationId": "example_example__post",
"requestBody": {
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/Item"},
"example": {"data": "Data in Body example"},
}
},
"required": True,
},
"responses": {
"200": {
"description": "Successful Response",
"content": {"application/json": {"schema": {}}},
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
},
},
},
}
},
"/examples/": {
"post": {
"summary": "Examples",
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does test_openapi_schema() do?
test_openapi_schema() is a function in the fastapi codebase, defined in tests/test_schema_extra_examples.py.
Where is test_openapi_schema() defined?
test_openapi_schema() is defined in tests/test_schema_extra_examples.py at line 255.
What does test_openapi_schema() call?
test_openapi_schema() calls 1 function(s): create_app.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free