Home / File/ test_default_response_class.py — fastapi Source File

test_default_response_class.py — fastapi Source File

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

File python FastAPI Responses 5 imports 28 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  25823848_c86e_6864_3a93_eb1f1621704a["test_default_response_class.py"]
  0dda2280_3359_8460_301c_e98c77e78185["typing"]
  25823848_c86e_6864_3a93_eb1f1621704a --> 0dda2280_3359_8460_301c_e98c77e78185
  9de9d538_b3d9_ff4a_53fa_f662e9eee826["orjson"]
  25823848_c86e_6864_3a93_eb1f1621704a --> 9de9d538_b3d9_ff4a_53fa_f662e9eee826
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  25823848_c86e_6864_3a93_eb1f1621704a --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  967b6712_70e2_f5fa_f671_7c149857a445["responses.py"]
  25823848_c86e_6864_3a93_eb1f1621704a --> 967b6712_70e2_f5fa_f671_7c149857a445
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  25823848_c86e_6864_3a93_eb1f1621704a --> a7c04dee_ee23_5891_b185_47ff6bed036d
  style 25823848_c86e_6864_3a93_eb1f1621704a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from typing import Any

import orjson
from fastapi import APIRouter, FastAPI
from fastapi.responses import HTMLResponse, JSONResponse, PlainTextResponse
from fastapi.testclient import TestClient


class ORJSONResponse(JSONResponse):
    media_type = "application/x-orjson"

    def render(self, content: Any) -> bytes:
        return orjson.dumps(content)


class OverrideResponse(JSONResponse):
    media_type = "application/x-override"


app = FastAPI(default_response_class=ORJSONResponse)
router_a = APIRouter()
router_a_a = APIRouter()
router_a_b_override = APIRouter()  # Overrides default class
router_b_override = APIRouter()  # Overrides default class
router_b_a = APIRouter()
router_b_a_c_override = APIRouter()  # Overrides default class again


@app.get("/")
def get_root():
    return {"msg": "Hello World"}


@app.get("/override", response_class=PlainTextResponse)
def get_path_override():
    return "Hello World"


@router_a.get("/")
def get_a():
    return {"msg": "Hello A"}


@router_a.get("/override", response_class=PlainTextResponse)
def get_a_path_override():
    return "Hello A"


@router_a_a.get("/")
def get_a_a():
    return {"msg": "Hello A A"}


@router_a_a.get("/override", response_class=PlainTextResponse)
def get_a_a_path_override():
    return "Hello A A"


@router_a_b_override.get("/")
def get_a_b():
// ... (157 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does test_default_response_class.py do?
test_default_response_class.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_default_response_class.py?
test_default_response_class.py defines 28 function(s): get_a, get_a_a, get_a_a_path_override, get_a_b, get_a_b_path_override, get_a_path_override, get_b, get_b_a, get_b_a_c, get_b_a_c_path_override, and 18 more.
What does test_default_response_class.py depend on?
test_default_response_class.py imports 5 module(s): __init__.py, orjson, responses.py, testclient.py, typing.
Where is test_default_response_class.py in the architecture?
test_default_response_class.py is located at tests/test_default_response_class.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