Home / Function/ test_openapi_schema() — fastapi Function Reference

test_openapi_schema() — fastapi Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  ec6f9987_5794_714b_ce1b_d1ab3e6cb32c["test_openapi_schema()"]
  a0978363_c79b_c0eb_a602_c69782cd758e["test_additional_responses_union_duplicate_anyof.py"]
  ec6f9987_5794_714b_ce1b_d1ab3e6cb32c -->|defined in| a0978363_c79b_c0eb_a602_c69782cd758e
  style ec6f9987_5794_714b_ce1b_d1ab3e6cb32c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_additional_responses_union_duplicate_anyof.py lines 46–126

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": {
                "/route1": {
                    "get": {
                        "summary": "Route1",
                        "operationId": "route1_route1_get",
                        "responses": {
                            "200": {
                                "description": "Successful Response",
                                "content": {"application/json": {"schema": {}}},
                            },
                            "500": {
                                "description": "Internal Server Error",
                                "content": {
                                    "application/json": {
                                        "schema": {
                                            "anyOf": [
                                                {"$ref": "#/components/schemas/ModelA"},
                                                {"$ref": "#/components/schemas/ModelB"},
                                            ],
                                            "title": "Response 500 Route1 Route1 Get",
                                        },
                                        "examples": {"Case A": {"value": "a"}},
                                    }
                                },
                            },
                        },
                    }
                },
                "/route2": {
                    "get": {
                        "summary": "Route2",
                        "operationId": "route2_route2_get",
                        "responses": {
                            "200": {
                                "description": "Successful Response",
                                "content": {"application/json": {"schema": {}}},
                            },
                            "500": {
                                "description": "Internal Server Error",
                                "content": {
                                    "application/json": {
                                        "schema": {
                                            "anyOf": [
                                                {"$ref": "#/components/schemas/ModelA"},
                                                {"$ref": "#/components/schemas/ModelB"},
                                            ],
                                            "title": "Response 500 Route2 Route2 Get",
                                        },
                                        "examples": {"Case A": {"value": "a"}},
                                    }
                                },
                            },
                        },
                    }
                },
            },
            "components": {
                "schemas": {
                    "ModelA": {
                        "properties": {"a": {"type": "string", "title": "A"}},
                        "type": "object",
                        "required": ["a"],
                        "title": "ModelA",
                    },
                    "ModelB": {
                        "properties": {"b": {"type": "string", "title": "B"}},
                        "type": "object",
                        "required": ["b"],
                        "title": "ModelB",
                    },
                }
            },
        }
    )

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_additional_responses_union_duplicate_anyof.py.
Where is test_openapi_schema() defined?
test_openapi_schema() is defined in tests/test_additional_responses_union_duplicate_anyof.py at line 46.

Analyze Your Own Codebase

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

Try Supermodel Free