Home / Function/ test_openapi_schema() — fastapi Function Reference

test_openapi_schema() — fastapi Function Reference

Architecture documentation for the test_openapi_schema() function in test_get_model_definitions_formfeed_escape.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  1bf5e3af_e90b_7c80_5a60_b808678f2603["test_openapi_schema()"]
  f5d6c39f_edf3_f284_1d2b_a21f1c182903["test_get_model_definitions_formfeed_escape.py"]
  1bf5e3af_e90b_7c80_5a60_b808678f2603 -->|defined in| f5d6c39f_edf3_f284_1d2b_a21f1c182903
  style 1bf5e3af_e90b_7c80_5a60_b808678f2603 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_get_model_definitions_formfeed_escape.py lines 52–160

def test_openapi_schema(client: TestClient):
    """
    Sanity check to ensure our app's openapi schema renders as we expect
    """
    response = client.get("/openapi.json")
    assert response.status_code == 200, response.text
    assert response.json() == snapshot(
        {
            "components": {
                "schemas": {
                    "Address": {
                        # NOTE: the description of this model shows only the public-facing text, before the `\f` in docstring
                        "description": "This is a public description of an Address\n",
                        "properties": {
                            "city": {"title": "City", "type": "string"},
                            "line_1": {"title": "Line 1", "type": "string"},
                            "state_province": {
                                "title": "State Province",
                                "type": "string",
                            },
                        },
                        "required": ["line_1", "city", "state_province"],
                        "title": "Address",
                        "type": "object",
                    },
                    "Facility": {
                        "properties": {
                            "address": {"$ref": "#/components/schemas/Address"},
                            "id": {"title": "Id", "type": "string"},
                        },
                        "required": ["id", "address"],
                        "title": "Facility",
                        "type": "object",
                    },
                    "HTTPValidationError": {
                        "properties": {
                            "detail": {
                                "items": {
                                    "$ref": "#/components/schemas/ValidationError"
                                },
                                "title": "Detail",
                                "type": "array",
                            }
                        },
                        "title": "HTTPValidationError",
                        "type": "object",
                    },
                    "ValidationError": {
                        "properties": {
                            "ctx": {"title": "Context", "type": "object"},
                            "input": {"title": "Input"},
                            "loc": {
                                "items": {
                                    "anyOf": [{"type": "string"}, {"type": "integer"}]
                                },
                                "title": "Location",
                                "type": "array",
                            },
                            "msg": {"title": "Message", "type": "string"},
                            "type": {"title": "Error Type", "type": "string"},
                        },
                        "required": ["loc", "msg", "type"],
                        "title": "ValidationError",
                        "type": "object",
                    },
                }
            },
            "info": {"title": "FastAPI", "version": "0.1.0"},
            "openapi": "3.1.0",
            "paths": {
                "/facilities/{facility_id}": {
                    "get": {
                        "operationId": "get_facility_facilities__facility_id__get",
                        "parameters": [
                            {
                                "in": "path",
                                "name": "facility_id",
                                "required": True,
                                "schema": {"title": "Facility Id", "type": "string"},
                            }
                        ],

Domain

Subdomains

Frequently Asked Questions

What does test_openapi_schema() do?
test_openapi_schema() is a function in the fastapi codebase, defined in tests/test_get_model_definitions_formfeed_escape.py.
Where is test_openapi_schema() defined?
test_openapi_schema() is defined in tests/test_get_model_definitions_formfeed_escape.py at line 52.

Analyze Your Own Codebase

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

Try Supermodel Free