test_openapi_schema() — fastapi Function Reference
Architecture documentation for the test_openapi_schema() function in test_tutorial002.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 5ff49077_01ea_dcf3_6112_53775196a8a5["test_openapi_schema()"] 6a23c7bb_bc43_fa1e_fdae_aca0cff0797f["test_tutorial002.py"] 5ff49077_01ea_dcf3_6112_53775196a8a5 -->|defined in| 6a23c7bb_bc43_fa1e_fdae_aca0cff0797f style 5ff49077_01ea_dcf3_6112_53775196a8a5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_tutorial/test_schema_extra_example/test_tutorial002.py lines 37–147
def test_openapi_schema(client: TestClient):
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/{item_id}": {
"put": {
"summary": "Update Item",
"operationId": "update_item_items__item_id__put",
"parameters": [
{
"name": "item_id",
"in": "path",
"required": True,
"schema": {"type": "integer", "title": "Item Id"},
}
],
"requestBody": {
"required": True,
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/Item"}
}
},
},
"responses": {
"200": {
"description": "Successful Response",
"content": {"application/json": {"schema": {}}},
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
},
},
},
}
}
},
"components": {
"schemas": {
"HTTPValidationError": {
"properties": {
"detail": {
"items": {
"$ref": "#/components/schemas/ValidationError"
},
"type": "array",
"title": "Detail",
}
},
"type": "object",
"title": "HTTPValidationError",
},
"Item": {
"properties": {
"name": {
"type": "string",
"title": "Name",
"examples": ["Foo"],
},
"description": {
"anyOf": [{"type": "string"}, {"type": "null"}],
"title": "Description",
"examples": ["A very nice Item"],
},
"price": {
"type": "number",
"title": "Price",
"examples": [35.4],
},
"tax": {
"anyOf": [{"type": "number"}, {"type": "null"}],
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_tutorial/test_schema_extra_example/test_tutorial002.py.
Where is test_openapi_schema() defined?
test_openapi_schema() is defined in tests/test_tutorial/test_schema_extra_example/test_tutorial002.py at line 37.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free