Home / File/ test_additional_responses_custom_model_in_callback.py — fastapi Source File

test_additional_responses_custom_model_in_callback.py — fastapi Source File

Architecture documentation for test_additional_responses_custom_model_in_callback.py, a python file in the fastapi codebase. 5 imports, 0 dependents.

File python FastAPI Responses 5 imports 3 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  f94fef85_5440_ee04_de4b_91d40adf6f11["test_additional_responses_custom_model_in_callback.py"]
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  f94fef85_5440_ee04_de4b_91d40adf6f11 --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  f94fef85_5440_ee04_de4b_91d40adf6f11 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"]
  f94fef85_5440_ee04_de4b_91d40adf6f11 --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a
  6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"]
  f94fef85_5440_ee04_de4b_91d40adf6f11 --> 6913fbd4_39df_d14b_44bb_522e99b65b90
  e5a24867_6a9b_cc44_1a92_bc955a4ceb50["starlette.responses"]
  f94fef85_5440_ee04_de4b_91d40adf6f11 --> e5a24867_6a9b_cc44_1a92_bc955a4ceb50
  style f94fef85_5440_ee04_de4b_91d40adf6f11 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from fastapi import APIRouter, FastAPI
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from pydantic import BaseModel, HttpUrl
from starlette.responses import JSONResponse


class CustomModel(BaseModel):
    a: int


app = FastAPI()

callback_router = APIRouter(default_response_class=JSONResponse)


@callback_router.get(
    "{$callback_url}/callback/", responses={400: {"model": CustomModel}}
)
def callback_route():
    pass  # pragma: no cover


@app.post("/", callbacks=callback_router.routes)
def main_route(callback_url: HttpUrl):
    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": {
                "/": {
                    "post": {
                        "summary": "Main Route",
                        "operationId": "main_route__post",
                        "parameters": [
                            {
                                "required": True,
                                "schema": {
                                    "title": "Callback Url",
                                    "maxLength": 2083,
                                    "minLength": 1,
                                    "type": "string",
                                    "format": "uri",
                                },
                                "name": "callback_url",
                                "in": "query",
                            }
                        ],
                        "responses": {
                            "200": {
                                "description": "Successful Response",
// ... (88 more lines)

Domain

Subdomains

Classes

Dependencies

Frequently Asked Questions

What does test_additional_responses_custom_model_in_callback.py do?
test_additional_responses_custom_model_in_callback.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_model_in_callback.py?
test_additional_responses_custom_model_in_callback.py defines 3 function(s): callback_route, main_route, test_openapi_schema.
What does test_additional_responses_custom_model_in_callback.py depend on?
test_additional_responses_custom_model_in_callback.py imports 5 module(s): __init__.py, inline_snapshot, pydantic, starlette.responses, testclient.py.
Where is test_additional_responses_custom_model_in_callback.py in the architecture?
test_additional_responses_custom_model_in_callback.py is located at tests/test_additional_responses_custom_model_in_callback.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