test_additional_responses_custom_validationerror.py — fastapi Source File
Architecture documentation for test_additional_responses_custom_validationerror.py, a python file in the fastapi codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR dfff6014_f006_aa5d_29b9_ef946d567ce4["test_additional_responses_custom_validationerror.py"] 534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"] dfff6014_f006_aa5d_29b9_ef946d567ce4 --> 534f6e44_61b8_3c38_8b89_6934a6df9802 967b6712_70e2_f5fa_f671_7c149857a445["responses.py"] dfff6014_f006_aa5d_29b9_ef946d567ce4 --> 967b6712_70e2_f5fa_f671_7c149857a445 a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"] dfff6014_f006_aa5d_29b9_ef946d567ce4 --> a7c04dee_ee23_5891_b185_47ff6bed036d a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"] dfff6014_f006_aa5d_29b9_ef946d567ce4 --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a 6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"] dfff6014_f006_aa5d_29b9_ef946d567ce4 --> 6913fbd4_39df_d14b_44bb_522e99b65b90 style dfff6014_f006_aa5d_29b9_ef946d567ce4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
class JsonApiResponse(JSONResponse):
media_type = "application/vnd.api+json"
class Error(BaseModel):
status: str
title: str
class JsonApiError(BaseModel):
errors: list[Error]
@app.get(
"/a/{id}",
response_class=JsonApiResponse,
responses={422: {"description": "Error", "model": JsonApiError}},
)
async def a(id):
pass # pragma: no cover
client = TestClient(app)
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": {
"/a/{id}": {
"get": {
"responses": {
"422": {
"description": "Error",
"content": {
"application/vnd.api+json": {
"schema": {
"$ref": "#/components/schemas/JsonApiError"
}
}
},
},
"200": {
"description": "Successful Response",
"content": {"application/vnd.api+json": {"schema": {}}},
},
},
"summary": "A",
"operationId": "a_a__id__get",
"parameters": [
{
"required": True,
"schema": {"title": "Id"},
"name": "id",
"in": "path",
}
],
}
}
},
"components": {
"schemas": {
"Error": {
"title": "Error",
"required": ["status", "title"],
"type": "object",
"properties": {
"status": {"title": "Status", "type": "string"},
"title": {"title": "Title", "type": "string"},
},
},
"JsonApiError": {
"title": "JsonApiError",
"required": ["errors"],
"type": "object",
"properties": {
"errors": {
"title": "Errors",
"type": "array",
"items": {"$ref": "#/components/schemas/Error"},
}
},
},
}
},
}
)
Domain
Subdomains
Functions
Classes
Dependencies
- __init__.py
- inline_snapshot
- pydantic
- responses.py
- testclient.py
Source
Frequently Asked Questions
What does test_additional_responses_custom_validationerror.py do?
test_additional_responses_custom_validationerror.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Responses subdomain.
What functions are defined in test_additional_responses_custom_validationerror.py?
test_additional_responses_custom_validationerror.py defines 2 function(s): a, test_openapi_schema.
What does test_additional_responses_custom_validationerror.py depend on?
test_additional_responses_custom_validationerror.py imports 5 module(s): __init__.py, inline_snapshot, pydantic, responses.py, testclient.py.
Where is test_additional_responses_custom_validationerror.py in the architecture?
test_additional_responses_custom_validationerror.py is located at tests/test_additional_responses_custom_validationerror.py (domain: FastAPI, subdomain: Responses, directory: tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free