Home / Function/ test_openapi() — fastapi Function Reference

test_openapi() — fastapi Function Reference

Architecture documentation for the test_openapi() function in test_include_router_defaults_overrides.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  b3976acf_17b3_3479_86ae_4a7b393decc2["test_openapi()"]
  d87662b2_2485_5c84_66f0_3b294a501db6["test_include_router_defaults_overrides.py"]
  b3976acf_17b3_3479_86ae_4a7b393decc2 -->|defined in| d87662b2_2485_5c84_66f0_3b294a501db6
  style b3976acf_17b3_3479_86ae_4a7b393decc2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_include_router_defaults_overrides.py lines 439–7304

def test_openapi():
    client = TestClient(app)
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter("always")
        response = client.get("/openapi.json")
        assert issubclass(w[-1].category, UserWarning)
        assert "Duplicate Operation ID" in str(w[-1].message)
    assert response.json() == snapshot(
        {
            "openapi": "3.1.0",
            "info": {"title": "FastAPI", "version": "0.1.0"},
            "paths": {
                "/override1": {
                    "get": {
                        "tags": ["path1a", "path1b"],
                        "summary": "Path1 Override",
                        "operationId": "path1_override_override1_get",
                        "parameters": [
                            {
                                "required": True,
                                "schema": {"title": "Level1", "type": "string"},
                                "name": "level1",
                                "in": "query",
                            }
                        ],
                        "responses": {
                            "200": {
                                "description": "Successful Response",
                                "content": {"application/x-level-1": {"schema": {}}},
                            },
                            "400": {"description": "Client error level 0"},
                            "401": {"description": "Client error level 1"},
                            "422": {
                                "description": "Validation Error",
                                "content": {
                                    "application/json": {
                                        "schema": {
                                            "$ref": "#/components/schemas/HTTPValidationError"
                                        }
                                    }
                                },
                            },
                            "500": {"description": "Server error level 0"},
                            "501": {"description": "Server error level 1"},
                        },
                        "callbacks": {
                            "callback0": {
                                "/": {
                                    "get": {
                                        "summary": "Callback0",
                                        "operationId": "callback0__get",
                                        "parameters": [
                                            {
                                                "name": "level0",
                                                "in": "query",
                                                "required": True,
                                                "schema": {
                                                    "title": "Level0",
                                                    "type": "string",
                                                },
                                            }
                                        ],
                                        "responses": {
                                            "200": {
                                                "description": "Successful Response",
                                                "content": {
                                                    "application/json": {"schema": {}}
                                                },
                                            },
                                            "422": {
                                                "description": "Validation Error",
                                                "content": {
                                                    "application/json": {
                                                        "schema": {
                                                            "$ref": "#/components/schemas/HTTPValidationError"
                                                        }
                                                    }
                                                },
                                            },
                                        },
                                    }

Domain

Subdomains

Frequently Asked Questions

What does test_openapi() do?
test_openapi() is a function in the fastapi codebase, defined in tests/test_include_router_defaults_overrides.py.
Where is test_openapi() defined?
test_openapi() is defined in tests/test_include_router_defaults_overrides.py at line 439.

Analyze Your Own Codebase

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

Try Supermodel Free