Home / Function/ test_openapi_schema() — fastapi Function Reference

test_openapi_schema() — fastapi Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  b655af23_cfe0_6311_7aec_5eb898b933f3["test_openapi_schema()"]
  74d8243a_c563_6592_e257_8603bf93cc97["test_infer_param_optionality.py"]
  b655af23_cfe0_6311_7aec_5eb898b933f3 -->|defined in| 74d8243a_c563_6592_e257_8603bf93cc97
  style b655af23_cfe0_6311_7aec_5eb898b933f3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_infer_param_optionality.py lines 108–339

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": {
                "/users/": {
                    "get": {
                        "summary": "Get Users",
                        "operationId": "get_users_users__get",
                        "responses": {
                            "200": {
                                "description": "Successful Response",
                                "content": {"application/json": {"schema": {}}},
                            }
                        },
                    }
                },
                "/users/{user_id}": {
                    "get": {
                        "summary": "Get User",
                        "operationId": "get_user_users__user_id__get",
                        "parameters": [
                            {
                                "required": True,
                                "schema": {"title": "User Id", "type": "string"},
                                "name": "user_id",
                                "in": "path",
                            }
                        ],
                        "responses": {
                            "200": {
                                "description": "Successful Response",
                                "content": {"application/json": {"schema": {}}},
                            },
                            "422": {
                                "description": "Validation Error",
                                "content": {
                                    "application/json": {
                                        "schema": {
                                            "$ref": "#/components/schemas/HTTPValidationError"
                                        }
                                    }
                                },
                            },
                        },
                    }
                },
                "/items/": {
                    "get": {
                        "summary": "Get Items",
                        "operationId": "get_items_items__get",
                        "parameters": [
                            {
                                "required": False,
                                "name": "user_id",
                                "in": "query",
                                "schema": {
                                    "anyOf": [{"type": "string"}, {"type": "null"}],
                                    "title": "User Id",
                                },
                            }
                        ],
                        "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_schema() do?
test_openapi_schema() is a function in the fastapi codebase, defined in tests/test_infer_param_optionality.py.
Where is test_openapi_schema() defined?
test_openapi_schema() is defined in tests/test_infer_param_optionality.py at line 108.

Analyze Your Own Codebase

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

Try Supermodel Free