Home / Function/ test_openapi_schema() — fastapi Function Reference

test_openapi_schema() — fastapi Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  adca045d_0b9d_8630_12ad_924caa42ed21["test_openapi_schema()"]
  db58a16f_b2c1_ef97_61af_61d872b92f63["test_tutorial005.py"]
  adca045d_0b9d_8630_12ad_924caa42ed21 -->|defined in| db58a16f_b2c1_ef97_61af_61d872b92f63
  style adca045d_0b9d_8630_12ad_924caa42ed21 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_tutorial/test_schema_extra_example/test_tutorial005.py lines 39–163

def test_openapi_schema(client: TestClient) -> None:
    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": {
                "/items/{item_id}": {
                    "put": {
                        "summary": "Update Item",
                        "operationId": "update_item_items__item_id__put",
                        "parameters": [
                            {
                                "required": True,
                                "schema": {"title": "Item Id", "type": "integer"},
                                "name": "item_id",
                                "in": "path",
                            }
                        ],
                        "requestBody": {
                            "content": {
                                "application/json": {
                                    "schema": {"$ref": "#/components/schemas/Item"},
                                    "examples": {
                                        "normal": {
                                            "summary": "A normal example",
                                            "description": "A **normal** item works correctly.",
                                            "value": {
                                                "name": "Foo",
                                                "description": "A very nice Item",
                                                "price": 35.4,
                                                "tax": 3.2,
                                            },
                                        },
                                        "converted": {
                                            "summary": "An example with converted data",
                                            "description": "FastAPI can convert price `strings` to actual `numbers` automatically",
                                            "value": {"name": "Bar", "price": "35.4"},
                                        },
                                        "invalid": {
                                            "summary": "Invalid data is rejected with an error",
                                            "value": {
                                                "name": "Baz",
                                                "price": "thirty five point four",
                                            },
                                        },
                                    },
                                }
                            },
                            "required": True,
                        },
                        "responses": {
                            "200": {
                                "description": "Successful Response",
                                "content": {"application/json": {"schema": {}}},
                            },
                            "422": {
                                "description": "Validation Error",
                                "content": {
                                    "application/json": {
                                        "schema": {
                                            "$ref": "#/components/schemas/HTTPValidationError"
                                        }
                                    }
                                },
                            },
                        },
                    }
                }
            },
            "components": {
                "schemas": {
                    "HTTPValidationError": {
                        "title": "HTTPValidationError",
                        "type": "object",
                        "properties": {
                            "detail": {
                                "title": "Detail",
                                "type": "array",
                                "items": {

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_schema_extra_example/test_tutorial005.py.
Where is test_openapi_schema() defined?
test_openapi_schema() is defined in tests/test_tutorial/test_schema_extra_example/test_tutorial005.py at line 39.

Analyze Your Own Codebase

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

Try Supermodel Free