Home / Function/ test_openapi_schema() — fastapi Function Reference

test_openapi_schema() — fastapi Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

tests/test_tutorial/test_security/test_tutorial004.py lines 188–374

def test_openapi_schema(mod: ModuleType):
    client = TestClient(mod.app)
    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": {
                "/token": {
                    "post": {
                        "responses": {
                            "200": {
                                "description": "Successful Response",
                                "content": {
                                    "application/json": {
                                        "schema": {"$ref": "#/components/schemas/Token"}
                                    }
                                },
                            },
                            "422": {
                                "description": "Validation Error",
                                "content": {
                                    "application/json": {
                                        "schema": {
                                            "$ref": "#/components/schemas/HTTPValidationError"
                                        }
                                    }
                                },
                            },
                        },
                        "summary": "Login For Access Token",
                        "operationId": "login_for_access_token_token_post",
                        "requestBody": {
                            "content": {
                                "application/x-www-form-urlencoded": {
                                    "schema": {
                                        "$ref": "#/components/schemas/Body_login_for_access_token_token_post"
                                    }
                                }
                            },
                            "required": True,
                        },
                    }
                },
                "/users/me/": {
                    "get": {
                        "responses": {
                            "200": {
                                "description": "Successful Response",
                                "content": {
                                    "application/json": {
                                        "schema": {"$ref": "#/components/schemas/User"}
                                    }
                                },
                            }
                        },
                        "summary": "Read Users Me",
                        "operationId": "read_users_me_users_me__get",
                        "security": [{"OAuth2PasswordBearer": []}],
                    }
                },
                "/users/me/items/": {
                    "get": {
                        "responses": {
                            "200": {
                                "description": "Successful Response",
                                "content": {"application/json": {"schema": {}}},
                            }
                        },
                        "summary": "Read Own Items",
                        "operationId": "read_own_items_users_me_items__get",
                        "security": [{"OAuth2PasswordBearer": []}],
                    }
                },
            },
            "components": {
                "schemas": {
                    "User": {
                        "title": "User",
                        "required": ["username"],

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_tutorial/test_security/test_tutorial004.py.
Where is test_openapi_schema() defined?
test_openapi_schema() is defined in tests/test_tutorial/test_security/test_tutorial004.py at line 188.

Analyze Your Own Codebase

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

Try Supermodel Free