Home / Function/ test_openapi_schema() — fastapi Function Reference

test_openapi_schema() — fastapi Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  f5c42606_4d23_c6a6_4539_723f98c27287["test_openapi_schema()"]
  8a5bb1d8_4ff0_e192_0afd_1c1690b8792d["test_computed_fields.py"]
  f5c42606_4d23_c6a6_4539_723f98c27287 -->|defined in| 8a5bb1d8_4ff0_e192_0afd_1c1690b8792d
  style f5c42606_4d23_c6a6_4539_723f98c27287 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_computed_fields.py lines 44–108

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": {
                "/": {
                    "get": {
                        "summary": "Read Root",
                        "operationId": "read_root__get",
                        "responses": {
                            "200": {
                                "description": "Successful Response",
                                "content": {
                                    "application/json": {
                                        "schema": {
                                            "$ref": "#/components/schemas/Rectangle"
                                        }
                                    }
                                },
                            }
                        },
                    }
                },
                "/responses": {
                    "get": {
                        "summary": "Read Responses",
                        "operationId": "read_responses_responses_get",
                        "responses": {
                            "200": {
                                "description": "Successful Response",
                                "content": {
                                    "application/json": {
                                        "schema": {
                                            "$ref": "#/components/schemas/Rectangle"
                                        }
                                    }
                                },
                            }
                        },
                    }
                },
            },
            "components": {
                "schemas": {
                    "Rectangle": {
                        "properties": {
                            "width": {"type": "integer", "title": "Width"},
                            "length": {"type": "integer", "title": "Length"},
                            "area": {
                                "type": "integer",
                                "title": "Area",
                                "readOnly": True,
                            },
                        },
                        "type": "object",
                        "required": ["width", "length", "area"],
                        "title": "Rectangle",
                    }
                }
            },
        }
    )

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_computed_fields.py.
Where is test_openapi_schema() defined?
test_openapi_schema() is defined in tests/test_computed_fields.py at line 44.

Analyze Your Own Codebase

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

Try Supermodel Free