Home / Function/ test_openapi_schema() — fastapi Function Reference

test_openapi_schema() — fastapi Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  b5c2677d_6490_a9aa_8c40_c4796eee6ee2["test_openapi_schema()"]
  7e784b87_9cdf_528d_4ae2_09349aaf6e83["test_security_oauth2_optional_description.py"]
  b5c2677d_6490_a9aa_8c40_c4796eee6ee2 -->|defined in| 7e784b87_9cdf_528d_4ae2_09349aaf6e83
  style b5c2677d_6490_a9aa_8c40_c4796eee6ee2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_security_oauth2_optional_description.py lines 153–285

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": {
                "/login": {
                    "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_login_post",
                        "requestBody": {
                            "content": {
                                "application/x-www-form-urlencoded": {
                                    "schema": {
                                        "$ref": "#/components/schemas/Body_login_login_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": [{"OAuth2": []}],
                    }
                },
            },
            "components": {
                "schemas": {
                    "Body_login_login_post": {
                        "title": "Body_login_login_post",
                        "required": ["grant_type", "username", "password"],
                        "type": "object",
                        "properties": {
                            "grant_type": {
                                "title": "Grant Type",
                                "pattern": "^password$",
                                "type": "string",
                            },
                            "username": {"title": "Username", "type": "string"},
                            "password": {"title": "Password", "type": "string"},
                            "scope": {
                                "title": "Scope",
                                "type": "string",
                                "default": "",
                            },
                            "client_id": {
                                "title": "Client Id",
                                "anyOf": [{"type": "string"}, {"type": "null"}],
                            },
                            "client_secret": {
                                "title": "Client Secret",
                                "anyOf": [{"type": "string"}, {"type": "null"}],
                            },

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_security_oauth2_optional_description.py.
Where is test_openapi_schema() defined?
test_openapi_schema() is defined in tests/test_security_oauth2_optional_description.py at line 153.

Analyze Your Own Codebase

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

Try Supermodel Free