Home / File/ test_response_model_as_return_annotation.py — fastapi Source File

test_response_model_as_return_annotation.py — fastapi Source File

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

File python FastAPI Applications 10 imports 74 functions 4 classes

Entity Profile

Dependency Diagram

graph LR
  cda67a9f_f26d_7734_ec51_1b0ee38954cf["test_response_model_as_return_annotation.py"]
  0dda2280_3359_8460_301c_e98c77e78185["typing"]
  cda67a9f_f26d_7734_ec51_1b0ee38954cf --> 0dda2280_3359_8460_301c_e98c77e78185
  5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"]
  cda67a9f_f26d_7734_ec51_1b0ee38954cf --> 5befe8bf_65d1_d058_6b78_4a597a8488e9
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  cda67a9f_f26d_7734_ec51_1b0ee38954cf --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  01c652c5_d85c_f45e_848e_412c94ea4172["exceptions.py"]
  cda67a9f_f26d_7734_ec51_1b0ee38954cf --> 01c652c5_d85c_f45e_848e_412c94ea4172
  2d54c1ec_3e75_6f8e_face_5433598e4278["FastAPIError"]
  cda67a9f_f26d_7734_ec51_1b0ee38954cf --> 2d54c1ec_3e75_6f8e_face_5433598e4278
  6c4918cc_63d7_a03d_91ee_e65fc35b0746["ResponseValidationError"]
  cda67a9f_f26d_7734_ec51_1b0ee38954cf --> 6c4918cc_63d7_a03d_91ee_e65fc35b0746
  967b6712_70e2_f5fa_f671_7c149857a445["responses.py"]
  cda67a9f_f26d_7734_ec51_1b0ee38954cf --> 967b6712_70e2_f5fa_f671_7c149857a445
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  cda67a9f_f26d_7734_ec51_1b0ee38954cf --> a7c04dee_ee23_5891_b185_47ff6bed036d
  a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"]
  cda67a9f_f26d_7734_ec51_1b0ee38954cf --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a
  6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"]
  cda67a9f_f26d_7734_ec51_1b0ee38954cf --> 6913fbd4_39df_d14b_44bb_522e99b65b90
  style cda67a9f_f26d_7734_ec51_1b0ee38954cf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from typing import Union

import pytest
from fastapi import FastAPI
from fastapi.exceptions import FastAPIError, ResponseValidationError
from fastapi.responses import JSONResponse, Response
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from pydantic import BaseModel


class BaseUser(BaseModel):
    name: str


class User(BaseUser):
    surname: str


class DBUser(User):
    password_hash: str


class Item(BaseModel):
    name: str
    price: float


app = FastAPI()


@app.get("/no_response_model-no_annotation-return_model")
def no_response_model_no_annotation_return_model():
    return User(name="John", surname="Doe")


@app.get("/no_response_model-no_annotation-return_dict")
def no_response_model_no_annotation_return_dict():
    return {"name": "John", "surname": "Doe"}


@app.get("/response_model-no_annotation-return_same_model", response_model=User)
def response_model_no_annotation_return_same_model():
    return User(name="John", surname="Doe")


@app.get("/response_model-no_annotation-return_exact_dict", response_model=User)
def response_model_no_annotation_return_exact_dict():
    return {"name": "John", "surname": "Doe"}


@app.get("/response_model-no_annotation-return_invalid_dict", response_model=User)
def response_model_no_annotation_return_invalid_dict():
    return {"name": "John"}


@app.get("/response_model-no_annotation-return_invalid_model", response_model=User)
def response_model_no_annotation_return_invalid_model():
    return Item(name="Foo", price=42.0)

// ... (1064 more lines)

Domain

Subdomains

Functions

Frequently Asked Questions

What does test_response_model_as_return_annotation.py do?
test_response_model_as_return_annotation.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Applications subdomain.
What functions are defined in test_response_model_as_return_annotation.py?
test_response_model_as_return_annotation.py defines 74 function(s): no_response_model_annotation_forward_ref_list_of_model, no_response_model_annotation_json_response_class, no_response_model_annotation_list_of_model, no_response_model_annotation_response_class, no_response_model_annotation_return_dict_with_extra_data, no_response_model_annotation_return_exact_dict, no_response_model_annotation_return_invalid_dict, no_response_model_annotation_return_invalid_model, no_response_model_annotation_return_same_model, no_response_model_annotation_return_submodel_with_extra_data, and 64 more.
What does test_response_model_as_return_annotation.py depend on?
test_response_model_as_return_annotation.py imports 10 module(s): FastAPIError, ResponseValidationError, __init__.py, exceptions.py, inline_snapshot, pydantic, pytest, responses.py, and 2 more.
Where is test_response_model_as_return_annotation.py in the architecture?
test_response_model_as_return_annotation.py is located at tests/test_response_model_as_return_annotation.py (domain: FastAPI, subdomain: Applications, directory: tests).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free