Home / Function/ test_openapi_schema() — fastapi Function Reference

test_openapi_schema() — fastapi Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

tests/test_tutorial/test_security/test_tutorial003.py lines 87–217

def test_openapi_schema(client: TestClient):
    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": {}}},
                            },
                            "422": {
                                "description": "Validation Error",
                                "content": {
                                    "application/json": {
                                        "schema": {
                                            "$ref": "#/components/schemas/HTTPValidationError"
                                        }
                                    }
                                },
                            },
                        },
                        "summary": "Login",
                        "operationId": "login_token_post",
                        "requestBody": {
                            "content": {
                                "application/x-www-form-urlencoded": {
                                    "schema": {
                                        "$ref": "#/components/schemas/Body_login_token_post"
                                    }
                                }
                            },
                            "required": True,
                        },
                    }
                },
                "/users/me": {
                    "get": {
                        "responses": {
                            "200": {
                                "description": "Successful Response",
                                "content": {"application/json": {"schema": {}}},
                            }
                        },
                        "summary": "Read Users Me",
                        "operationId": "read_users_me_users_me_get",
                        "security": [{"OAuth2PasswordBearer": []}],
                    }
                },
            },
            "components": {
                "schemas": {
                    "Body_login_token_post": {
                        "title": "Body_login_token_post",
                        "required": ["username", "password"],
                        "type": "object",
                        "properties": {
                            "grant_type": {
                                "title": "Grant Type",
                                "anyOf": [
                                    {"pattern": "^password$", "type": "string"},
                                    {"type": "null"},
                                ],
                            },
                            "username": {"title": "Username", "type": "string"},
                            "password": {
                                "title": "Password",
                                "type": "string",
                                "format": "password",
                            },
                            "scope": {
                                "title": "Scope",
                                "type": "string",
                                "default": "",
                            },
                            "client_id": {
                                "title": "Client Id",

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

Analyze Your Own Codebase

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

Try Supermodel Free