]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
✅ Refactor OpenAPI tests, prepare for Pydantic v2 (#9503)
authorSebastián Ramírez <tiangolo@gmail.com>
Mon, 8 May 2023 21:07:32 +0000 (23:07 +0200)
committerGitHub <noreply@github.com>
Mon, 8 May 2023 21:07:32 +0000 (23:07 +0200)
* ✅ Refactor OpenAPI tests, move inline, prepare for Pydantic v2 tests

* ✅ Fix test module loading for conditional OpenAPI

* 🐛 Fix missing pytest marker

* ✅ Fix test for coverage

280 files changed:
tests/test_additional_properties.py
tests/test_additional_response_extra.py
tests/test_additional_responses_custom_model_in_callback.py
tests/test_additional_responses_custom_validationerror.py
tests/test_additional_responses_default_validationerror.py
tests/test_additional_responses_response_class.py
tests/test_additional_responses_router.py
tests/test_annotated.py
tests/test_application.py
tests/test_custom_route_class.py
tests/test_dependency_duplicates.py
tests/test_deprecated_openapi_prefix.py
tests/test_duplicate_models_openapi.py
tests/test_extra_routes.py
tests/test_filter_pydantic_sub_model.py
tests/test_get_request_body.py
tests/test_include_router_defaults_overrides.py
tests/test_modules_same_name_body/test_main.py
tests/test_multi_body_errors.py
tests/test_multi_query_errors.py
tests/test_openapi_query_parameter_extension.py
tests/test_openapi_route_extensions.py
tests/test_openapi_servers.py
tests/test_param_in_path_and_dependency.py
tests/test_put_no_body.py
tests/test_repeated_parameter_alias.py
tests/test_reponse_set_reponse_code_empty.py
tests/test_response_by_alias.py
tests/test_response_class_no_mediatype.py
tests/test_response_code_no_body.py
tests/test_response_model_as_return_annotation.py
tests/test_response_model_sub_types.py
tests/test_schema_extra_examples.py
tests/test_security_api_key_cookie.py
tests/test_security_api_key_cookie_description.py
tests/test_security_api_key_cookie_optional.py
tests/test_security_api_key_header.py
tests/test_security_api_key_header_description.py
tests/test_security_api_key_header_optional.py
tests/test_security_api_key_query.py
tests/test_security_api_key_query_description.py
tests/test_security_api_key_query_optional.py
tests/test_security_http_base.py
tests/test_security_http_base_description.py
tests/test_security_http_base_optional.py
tests/test_security_http_basic_optional.py
tests/test_security_http_basic_realm.py
tests/test_security_http_basic_realm_description.py
tests/test_security_http_bearer.py
tests/test_security_http_bearer_description.py
tests/test_security_http_bearer_optional.py
tests/test_security_http_digest.py
tests/test_security_http_digest_description.py
tests/test_security_http_digest_optional.py
tests/test_security_oauth2.py
tests/test_security_oauth2_authorization_code_bearer.py
tests/test_security_oauth2_authorization_code_bearer_description.py
tests/test_security_oauth2_optional.py
tests/test_security_oauth2_optional_description.py
tests/test_security_oauth2_password_bearer_optional.py
tests/test_security_oauth2_password_bearer_optional_description.py
tests/test_security_openid_connect.py
tests/test_security_openid_connect_description.py
tests/test_security_openid_connect_optional.py
tests/test_starlette_exception.py
tests/test_sub_callbacks.py
tests/test_tuples.py
tests/test_tutorial/test_additional_responses/test_tutorial001.py
tests/test_tutorial/test_additional_responses/test_tutorial002.py
tests/test_tutorial/test_additional_responses/test_tutorial003.py
tests/test_tutorial/test_additional_responses/test_tutorial004.py
tests/test_tutorial/test_async_sql_databases/test_tutorial001.py
tests/test_tutorial/test_behind_a_proxy/test_tutorial001.py
tests/test_tutorial/test_behind_a_proxy/test_tutorial002.py
tests/test_tutorial/test_behind_a_proxy/test_tutorial003.py
tests/test_tutorial/test_behind_a_proxy/test_tutorial004.py
tests/test_tutorial/test_bigger_applications/test_main.py
tests/test_tutorial/test_bigger_applications/test_main_an.py
tests/test_tutorial/test_bigger_applications/test_main_an_py39.py
tests/test_tutorial/test_body/test_tutorial001.py
tests/test_tutorial/test_body/test_tutorial001_py310.py
tests/test_tutorial/test_body_fields/test_tutorial001.py
tests/test_tutorial/test_body_fields/test_tutorial001_an.py
tests/test_tutorial/test_body_fields/test_tutorial001_an_py310.py
tests/test_tutorial/test_body_fields/test_tutorial001_an_py39.py
tests/test_tutorial/test_body_fields/test_tutorial001_py310.py
tests/test_tutorial/test_body_multiple_params/test_tutorial001.py
tests/test_tutorial/test_body_multiple_params/test_tutorial001_an.py
tests/test_tutorial/test_body_multiple_params/test_tutorial001_an_py310.py
tests/test_tutorial/test_body_multiple_params/test_tutorial001_an_py39.py
tests/test_tutorial/test_body_multiple_params/test_tutorial001_py310.py
tests/test_tutorial/test_body_multiple_params/test_tutorial003.py
tests/test_tutorial/test_body_multiple_params/test_tutorial003_an.py
tests/test_tutorial/test_body_multiple_params/test_tutorial003_an_py310.py
tests/test_tutorial/test_body_multiple_params/test_tutorial003_an_py39.py
tests/test_tutorial/test_body_multiple_params/test_tutorial003_py310.py
tests/test_tutorial/test_body_nested_models/test_tutorial009.py
tests/test_tutorial/test_body_nested_models/test_tutorial009_py39.py
tests/test_tutorial/test_body_updates/test_tutorial001.py
tests/test_tutorial/test_body_updates/test_tutorial001_py310.py
tests/test_tutorial/test_body_updates/test_tutorial001_py39.py
tests/test_tutorial/test_conditional_openapi/test_tutorial001.py
tests/test_tutorial/test_cookie_params/test_tutorial001.py
tests/test_tutorial/test_cookie_params/test_tutorial001_an.py
tests/test_tutorial/test_cookie_params/test_tutorial001_an_py310.py
tests/test_tutorial/test_cookie_params/test_tutorial001_an_py39.py
tests/test_tutorial/test_cookie_params/test_tutorial001_py310.py
tests/test_tutorial/test_custom_response/test_tutorial001.py
tests/test_tutorial/test_custom_response/test_tutorial001b.py
tests/test_tutorial/test_custom_response/test_tutorial004.py
tests/test_tutorial/test_custom_response/test_tutorial005.py
tests/test_tutorial/test_custom_response/test_tutorial006.py
tests/test_tutorial/test_custom_response/test_tutorial006b.py
tests/test_tutorial/test_custom_response/test_tutorial006c.py
tests/test_tutorial/test_dataclasses/test_tutorial001.py
tests/test_tutorial/test_dataclasses/test_tutorial003.py
tests/test_tutorial/test_dependencies/test_tutorial001.py
tests/test_tutorial/test_dependencies/test_tutorial001_an.py
tests/test_tutorial/test_dependencies/test_tutorial001_an_py310.py
tests/test_tutorial/test_dependencies/test_tutorial001_an_py39.py
tests/test_tutorial/test_dependencies/test_tutorial001_py310.py
tests/test_tutorial/test_dependencies/test_tutorial004.py
tests/test_tutorial/test_dependencies/test_tutorial004_an.py
tests/test_tutorial/test_dependencies/test_tutorial004_an_py310.py
tests/test_tutorial/test_dependencies/test_tutorial004_an_py39.py
tests/test_tutorial/test_dependencies/test_tutorial004_py310.py
tests/test_tutorial/test_dependencies/test_tutorial006.py
tests/test_tutorial/test_dependencies/test_tutorial006_an.py
tests/test_tutorial/test_dependencies/test_tutorial006_an_py39.py
tests/test_tutorial/test_dependencies/test_tutorial012.py
tests/test_tutorial/test_dependencies/test_tutorial012_an.py
tests/test_tutorial/test_dependencies/test_tutorial012_an_py39.py
tests/test_tutorial/test_events/test_tutorial001.py
tests/test_tutorial/test_events/test_tutorial002.py
tests/test_tutorial/test_events/test_tutorial003.py
tests/test_tutorial/test_extending_openapi/test_tutorial001.py
tests/test_tutorial/test_extra_data_types/test_tutorial001.py
tests/test_tutorial/test_extra_data_types/test_tutorial001_an.py
tests/test_tutorial/test_extra_data_types/test_tutorial001_an_py310.py
tests/test_tutorial/test_extra_data_types/test_tutorial001_an_py39.py
tests/test_tutorial/test_extra_data_types/test_tutorial001_py310.py
tests/test_tutorial/test_extra_models/test_tutorial003.py
tests/test_tutorial/test_extra_models/test_tutorial003_py310.py
tests/test_tutorial/test_extra_models/test_tutorial004.py
tests/test_tutorial/test_extra_models/test_tutorial004_py39.py
tests/test_tutorial/test_extra_models/test_tutorial005.py
tests/test_tutorial/test_extra_models/test_tutorial005_py39.py
tests/test_tutorial/test_first_steps/test_tutorial001.py
tests/test_tutorial/test_generate_clients/test_tutorial003.py
tests/test_tutorial/test_handling_errors/test_tutorial001.py
tests/test_tutorial/test_handling_errors/test_tutorial002.py
tests/test_tutorial/test_handling_errors/test_tutorial003.py
tests/test_tutorial/test_handling_errors/test_tutorial004.py
tests/test_tutorial/test_handling_errors/test_tutorial005.py
tests/test_tutorial/test_handling_errors/test_tutorial006.py
tests/test_tutorial/test_header_params/test_tutorial001.py
tests/test_tutorial/test_header_params/test_tutorial001_an.py
tests/test_tutorial/test_header_params/test_tutorial001_an_py310.py
tests/test_tutorial/test_header_params/test_tutorial001_py310.py
tests/test_tutorial/test_header_params/test_tutorial002.py
tests/test_tutorial/test_header_params/test_tutorial002_an.py
tests/test_tutorial/test_header_params/test_tutorial002_an_py310.py
tests/test_tutorial/test_header_params/test_tutorial002_an_py39.py
tests/test_tutorial/test_header_params/test_tutorial002_py310.py
tests/test_tutorial/test_metadata/test_tutorial001.py
tests/test_tutorial/test_metadata/test_tutorial004.py
tests/test_tutorial/test_openapi_callbacks/test_tutorial001.py
tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial001.py
tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial002.py
tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial003.py
tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial004.py
tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial005.py
tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial006.py
tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial007.py
tests/test_tutorial/test_path_operation_configurations/test_tutorial002b.py
tests/test_tutorial/test_path_operation_configurations/test_tutorial005.py
tests/test_tutorial/test_path_operation_configurations/test_tutorial005_py310.py
tests/test_tutorial/test_path_operation_configurations/test_tutorial005_py39.py
tests/test_tutorial/test_path_operation_configurations/test_tutorial006.py
tests/test_tutorial/test_path_params/test_tutorial004.py
tests/test_tutorial/test_path_params/test_tutorial005.py
tests/test_tutorial/test_query_params/test_tutorial005.py
tests/test_tutorial/test_query_params/test_tutorial006.py
tests/test_tutorial/test_query_params/test_tutorial006_py310.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial010.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial010_an.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial010_an_py310.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial010_an_py39.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial010_py310.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial011.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial011_an.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial011_an_py310.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial011_an_py39.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial011_py310.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial011_py39.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial012.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial012_an.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial012_an_py39.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial012_py39.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial013.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial013_an.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial013_an_py39.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial014.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial014_an.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial014_an_py310.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial014_an_py39.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial014_py310.py
tests/test_tutorial/test_request_files/test_tutorial001.py
tests/test_tutorial/test_request_files/test_tutorial001_02.py
tests/test_tutorial/test_request_files/test_tutorial001_02_an.py
tests/test_tutorial/test_request_files/test_tutorial001_02_an_py310.py
tests/test_tutorial/test_request_files/test_tutorial001_02_an_py39.py
tests/test_tutorial/test_request_files/test_tutorial001_02_py310.py
tests/test_tutorial/test_request_files/test_tutorial001_03.py
tests/test_tutorial/test_request_files/test_tutorial001_03_an.py
tests/test_tutorial/test_request_files/test_tutorial001_03_an_py39.py
tests/test_tutorial/test_request_files/test_tutorial001_an.py
tests/test_tutorial/test_request_files/test_tutorial001_an_py39.py
tests/test_tutorial/test_request_files/test_tutorial002.py
tests/test_tutorial/test_request_files/test_tutorial002_an.py
tests/test_tutorial/test_request_files/test_tutorial002_an_py39.py
tests/test_tutorial/test_request_files/test_tutorial002_py39.py
tests/test_tutorial/test_request_files/test_tutorial003.py
tests/test_tutorial/test_request_files/test_tutorial003_an.py
tests/test_tutorial/test_request_files/test_tutorial003_an_py39.py
tests/test_tutorial/test_request_files/test_tutorial003_py39.py
tests/test_tutorial/test_request_forms/test_tutorial001.py
tests/test_tutorial/test_request_forms/test_tutorial001_an.py
tests/test_tutorial/test_request_forms/test_tutorial001_an_py39.py
tests/test_tutorial/test_request_forms_and_files/test_tutorial001.py
tests/test_tutorial/test_request_forms_and_files/test_tutorial001_an.py
tests/test_tutorial/test_request_forms_and_files/test_tutorial001_an_py39.py
tests/test_tutorial/test_response_model/test_tutorial003.py
tests/test_tutorial/test_response_model/test_tutorial003_01.py
tests/test_tutorial/test_response_model/test_tutorial003_01_py310.py
tests/test_tutorial/test_response_model/test_tutorial003_02.py
tests/test_tutorial/test_response_model/test_tutorial003_03.py
tests/test_tutorial/test_response_model/test_tutorial003_05.py
tests/test_tutorial/test_response_model/test_tutorial003_05_py310.py
tests/test_tutorial/test_response_model/test_tutorial003_py310.py
tests/test_tutorial/test_response_model/test_tutorial004.py
tests/test_tutorial/test_response_model/test_tutorial004_py310.py
tests/test_tutorial/test_response_model/test_tutorial004_py39.py
tests/test_tutorial/test_response_model/test_tutorial005.py
tests/test_tutorial/test_response_model/test_tutorial005_py310.py
tests/test_tutorial/test_response_model/test_tutorial006.py
tests/test_tutorial/test_response_model/test_tutorial006_py310.py
tests/test_tutorial/test_schema_extra_example/test_tutorial004.py
tests/test_tutorial/test_schema_extra_example/test_tutorial004_an.py
tests/test_tutorial/test_schema_extra_example/test_tutorial004_an_py310.py
tests/test_tutorial/test_schema_extra_example/test_tutorial004_an_py39.py
tests/test_tutorial/test_schema_extra_example/test_tutorial004_py310.py
tests/test_tutorial/test_security/test_tutorial001.py
tests/test_tutorial/test_security/test_tutorial001_an.py
tests/test_tutorial/test_security/test_tutorial001_an_py39.py
tests/test_tutorial/test_security/test_tutorial003.py
tests/test_tutorial/test_security/test_tutorial003_an.py
tests/test_tutorial/test_security/test_tutorial003_an_py310.py
tests/test_tutorial/test_security/test_tutorial003_an_py39.py
tests/test_tutorial/test_security/test_tutorial003_py310.py
tests/test_tutorial/test_security/test_tutorial005.py
tests/test_tutorial/test_security/test_tutorial005_an.py
tests/test_tutorial/test_security/test_tutorial005_an_py310.py
tests/test_tutorial/test_security/test_tutorial005_an_py39.py
tests/test_tutorial/test_security/test_tutorial005_py310.py
tests/test_tutorial/test_security/test_tutorial005_py39.py
tests/test_tutorial/test_security/test_tutorial006.py
tests/test_tutorial/test_security/test_tutorial006_an.py
tests/test_tutorial/test_security/test_tutorial006_an_py39.py
tests/test_tutorial/test_sql_databases/test_sql_databases.py
tests/test_tutorial/test_sql_databases/test_sql_databases_middleware.py
tests/test_tutorial/test_sql_databases/test_sql_databases_middleware_py310.py
tests/test_tutorial/test_sql_databases/test_sql_databases_middleware_py39.py
tests/test_tutorial/test_sql_databases/test_sql_databases_py310.py
tests/test_tutorial/test_sql_databases/test_sql_databases_py39.py
tests/test_tutorial/test_sql_databases_peewee/test_sql_databases_peewee.py
tests/test_tutorial/test_testing/test_main.py
tests/test_tutorial/test_testing/test_tutorial001.py
tests/test_union_body.py
tests/test_union_inherited_body.py

index 016c1f734ed1111943dbc22549f4cf8012b0c627..516a569e4250dc81e15138b1fa7efc51d838b45d 100644 (file)
@@ -19,92 +19,91 @@ def foo(items: Items):
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/foo": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
+def test_additional_properties_post():
+    response = client.post("/foo", json={"items": {"foo": 1, "bar": 2}})
+    assert response.status_code == 200, response.text
+    assert response.json() == {"foo": 1, "bar": 2}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/foo": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
                     },
-                    "422": {
-                        "description": "Validation Error",
+                    "summary": "Foo",
+                    "operationId": "foo_foo_post",
+                    "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
+                                "schema": {"$ref": "#/components/schemas/Items"}
                             }
                         },
+                        "required": True,
                     },
-                },
-                "summary": "Foo",
-                "operationId": "foo_foo_post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Items"}
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Items": {
+                    "title": "Items",
+                    "required": ["items"],
+                    "type": "object",
+                    "properties": {
+                        "items": {
+                            "title": "Items",
+                            "type": "object",
+                            "additionalProperties": {"type": "integer"},
                         }
                     },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Items": {
-                "title": "Items",
-                "required": ["items"],
-                "type": "object",
-                "properties": {
-                    "items": {
-                        "title": "Items",
-                        "type": "object",
-                        "additionalProperties": {"type": "integer"},
-                    }
                 },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
                     },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
                 },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
                 },
-            },
-        }
-    },
-}
-
-
-def test_additional_properties_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
-def test_additional_properties_post():
-    response = client.post("/foo", json={"items": {"foo": 1, "bar": 2}})
-    assert response.status_code == 200, response.text
-    assert response.json() == {"foo": 1, "bar": 2}
+            }
+        },
+    }
index 1df1891e059c2237aad3d5b568fd0c6722ca336a..d62638c8fa3cd7bb49cb93da5673ff751d3261f8 100644 (file)
@@ -17,36 +17,33 @@ router.include_router(sub_router, prefix="/items")
 
 app.include_router(router)
 
-
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Item",
-                "operationId": "read_item_items__get",
-            }
-        }
-    },
-}
-
 client = TestClient(app)
 
 
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_path_operation():
     response = client.get("/items/")
     assert response.status_code == 200, response.text
     assert response.json() == {"id": "foo"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__get",
+                }
+            }
+        },
+    }
index a1072cc5697edeeac5406e3b4624a298767587fc..5c08eaa6d2662afb43ed7c833f7a0e59f1f84988 100644 (file)
@@ -25,114 +25,116 @@ def main_route(callback_url: HttpUrl):
     pass  # pragma: no cover
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/": {
-            "post": {
-                "summary": "Main Route",
-                "operationId": "main_route__post",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Callback Url",
-                            "maxLength": 2083,
-                            "minLength": 1,
-                            "type": "string",
-                            "format": "uri",
+client = TestClient(app)
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/": {
+                "post": {
+                    "summary": "Main Route",
+                    "operationId": "main_route__post",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Callback Url",
+                                "maxLength": 2083,
+                                "minLength": 1,
+                                "type": "string",
+                                "format": "uri",
+                            },
+                            "name": "callback_url",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
                         },
-                        "name": "callback_url",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "callbacks": {
-                    "callback_route": {
-                        "{$callback_url}/callback/": {
-                            "get": {
-                                "summary": "Callback Route",
-                                "operationId": "callback_route__callback_url__callback__get",
-                                "responses": {
-                                    "400": {
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/CustomModel"
+                    "callbacks": {
+                        "callback_route": {
+                            "{$callback_url}/callback/": {
+                                "get": {
+                                    "summary": "Callback Route",
+                                    "operationId": "callback_route__callback_url__callback__get",
+                                    "responses": {
+                                        "400": {
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/CustomModel"
+                                                    }
                                                 }
-                                            }
+                                            },
+                                            "description": "Bad Request",
+                                        },
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
                                         },
-                                        "description": "Bad Request",
-                                    },
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
                                     },
-                                },
+                                }
                             }
                         }
-                    }
-                },
+                    },
+                }
             }
-        }
-    },
-    "components": {
-        "schemas": {
-            "CustomModel": {
-                "title": "CustomModel",
-                "required": ["a"],
-                "type": "object",
-                "properties": {"a": {"title": "A", "type": "integer"}},
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
+        },
+        "components": {
+            "schemas": {
+                "CustomModel": {
+                    "title": "CustomModel",
+                    "required": ["a"],
+                    "type": "object",
+                    "properties": {"a": {"title": "A", "type": "integer"}},
                 },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
                     },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
                 },
-            },
-        }
-    },
-}
-
-client = TestClient(app)
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 811fe69221272937e7c0e8cce56ec653385fe797..05260276856ccb8217eb450da3a25cb2f0a6440a 100644 (file)
@@ -30,71 +30,70 @@ async def a(id):
     pass  # pragma: no cover
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/a/{id}": {
-            "get": {
-                "responses": {
-                    "422": {
-                        "description": "Error",
-                        "content": {
-                            "application/vnd.api+json": {
-                                "schema": {"$ref": "#/components/schemas/JsonApiError"}
-                            }
-                        },
-                    },
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/vnd.api+json": {"schema": {}}},
-                    },
-                },
-                "summary": "A",
-                "operationId": "a_a__id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Id"},
-                        "name": "id",
-                        "in": "path",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Error": {
-                "title": "Error",
-                "required": ["status", "title"],
-                "type": "object",
-                "properties": {
-                    "status": {"title": "Status", "type": "string"},
-                    "title": {"title": "Title", "type": "string"},
-                },
-            },
-            "JsonApiError": {
-                "title": "JsonApiError",
-                "required": ["errors"],
-                "type": "object",
-                "properties": {
-                    "errors": {
-                        "title": "Errors",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/Error"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
 client = TestClient(app)
 
 
 def test_openapi_schema():
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/a/{id}": {
+                "get": {
+                    "responses": {
+                        "422": {
+                            "description": "Error",
+                            "content": {
+                                "application/vnd.api+json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/JsonApiError"
+                                    }
+                                }
+                            },
+                        },
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/vnd.api+json": {"schema": {}}},
+                        },
+                    },
+                    "summary": "A",
+                    "operationId": "a_a__id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Id"},
+                            "name": "id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Error": {
+                    "title": "Error",
+                    "required": ["status", "title"],
+                    "type": "object",
+                    "properties": {
+                        "status": {"title": "Status", "type": "string"},
+                        "title": {"title": "Title", "type": "string"},
+                    },
+                },
+                "JsonApiError": {
+                    "title": "JsonApiError",
+                    "required": ["errors"],
+                    "type": "object",
+                    "properties": {
+                        "errors": {
+                            "title": "Errors",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/Error"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index cabb536d714bc7aa9a36a564f1406a6771402bfd..58de46ff60157727f7564bfbb27b8f6c5a4342ce 100644 (file)
@@ -9,77 +9,76 @@ async def a(id):
     pass  # pragma: no cover
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/a/{id}": {
-            "get": {
-                "responses": {
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+client = TestClient(app)
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/a/{id}": {
+                "get": {
+                    "responses": {
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
+                        },
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
                         },
                     },
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                },
-                "summary": "A",
-                "operationId": "a_a__id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Id"},
-                        "name": "id",
-                        "in": "path",
-                    }
-                ],
+                    "summary": "A",
+                    "operationId": "a_a__id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Id"},
+                            "name": "id",
+                            "in": "path",
+                        }
+                    ],
+                }
             }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
                     },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
                 },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
                 },
-            },
-        }
-    },
-}
-
-
-client = TestClient(app)
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
+            }
+        },
+    }
index aa549b1636eadfe90ef6aabf4571451593d4d99a..6746760f0e295a4468b92acfa1b249fd49e48dbb 100644 (file)
@@ -35,83 +35,82 @@ async def b():
     pass  # pragma: no cover
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/a": {
-            "get": {
-                "responses": {
-                    "500": {
-                        "description": "Error",
-                        "content": {
-                            "application/vnd.api+json": {
-                                "schema": {"$ref": "#/components/schemas/JsonApiError"}
-                            }
+client = TestClient(app)
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/a": {
+                "get": {
+                    "responses": {
+                        "500": {
+                            "description": "Error",
+                            "content": {
+                                "application/vnd.api+json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/JsonApiError"
+                                    }
+                                }
+                            },
+                        },
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/vnd.api+json": {"schema": {}}},
                         },
                     },
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/vnd.api+json": {"schema": {}}},
+                    "summary": "A",
+                    "operationId": "a_a_get",
+                }
+            },
+            "/b": {
+                "get": {
+                    "responses": {
+                        "500": {
+                            "description": "Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Error"}
+                                }
+                            },
+                        },
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
                     },
-                },
-                "summary": "A",
-                "operationId": "a_a_get",
-            }
+                    "summary": "B",
+                    "operationId": "b_b_get",
+                }
+            },
         },
-        "/b": {
-            "get": {
-                "responses": {
-                    "500": {
-                        "description": "Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Error"}
-                            }
-                        },
+        "components": {
+            "schemas": {
+                "Error": {
+                    "title": "Error",
+                    "required": ["status", "title"],
+                    "type": "object",
+                    "properties": {
+                        "status": {"title": "Status", "type": "string"},
+                        "title": {"title": "Title", "type": "string"},
                     },
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
+                },
+                "JsonApiError": {
+                    "title": "JsonApiError",
+                    "required": ["errors"],
+                    "type": "object",
+                    "properties": {
+                        "errors": {
+                            "title": "Errors",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/Error"},
+                        }
                     },
                 },
-                "summary": "B",
-                "operationId": "b_b_get",
             }
         },
-    },
-    "components": {
-        "schemas": {
-            "Error": {
-                "title": "Error",
-                "required": ["status", "title"],
-                "type": "object",
-                "properties": {
-                    "status": {"title": "Status", "type": "string"},
-                    "title": {"title": "Title", "type": "string"},
-                },
-            },
-            "JsonApiError": {
-                "title": "JsonApiError",
-                "required": ["errors"],
-                "type": "object",
-                "properties": {
-                    "errors": {
-                        "title": "Errors",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/Error"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-client = TestClient(app)
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
+    }
index fe4956f8fc96eb87fb09c94c4ccdc57b53b1fd4d..58d54b733e763661478168fd819a52907d01a82e 100644 (file)
@@ -53,103 +53,10 @@ async def d():
 
 app.include_router(router)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/a": {
-            "get": {
-                "responses": {
-                    "501": {"description": "Error 1"},
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                },
-                "summary": "A",
-                "operationId": "a_a_get",
-            }
-        },
-        "/b": {
-            "get": {
-                "responses": {
-                    "502": {"description": "Error 2"},
-                    "4XX": {"description": "Error with range, upper"},
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                },
-                "summary": "B",
-                "operationId": "b_b_get",
-            }
-        },
-        "/c": {
-            "get": {
-                "responses": {
-                    "400": {"description": "Error with str"},
-                    "5XX": {"description": "Error with range, lower"},
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "default": {"description": "A default response"},
-                },
-                "summary": "C",
-                "operationId": "c_c_get",
-            }
-        },
-        "/d": {
-            "get": {
-                "responses": {
-                    "400": {"description": "Error with str"},
-                    "5XX": {
-                        "description": "Server Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/ResponseModel"}
-                            }
-                        },
-                    },
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "default": {
-                        "description": "Default Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/ResponseModel"}
-                            }
-                        },
-                    },
-                },
-                "summary": "D",
-                "operationId": "d_d_get",
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "ResponseModel": {
-                "title": "ResponseModel",
-                "required": ["message"],
-                "type": "object",
-                "properties": {"message": {"title": "Message", "type": "string"}},
-            }
-        }
-    },
-}
 
 client = TestClient(app)
 
 
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_a():
     response = client.get("/a")
     assert response.status_code == 200, response.text
@@ -172,3 +79,99 @@ def test_d():
     response = client.get("/d")
     assert response.status_code == 200, response.text
     assert response.json() == "d"
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/a": {
+                "get": {
+                    "responses": {
+                        "501": {"description": "Error 1"},
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                    },
+                    "summary": "A",
+                    "operationId": "a_a_get",
+                }
+            },
+            "/b": {
+                "get": {
+                    "responses": {
+                        "502": {"description": "Error 2"},
+                        "4XX": {"description": "Error with range, upper"},
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                    },
+                    "summary": "B",
+                    "operationId": "b_b_get",
+                }
+            },
+            "/c": {
+                "get": {
+                    "responses": {
+                        "400": {"description": "Error with str"},
+                        "5XX": {"description": "Error with range, lower"},
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "default": {"description": "A default response"},
+                    },
+                    "summary": "C",
+                    "operationId": "c_c_get",
+                }
+            },
+            "/d": {
+                "get": {
+                    "responses": {
+                        "400": {"description": "Error with str"},
+                        "5XX": {
+                            "description": "Server Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/ResponseModel"
+                                    }
+                                }
+                            },
+                        },
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "default": {
+                            "description": "Default Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/ResponseModel"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "D",
+                    "operationId": "d_d_get",
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "ResponseModel": {
+                    "title": "ResponseModel",
+                    "required": ["message"],
+                    "type": "object",
+                    "properties": {"message": {"title": "Message", "type": "string"}},
+                }
+            }
+        },
+    }
index 30c8efe0140657185d2eefb45b97602de3bfcae2..a4f42b038f476fb8a350363271abbb8ec6d18456 100644 (file)
@@ -28,161 +28,6 @@ async def unrelated(foo: Annotated[str, object()]):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/default": {
-            "get": {
-                "summary": "Default",
-                "operationId": "default_default_get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Foo", "type": "string", "default": "foo"},
-                        "name": "foo",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/required": {
-            "get": {
-                "summary": "Required",
-                "operationId": "required_required_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Foo", "minLength": 1, "type": "string"},
-                        "name": "foo",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/multiple": {
-            "get": {
-                "summary": "Multiple",
-                "operationId": "multiple_multiple_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Foo", "minLength": 1, "type": "string"},
-                        "name": "foo",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/unrelated": {
-            "get": {
-                "summary": "Unrelated",
-                "operationId": "unrelated_unrelated_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Foo", "type": "string"},
-                        "name": "foo",
-                        "in": "query",
-                    }
-                ],
-                "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
 foo_is_missing = {
     "detail": [
         {
@@ -217,7 +62,6 @@ foo_is_short = {
         ("/multiple?foo=", 422, foo_is_short),
         ("/unrelated?foo=bar", 200, {"foo": "bar"}),
         ("/unrelated", 422, foo_is_missing),
-        ("/openapi.json", 200, openapi_schema),
     ],
 )
 def test_get(path, expected_status, expected_response):
@@ -227,11 +71,14 @@ def test_get(path, expected_status, expected_response):
 
 
 def test_multiple_path():
+    app = FastAPI()
+
     @app.get("/test1")
     @app.get("/test2")
     async def test(var: Annotated[str, Query()] = "bar"):
         return {"foo": var}
 
+    client = TestClient(app)
     response = client.get("/test1")
     assert response.status_code == 200
     assert response.json() == {"foo": "bar"}
@@ -265,3 +112,177 @@ def test_nested_router():
     response = client.get("/nested/test")
     assert response.status_code == 200
     assert response.json() == {"foo": "bar"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/default": {
+                "get": {
+                    "summary": "Default",
+                    "operationId": "default_default_get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Foo",
+                                "type": "string",
+                                "default": "foo",
+                            },
+                            "name": "foo",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/required": {
+                "get": {
+                    "summary": "Required",
+                    "operationId": "required_required_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Foo",
+                                "minLength": 1,
+                                "type": "string",
+                            },
+                            "name": "foo",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/multiple": {
+                "get": {
+                    "summary": "Multiple",
+                    "operationId": "multiple_multiple_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Foo",
+                                "minLength": 1,
+                                "type": "string",
+                            },
+                            "name": "foo",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/unrelated": {
+                "get": {
+                    "summary": "Unrelated",
+                    "operationId": "unrelated_unrelated_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Foo", "type": "string"},
+                            "name": "foo",
+                            "in": "query",
+                        }
+                    ],
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index a4f13e12dabce91c2b14467a4091a0259ae06dd3..e5f2f43878b6fd3dda1fa7bbebaed0c945b34410 100644 (file)
@@ -5,1170 +5,1179 @@ from .main import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/api_route": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Non Operation",
-                "operationId": "non_operation_api_route_get",
-            }
-        },
-        "/non_decorated_route": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Non Decorated Route",
-                "operationId": "non_decorated_route_non_decorated_route_get",
-            }
-        },
-        "/text": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Get Text",
-                "operationId": "get_text_text_get",
-            }
-        },
-        "/path/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+
+@pytest.mark.parametrize(
+    "path,expected_status,expected_response",
+    [
+        ("/api_route", 200, {"message": "Hello World"}),
+        ("/non_decorated_route", 200, {"message": "Hello World"}),
+        ("/nonexistent", 404, {"detail": "Not Found"}),
+    ],
+)
+def test_get_path(path, expected_status, expected_response):
+    response = client.get(path)
+    assert response.status_code == expected_status
+    assert response.json() == expected_response
+
+
+def test_swagger_ui():
+    response = client.get("/docs")
+    assert response.status_code == 200, response.text
+    assert response.headers["content-type"] == "text/html; charset=utf-8"
+    assert "swagger-ui-dist" in response.text
+    assert (
+        "oauth2RedirectUrl: window.location.origin + '/docs/oauth2-redirect'"
+        in response.text
+    )
+
+
+def test_swagger_ui_oauth2_redirect():
+    response = client.get("/docs/oauth2-redirect")
+    assert response.status_code == 200, response.text
+    assert response.headers["content-type"] == "text/html; charset=utf-8"
+    assert "window.opener.swaggerUIRedirectOauth2" in response.text
+
+
+def test_redoc():
+    response = client.get("/redoc")
+    assert response.status_code == 200, response.text
+    assert response.headers["content-type"] == "text/html; charset=utf-8"
+    assert "redoc@next" in response.text
+
+
+def test_enum_status_code_response():
+    response = client.get("/enum-status-code")
+    assert response.status_code == 201, response.text
+    assert response.json() == "foo bar"
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/api_route": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Non Operation",
+                    "operationId": "non_operation_api_route_get",
+                }
+            },
+            "/non_decorated_route": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Non Decorated Route",
+                    "operationId": "non_decorated_route_non_decorated_route_get",
+                }
+            },
+            "/text": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Get Text",
+                    "operationId": "get_text_text_get",
+                }
+            },
+            "/path/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Id",
-                "operationId": "get_id_path__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/str/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Id",
+                    "operationId": "get_id_path__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/str/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Str Id",
-                "operationId": "get_str_id_path_str__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/int/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Str Id",
+                    "operationId": "get_str_id_path_str__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/int/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Int Id",
-                "operationId": "get_int_id_path_int__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "integer"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/float/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Int Id",
+                    "operationId": "get_int_id_path_int__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "integer"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/float/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Float Id",
-                "operationId": "get_float_id_path_float__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "number"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/bool/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Float Id",
+                    "operationId": "get_float_id_path_float__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "number"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/bool/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Bool Id",
-                "operationId": "get_bool_id_path_bool__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "boolean"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Bool Id",
+                    "operationId": "get_bool_id_path_bool__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "boolean"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Id",
-                "operationId": "get_path_param_id_path_param__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param-minlength/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Id",
+                    "operationId": "get_path_param_id_path_param__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param-minlength/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Min Length",
-                "operationId": "get_path_param_min_length_path_param_minlength__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "minLength": 3,
-                            "type": "string",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param-maxlength/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Min Length",
+                    "operationId": "get_path_param_min_length_path_param_minlength__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "minLength": 3,
+                                "type": "string",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param-maxlength/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Max Length",
-                "operationId": "get_path_param_max_length_path_param_maxlength__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "maxLength": 3,
-                            "type": "string",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param-min_maxlength/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Max Length",
+                    "operationId": "get_path_param_max_length_path_param_maxlength__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "maxLength": 3,
+                                "type": "string",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param-min_maxlength/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Min Max Length",
-                "operationId": "get_path_param_min_max_length_path_param_min_maxlength__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "maxLength": 3,
-                            "minLength": 2,
-                            "type": "string",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param-gt/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Min Max Length",
+                    "operationId": "get_path_param_min_max_length_path_param_min_maxlength__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "maxLength": 3,
+                                "minLength": 2,
+                                "type": "string",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param-gt/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Gt",
-                "operationId": "get_path_param_gt_path_param_gt__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "exclusiveMinimum": 3.0,
-                            "type": "number",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param-gt0/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Gt",
+                    "operationId": "get_path_param_gt_path_param_gt__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "exclusiveMinimum": 3.0,
+                                "type": "number",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param-gt0/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Gt0",
-                "operationId": "get_path_param_gt0_path_param_gt0__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "exclusiveMinimum": 0.0,
-                            "type": "number",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param-ge/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Gt0",
+                    "operationId": "get_path_param_gt0_path_param_gt0__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "exclusiveMinimum": 0.0,
+                                "type": "number",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param-ge/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Ge",
-                "operationId": "get_path_param_ge_path_param_ge__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "minimum": 3.0,
-                            "type": "number",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param-lt/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Ge",
+                    "operationId": "get_path_param_ge_path_param_ge__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "minimum": 3.0,
+                                "type": "number",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param-lt/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Lt",
-                "operationId": "get_path_param_lt_path_param_lt__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "exclusiveMaximum": 3.0,
-                            "type": "number",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param-lt0/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Lt",
+                    "operationId": "get_path_param_lt_path_param_lt__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "exclusiveMaximum": 3.0,
+                                "type": "number",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param-lt0/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Lt0",
-                "operationId": "get_path_param_lt0_path_param_lt0__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "exclusiveMaximum": 0.0,
-                            "type": "number",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param-le/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Lt0",
+                    "operationId": "get_path_param_lt0_path_param_lt0__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "exclusiveMaximum": 0.0,
+                                "type": "number",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param-le/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Le",
-                "operationId": "get_path_param_le_path_param_le__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "maximum": 3.0,
-                            "type": "number",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param-lt-gt/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Le",
+                    "operationId": "get_path_param_le_path_param_le__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "maximum": 3.0,
+                                "type": "number",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param-lt-gt/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Lt Gt",
-                "operationId": "get_path_param_lt_gt_path_param_lt_gt__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "exclusiveMaximum": 3.0,
-                            "exclusiveMinimum": 1.0,
-                            "type": "number",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param-le-ge/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Lt Gt",
+                    "operationId": "get_path_param_lt_gt_path_param_lt_gt__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "exclusiveMaximum": 3.0,
+                                "exclusiveMinimum": 1.0,
+                                "type": "number",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param-le-ge/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Le Ge",
-                "operationId": "get_path_param_le_ge_path_param_le_ge__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "maximum": 3.0,
-                            "minimum": 1.0,
-                            "type": "number",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param-lt-int/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Le Ge",
+                    "operationId": "get_path_param_le_ge_path_param_le_ge__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "maximum": 3.0,
+                                "minimum": 1.0,
+                                "type": "number",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param-lt-int/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Lt Int",
-                "operationId": "get_path_param_lt_int_path_param_lt_int__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "exclusiveMaximum": 3.0,
-                            "type": "integer",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param-gt-int/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Lt Int",
+                    "operationId": "get_path_param_lt_int_path_param_lt_int__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "exclusiveMaximum": 3.0,
+                                "type": "integer",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param-gt-int/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Gt Int",
-                "operationId": "get_path_param_gt_int_path_param_gt_int__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "exclusiveMinimum": 3.0,
-                            "type": "integer",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param-le-int/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Gt Int",
+                    "operationId": "get_path_param_gt_int_path_param_gt_int__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "exclusiveMinimum": 3.0,
+                                "type": "integer",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param-le-int/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Le Int",
-                "operationId": "get_path_param_le_int_path_param_le_int__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "maximum": 3.0,
-                            "type": "integer",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param-ge-int/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Le Int",
+                    "operationId": "get_path_param_le_int_path_param_le_int__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "maximum": 3.0,
+                                "type": "integer",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param-ge-int/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Ge Int",
-                "operationId": "get_path_param_ge_int_path_param_ge_int__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "minimum": 3.0,
-                            "type": "integer",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param-lt-gt-int/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Ge Int",
+                    "operationId": "get_path_param_ge_int_path_param_ge_int__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "minimum": 3.0,
+                                "type": "integer",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param-lt-gt-int/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Lt Gt Int",
-                "operationId": "get_path_param_lt_gt_int_path_param_lt_gt_int__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "exclusiveMaximum": 3.0,
-                            "exclusiveMinimum": 1.0,
-                            "type": "integer",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/path/param-le-ge-int/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Lt Gt Int",
+                    "operationId": "get_path_param_lt_gt_int_path_param_lt_gt_int__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "exclusiveMaximum": 3.0,
+                                "exclusiveMinimum": 1.0,
+                                "type": "integer",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/path/param-le-ge-int/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Path Param Le Ge Int",
-                "operationId": "get_path_param_le_ge_int_path_param_le_ge_int__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "maximum": 3.0,
-                            "minimum": 1.0,
-                            "type": "integer",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/query": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Path Param Le Ge Int",
+                    "operationId": "get_path_param_le_ge_int_path_param_le_ge_int__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "maximum": 3.0,
+                                "minimum": 1.0,
+                                "type": "integer",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/query": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Query",
-                "operationId": "get_query_query_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Query"},
-                        "name": "query",
-                        "in": "query",
-                    }
-                ],
-            }
-        },
-        "/query/optional": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Query",
+                    "operationId": "get_query_query_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Query"},
+                            "name": "query",
+                            "in": "query",
+                        }
+                    ],
+                }
+            },
+            "/query/optional": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Query Optional",
-                "operationId": "get_query_optional_query_optional_get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Query"},
-                        "name": "query",
-                        "in": "query",
-                    }
-                ],
-            }
-        },
-        "/query/int": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Query Optional",
+                    "operationId": "get_query_optional_query_optional_get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Query"},
+                            "name": "query",
+                            "in": "query",
+                        }
+                    ],
+                }
+            },
+            "/query/int": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Query Type",
-                "operationId": "get_query_type_query_int_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Query", "type": "integer"},
-                        "name": "query",
-                        "in": "query",
-                    }
-                ],
-            }
-        },
-        "/query/int/optional": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Query Type",
+                    "operationId": "get_query_type_query_int_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Query", "type": "integer"},
+                            "name": "query",
+                            "in": "query",
+                        }
+                    ],
+                }
+            },
+            "/query/int/optional": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Query Type Optional",
-                "operationId": "get_query_type_optional_query_int_optional_get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Query", "type": "integer"},
-                        "name": "query",
-                        "in": "query",
-                    }
-                ],
-            }
-        },
-        "/query/int/default": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Query Type Optional",
+                    "operationId": "get_query_type_optional_query_int_optional_get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Query", "type": "integer"},
+                            "name": "query",
+                            "in": "query",
+                        }
+                    ],
+                }
+            },
+            "/query/int/default": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Query Type Int Default",
-                "operationId": "get_query_type_int_default_query_int_default_get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Query", "type": "integer", "default": 10},
-                        "name": "query",
-                        "in": "query",
-                    }
-                ],
-            }
-        },
-        "/query/param": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Query Type Int Default",
+                    "operationId": "get_query_type_int_default_query_int_default_get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Query",
+                                "type": "integer",
+                                "default": 10,
+                            },
+                            "name": "query",
+                            "in": "query",
+                        }
+                    ],
+                }
+            },
+            "/query/param": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Query Param",
-                "operationId": "get_query_param_query_param_get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Query"},
-                        "name": "query",
-                        "in": "query",
-                    }
-                ],
-            }
-        },
-        "/query/param-required": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
+                    "summary": "Get Query Param",
+                    "operationId": "get_query_param_query_param_get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Query"},
+                            "name": "query",
+                            "in": "query",
+                        }
+                    ],
+                }
+            },
+            "/query/param-required": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
                     },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Query Param Required",
+                    "operationId": "get_query_param_required_query_param_required_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Query"},
+                            "name": "query",
+                            "in": "query",
+                        }
+                    ],
+                }
+            },
+            "/query/param-required/int": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Query Param Required",
-                "operationId": "get_query_param_required_query_param_required_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Query"},
-                        "name": "query",
-                        "in": "query",
-                    }
-                ],
-            }
-        },
-        "/query/param-required/int": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
+                    "summary": "Get Query Param Required Type",
+                    "operationId": "get_query_param_required_type_query_param_required_int_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Query", "type": "integer"},
+                            "name": "query",
+                            "in": "query",
+                        }
+                    ],
+                }
+            },
+            "/enum-status-code": {
+                "get": {
+                    "responses": {
+                        "201": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
                     },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "summary": "Get Enum Status Code",
+                    "operationId": "get_enum_status_code_enum_status_code_get",
+                }
+            },
+            "/query/frozenset": {
+                "get": {
+                    "summary": "Get Query Type Frozenset",
+                    "operationId": "get_query_type_frozenset_query_frozenset_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Query",
+                                "uniqueItems": True,
+                                "type": "array",
+                                "items": {"type": "integer"},
+                            },
+                            "name": "query",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-                "summary": "Get Query Param Required Type",
-                "operationId": "get_query_param_required_type_query_param_required_int_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Query", "type": "integer"},
-                        "name": "query",
-                        "in": "query",
-                    }
-                ],
-            }
+                }
+            },
         },
-        "/enum-status-code": {
-            "get": {
-                "responses": {
-                    "201": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
                     },
                 },
-                "summary": "Get Enum Status Code",
-                "operationId": "get_enum_status_code_enum_status_code_get",
-            }
-        },
-        "/query/frozenset": {
-            "get": {
-                "summary": "Get Query Type Frozenset",
-                "operationId": "get_query_type_frozenset_query_frozenset_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Query",
-                            "uniqueItems": True,
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
                             "type": "array",
-                            "items": {"type": "integer"},
-                        },
-                        "name": "query",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
                     },
                 },
             }
         },
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-@pytest.mark.parametrize(
-    "path,expected_status,expected_response",
-    [
-        ("/api_route", 200, {"message": "Hello World"}),
-        ("/non_decorated_route", 200, {"message": "Hello World"}),
-        ("/nonexistent", 404, {"detail": "Not Found"}),
-        ("/openapi.json", 200, openapi_schema),
-    ],
-)
-def test_get_path(path, expected_status, expected_response):
-    response = client.get(path)
-    assert response.status_code == expected_status
-    assert response.json() == expected_response
-
-
-def test_swagger_ui():
-    response = client.get("/docs")
-    assert response.status_code == 200, response.text
-    assert response.headers["content-type"] == "text/html; charset=utf-8"
-    assert "swagger-ui-dist" in response.text
-    assert (
-        "oauth2RedirectUrl: window.location.origin + '/docs/oauth2-redirect'"
-        in response.text
-    )
-
-
-def test_swagger_ui_oauth2_redirect():
-    response = client.get("/docs/oauth2-redirect")
-    assert response.status_code == 200, response.text
-    assert response.headers["content-type"] == "text/html; charset=utf-8"
-    assert "window.opener.swaggerUIRedirectOauth2" in response.text
-
-
-def test_redoc():
-    response = client.get("/redoc")
-    assert response.status_code == 200, response.text
-    assert response.headers["content-type"] == "text/html; charset=utf-8"
-    assert "redoc@next" in response.text
-
-
-def test_enum_status_code_response():
-    response = client.get("/enum-status-code")
-    assert response.status_code == 201, response.text
-    assert response.json() == "foo bar"
+    }
index 2e8d9c6de5e10eb721d45eb13141618b7618a448..d1b18ef1d2f558e840f86a0585b4ff703c98ee9e 100644 (file)
@@ -46,49 +46,6 @@ app.include_router(router=router_a, prefix="/a")
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/a/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Get A",
-                "operationId": "get_a_a__get",
-            }
-        },
-        "/a/b/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Get B",
-                "operationId": "get_b_a_b__get",
-            }
-        },
-        "/a/b/c/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Get C",
-                "operationId": "get_c_a_b_c__get",
-            }
-        },
-    },
-}
-
 
 @pytest.mark.parametrize(
     "path,expected_status,expected_response",
@@ -96,7 +53,6 @@ openapi_schema = {
         ("/a", 200, {"msg": "A"}),
         ("/a/b", 200, {"msg": "B"}),
         ("/a/b/c", 200, {"msg": "C"}),
-        ("/openapi.json", 200, openapi_schema),
     ],
 )
 def test_get_path(path, expected_status, expected_response):
@@ -113,3 +69,50 @@ def test_route_classes():
     assert getattr(routes["/a/"], "x_type") == "A"  # noqa: B009
     assert getattr(routes["/a/b/"], "x_type") == "B"  # noqa: B009
     assert getattr(routes["/a/b/c/"], "x_type") == "C"  # noqa: B009
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/a/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Get A",
+                    "operationId": "get_a_a__get",
+                }
+            },
+            "/a/b/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Get B",
+                    "operationId": "get_b_a_b__get",
+                }
+            },
+            "/a/b/c/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Get C",
+                    "operationId": "get_c_a_b_c__get",
+                }
+            },
+        },
+    }
index 33899134e924bf46801637ed902a7faa516e886d..285fdf1ab717effe45ff500a6ea86dd7775ff1d8 100644 (file)
@@ -44,156 +44,6 @@ async def no_duplicates_sub(
     return [item, sub_items]
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/with-duplicates": {
-            "post": {
-                "summary": "With Duplicates",
-                "operationId": "with_duplicates_with_duplicates_post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/no-duplicates": {
-            "post": {
-                "summary": "No Duplicates",
-                "operationId": "no_duplicates_no_duplicates_post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_no_duplicates_no_duplicates_post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/with-duplicates-sub": {
-            "post": {
-                "summary": "No Duplicates Sub",
-                "operationId": "no_duplicates_sub_with_duplicates_sub_post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    },
-                    "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": {
-            "Body_no_duplicates_no_duplicates_post": {
-                "title": "Body_no_duplicates_no_duplicates_post",
-                "required": ["item", "item2"],
-                "type": "object",
-                "properties": {
-                    "item": {"$ref": "#/components/schemas/Item"},
-                    "item2": {"$ref": "#/components/schemas/Item"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["data"],
-                "type": "object",
-                "properties": {"data": {"title": "Data", "type": "string"}},
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_no_duplicates_invalid():
     response = client.post("/no-duplicates", json={"item": {"data": "myitem"}})
     assert response.status_code == 422, response.text
@@ -230,3 +80,152 @@ def test_sub_duplicates():
         {"data": "myitem"},
         [{"data": "myitem"}, {"data": "myitem"}],
     ]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/with-duplicates": {
+                "post": {
+                    "summary": "With Duplicates",
+                    "operationId": "with_duplicates_with_duplicates_post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/no-duplicates": {
+                "post": {
+                    "summary": "No Duplicates",
+                    "operationId": "no_duplicates_no_duplicates_post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_no_duplicates_no_duplicates_post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/with-duplicates-sub": {
+                "post": {
+                    "summary": "No Duplicates Sub",
+                    "operationId": "no_duplicates_sub_with_duplicates_sub_post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        },
+                        "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": {
+                "Body_no_duplicates_no_duplicates_post": {
+                    "title": "Body_no_duplicates_no_duplicates_post",
+                    "required": ["item", "item2"],
+                    "type": "object",
+                    "properties": {
+                        "item": {"$ref": "#/components/schemas/Item"},
+                        "item2": {"$ref": "#/components/schemas/Item"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "Item": {
+                    "title": "Item",
+                    "required": ["data"],
+                    "type": "object",
+                    "properties": {"data": {"title": "Data", "type": "string"}},
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index a3355256f9cd1a81bff2fbf471331552c3bd597d..688b9837f2d05ac57d95ee85bd4429e58a1dd795 100644 (file)
@@ -11,34 +11,32 @@ def read_main(request: Request):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/app": {
-            "get": {
-                "summary": "Read Main",
-                "operationId": "read_main_app_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        }
-    },
-    "servers": [{"url": "/api/v1"}],
-}
-
-
-def test_openapi():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200
-    assert response.json() == openapi_schema
-
 
 def test_main():
     response = client.get("/app")
     assert response.status_code == 200
     assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}
+
+
+def test_openapi():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/app": {
+                "get": {
+                    "summary": "Read Main",
+                    "operationId": "read_main_app_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            }
+        },
+        "servers": [{"url": "/api/v1"}],
+    }
index f077dfea08026509b946e4aa7b6f3e4d1c02a905..116b2006a04a2fb03414792b9ef640c4f64fdafa 100644 (file)
@@ -23,60 +23,57 @@ def f():
     return {"c": {}, "d": {"a": {}}}
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/": {
-            "get": {
-                "summary": "F",
-                "operationId": "f__get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Model3"}
-                            }
-                        },
-                    }
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Model": {"title": "Model", "type": "object", "properties": {}},
-            "Model2": {
-                "title": "Model2",
-                "required": ["a"],
-                "type": "object",
-                "properties": {"a": {"$ref": "#/components/schemas/Model"}},
-            },
-            "Model3": {
-                "title": "Model3",
-                "required": ["c", "d"],
-                "type": "object",
-                "properties": {
-                    "c": {"$ref": "#/components/schemas/Model"},
-                    "d": {"$ref": "#/components/schemas/Model2"},
-                },
-            },
-        }
-    },
-}
-
-
 client = TestClient(app)
 
 
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_get_api_route():
     response = client.get("/")
     assert response.status_code == 200, response.text
     assert response.json() == {"c": {}, "d": {"a": {}}}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/": {
+                "get": {
+                    "summary": "F",
+                    "operationId": "f__get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Model3"}
+                                }
+                            },
+                        }
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Model": {"title": "Model", "type": "object", "properties": {}},
+                "Model2": {
+                    "title": "Model2",
+                    "required": ["a"],
+                    "type": "object",
+                    "properties": {"a": {"$ref": "#/components/schemas/Model"}},
+                },
+                "Model3": {
+                    "title": "Model3",
+                    "required": ["c", "d"],
+                    "type": "object",
+                    "properties": {
+                        "c": {"$ref": "#/components/schemas/Model"},
+                        "d": {"$ref": "#/components/schemas/Model2"},
+                    },
+                },
+            }
+        },
+    }
index e979628a5cc5e0d3fd47ffacb930a5ea2e7ae640..c0db62c19d40c425898d4c5b5a0fe1bfb3226bec 100644 (file)
@@ -52,273 +52,6 @@ def trace_item(item_id: str):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Get Items",
-                "operationId": "get_items_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            },
-            "delete": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Delete Item",
-                "operationId": "delete_item_items__item_id__delete",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    },
-                    "required": True,
-                },
-            },
-            "options": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Options Item",
-                "operationId": "options_item_items__item_id__options",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            },
-            "head": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Head Item",
-                "operationId": "head_item_items__item_id__head",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            },
-            "patch": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Patch Item",
-                "operationId": "patch_item_items__item_id__patch",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    },
-                    "required": True,
-                },
-            },
-            "trace": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Trace Item",
-                "operationId": "trace_item_items__item_id__trace",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            },
-        },
-        "/items-not-decorated/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Get Not Decorated",
-                "operationId": "get_not_decorated_items_not_decorated__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_api_route():
     response = client.get("/items/foo")
@@ -360,3 +93,270 @@ def test_trace():
     response = client.request("trace", "/items/foo")
     assert response.status_code == 200, response.text
     assert response.headers["content-type"] == "message/http"
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Get Items",
+                    "operationId": "get_items_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                },
+                "delete": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Delete Item",
+                    "operationId": "delete_item_items__item_id__delete",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        },
+                        "required": True,
+                    },
+                },
+                "options": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Options Item",
+                    "operationId": "options_item_items__item_id__options",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                },
+                "head": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Head Item",
+                    "operationId": "head_item_items__item_id__head",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                },
+                "patch": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Patch Item",
+                    "operationId": "patch_item_items__item_id__patch",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        },
+                        "required": True,
+                    },
+                },
+                "trace": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Trace Item",
+                    "operationId": "trace_item_items__item_id__trace",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                },
+            },
+            "/items-not-decorated/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Get Not Decorated",
+                    "operationId": "get_not_decorated_items_not_decorated__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 8814356a10e7963384b0963c129704b564b7d3e7..15b15f862449886acc2963f9025e2106f3017a81 100644 (file)
@@ -40,99 +40,6 @@ async def get_model_a(name: str, model_c=Depends(get_model_c)):
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/model/{name}": {
-            "get": {
-                "summary": "Get Model A",
-                "operationId": "get_model_a_model__name__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Name", "type": "string"},
-                        "name": "name",
-                        "in": "path",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/ModelA"}
-                            }
-                        },
-                    },
-                    "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ModelA": {
-                "title": "ModelA",
-                "required": ["name", "model_b"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                    "model_b": {"$ref": "#/components/schemas/ModelB"},
-                },
-            },
-            "ModelB": {
-                "title": "ModelB",
-                "required": ["username"],
-                "type": "object",
-                "properties": {"username": {"title": "Username", "type": "string"}},
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_filter_sub_model():
     response = client.get("/model/modelA")
     assert response.status_code == 200, response.text
@@ -153,3 +60,95 @@ def test_validator_is_cloned():
             "type": "value_error",
         }
     ]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/model/{name}": {
+                "get": {
+                    "summary": "Get Model A",
+                    "operationId": "get_model_a_model__name__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Name", "type": "string"},
+                            "name": "name",
+                            "in": "path",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/ModelA"}
+                                }
+                            },
+                        },
+                        "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ModelA": {
+                    "title": "ModelA",
+                    "required": ["name", "model_b"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                        "model_b": {"$ref": "#/components/schemas/ModelB"},
+                    },
+                },
+                "ModelB": {
+                    "title": "ModelB",
+                    "required": ["username"],
+                    "type": "object",
+                    "properties": {"username": {"title": "Username", "type": "string"}},
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 52a052faab1b2c2616288aba47c6764000e93174..541147fa8f123b1d619630172a4fc820e3429b6d 100644 (file)
@@ -19,90 +19,89 @@ async def create_item(product: Product):
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/product": {
-            "get": {
-                "summary": "Create Item",
-                "operationId": "create_item_product_get",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Product"}
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
+def test_get_with_body():
+    body = {"name": "Foo", "description": "Some description", "price": 5.5}
+    response = client.request("GET", "/product", json=body)
+    assert response.json() == body
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/product": {
+                "get": {
+                    "summary": "Create Item",
+                    "operationId": "create_item_product_get",
+                    "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
+                                "schema": {"$ref": "#/components/schemas/Product"}
                             }
                         },
+                        "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
+        },
+        "components": {
+            "schemas": {
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
                 },
-            },
-            "Product": {
-                "title": "Product",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
+                "Product": {
+                    "title": "Product",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                    },
                 },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
                     },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
                 },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
-def test_get_with_body():
-    body = {"name": "Foo", "description": "Some description", "price": 5.5}
-    response = client.request("GET", "/product", json=body)
-    assert response.json() == body
+            }
+        },
+    }
index ccb6c7229d37f2f2097d651fa90be577944e7c4c..ced56c84d30fd342a8f79cfda718cbeda31ba65f 100644 (file)
@@ -343,16 +343,6 @@ app.include_router(router2_default)
 client = TestClient(app)
 
 
-def test_openapi():
-    client = TestClient(app)
-    with warnings.catch_warnings(record=True) as w:
-        warnings.simplefilter("always")
-        response = client.get("/openapi.json")
-        assert issubclass(w[-1].category, UserWarning)
-        assert "Duplicate Operation ID" in str(w[-1].message)
-    assert response.json() == openapi_schema
-
-
 def test_level1_override():
     response = client.get("/override1?level1=foo")
     assert response.json() == "foo"
@@ -445,6179 +435,6863 @@ def test_paths_level5(override1, override2, override3, override4, override5):
     assert not override5 or "x-level5" in response.headers
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/override1": {
-            "get": {
-                "tags": ["path1a", "path1b"],
-                "summary": "Path1 Override",
-                "operationId": "path1_override_override1_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level1", "type": "string"},
-                        "name": "level1",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-1": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
+def test_openapi():
+    client = TestClient(app)
+    with warnings.catch_warnings(record=True) as w:
+        warnings.simplefilter("always")
+        response = client.get("/openapi.json")
+        assert issubclass(w[-1].category, UserWarning)
+        assert "Duplicate Operation ID" in str(w[-1].message)
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/override1": {
+                "get": {
+                    "tags": ["path1a", "path1b"],
+                    "summary": "Path1 Override",
+                    "operationId": "path1_override_override1_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level1", "type": "string"},
+                            "name": "level1",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-1": {"schema": {}}},
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/default1": {
-            "get": {
-                "summary": "Path1 Default",
-                "operationId": "path1_default_default1_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level1", "type": "string"},
-                        "name": "level1",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-0": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/default1": {
+                "get": {
+                    "summary": "Path1 Default",
+                    "operationId": "path1_default_default1_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level1", "type": "string"},
+                            "name": "level1",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-0": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
                         }
-                    }
-                },
-            }
-        },
-        "/level1/level2/override3": {
-            "get": {
-                "tags": [
-                    "level1a",
-                    "level1b",
-                    "level2a",
-                    "level2b",
-                    "path3a",
-                    "path3b",
-                ],
-                "summary": "Path3 Override Router2 Override",
-                "operationId": "path3_override_router2_override_level1_level2_override3_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level3", "type": "string"},
-                        "name": "level3",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-3": {"schema": {}}},
                     },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "402": {"description": "Client error level 2"},
-                    "403": {"description": "Client error level 3"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
+                }
+            },
+            "/level1/level2/override3": {
+                "get": {
+                    "tags": [
+                        "level1a",
+                        "level1b",
+                        "level2a",
+                        "level2b",
+                        "path3a",
+                        "path3b",
+                    ],
+                    "summary": "Path3 Override Router2 Override",
+                    "operationId": "path3_override_router2_override_level1_level2_override3_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level3", "type": "string"},
+                            "name": "level3",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-3": {"schema": {}}},
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "502": {"description": "Server error level 2"},
-                    "503": {"description": "Server error level 3"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "402": {"description": "Client error level 2"},
+                        "403": {"description": "Client error level 3"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "502": {"description": "Server error level 2"},
+                        "503": {"description": "Server error level 3"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level1/level2/default3": {
-            "get": {
-                "tags": ["level1a", "level1b", "level2a", "level2b"],
-                "summary": "Path3 Default Router2 Override",
-                "operationId": "path3_default_router2_override_level1_level2_default3_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level3", "type": "string"},
-                        "name": "level3",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-2": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "402": {"description": "Client error level 2"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "502": {"description": "Server error level 2"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level1/level2/default3": {
+                "get": {
+                    "tags": ["level1a", "level1b", "level2a", "level2b"],
+                    "summary": "Path3 Default Router2 Override",
+                    "operationId": "path3_default_router2_override_level1_level2_default3_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level3", "type": "string"},
+                            "name": "level3",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-2": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "402": {"description": "Client error level 2"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "502": {"description": "Server error level 2"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level1/level2/level3/level4/override5": {
-            "get": {
-                "tags": [
-                    "level1a",
-                    "level1b",
-                    "level2a",
-                    "level2b",
-                    "level3a",
-                    "level3b",
-                    "level4a",
-                    "level4b",
-                    "path5a",
-                    "path5b",
-                ],
-                "summary": "Path5 Override Router4 Override",
-                "operationId": "path5_override_router4_override_level1_level2_level3_level4_override5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-5": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "402": {"description": "Client error level 2"},
-                    "403": {"description": "Client error level 3"},
-                    "404": {"description": "Client error level 4"},
-                    "405": {"description": "Client error level 5"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "502": {"description": "Server error level 2"},
-                    "503": {"description": "Server error level 3"},
-                    "504": {"description": "Server error level 4"},
-                    "505": {"description": "Server error level 5"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level1/level2/level3/level4/override5": {
+                "get": {
+                    "tags": [
+                        "level1a",
+                        "level1b",
+                        "level2a",
+                        "level2b",
+                        "level3a",
+                        "level3b",
+                        "level4a",
+                        "level4b",
+                        "path5a",
+                        "path5b",
+                    ],
+                    "summary": "Path5 Override Router4 Override",
+                    "operationId": "path5_override_router4_override_level1_level2_level3_level4_override5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-5": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "402": {"description": "Client error level 2"},
+                        "403": {"description": "Client error level 3"},
+                        "404": {"description": "Client error level 4"},
+                        "405": {"description": "Client error level 5"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "502": {"description": "Server error level 2"},
+                        "503": {"description": "Server error level 3"},
+                        "504": {"description": "Server error level 4"},
+                        "505": {"description": "Server error level 5"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback4": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback4",
-                                "operationId": "callback4__get",
-                                "parameters": [
-                                    {
-                                        "name": "level4",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level4", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback4": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback4",
+                                    "operationId": "callback4__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level4",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level4",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback5": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback5",
-                                "operationId": "callback5__get",
-                                "parameters": [
-                                    {
-                                        "name": "level5",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level5", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback5": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback5",
+                                    "operationId": "callback5__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level5",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level5",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level1/level2/level3/level4/default5": {
-            "get": {
-                "tags": [
-                    "level1a",
-                    "level1b",
-                    "level2a",
-                    "level2b",
-                    "level3a",
-                    "level3b",
-                    "level4a",
-                    "level4b",
-                ],
-                "summary": "Path5 Default Router4 Override",
-                "operationId": "path5_default_router4_override_level1_level2_level3_level4_default5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-4": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "402": {"description": "Client error level 2"},
-                    "403": {"description": "Client error level 3"},
-                    "404": {"description": "Client error level 4"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "502": {"description": "Server error level 2"},
-                    "503": {"description": "Server error level 3"},
-                    "504": {"description": "Server error level 4"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level1/level2/level3/level4/default5": {
+                "get": {
+                    "tags": [
+                        "level1a",
+                        "level1b",
+                        "level2a",
+                        "level2b",
+                        "level3a",
+                        "level3b",
+                        "level4a",
+                        "level4b",
+                    ],
+                    "summary": "Path5 Default Router4 Override",
+                    "operationId": "path5_default_router4_override_level1_level2_level3_level4_default5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-4": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "402": {"description": "Client error level 2"},
+                        "403": {"description": "Client error level 3"},
+                        "404": {"description": "Client error level 4"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "502": {"description": "Server error level 2"},
+                        "503": {"description": "Server error level 3"},
+                        "504": {"description": "Server error level 4"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback4": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback4",
-                                "operationId": "callback4__get",
-                                "parameters": [
-                                    {
-                                        "name": "level4",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level4", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback4": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback4",
+                                    "operationId": "callback4__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level4",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level4",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level1/level2/level3/override5": {
-            "get": {
-                "tags": [
-                    "level1a",
-                    "level1b",
-                    "level2a",
-                    "level2b",
-                    "level3a",
-                    "level3b",
-                    "path5a",
-                    "path5b",
-                ],
-                "summary": "Path5 Override Router4 Default",
-                "operationId": "path5_override_router4_default_level1_level2_level3_override5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-5": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "402": {"description": "Client error level 2"},
-                    "403": {"description": "Client error level 3"},
-                    "405": {"description": "Client error level 5"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "502": {"description": "Server error level 2"},
-                    "503": {"description": "Server error level 3"},
-                    "505": {"description": "Server error level 5"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level1/level2/level3/override5": {
+                "get": {
+                    "tags": [
+                        "level1a",
+                        "level1b",
+                        "level2a",
+                        "level2b",
+                        "level3a",
+                        "level3b",
+                        "path5a",
+                        "path5b",
+                    ],
+                    "summary": "Path5 Override Router4 Default",
+                    "operationId": "path5_override_router4_default_level1_level2_level3_override5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-5": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "402": {"description": "Client error level 2"},
+                        "403": {"description": "Client error level 3"},
+                        "405": {"description": "Client error level 5"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "502": {"description": "Server error level 2"},
+                        "503": {"description": "Server error level 3"},
+                        "505": {"description": "Server error level 5"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback5": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback5",
-                                "operationId": "callback5__get",
-                                "parameters": [
-                                    {
-                                        "name": "level5",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level5", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback5": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback5",
+                                    "operationId": "callback5__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level5",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level5",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level1/level2/level3/default5": {
-            "get": {
-                "tags": [
-                    "level1a",
-                    "level1b",
-                    "level2a",
-                    "level2b",
-                    "level3a",
-                    "level3b",
-                ],
-                "summary": "Path5 Default Router4 Default",
-                "operationId": "path5_default_router4_default_level1_level2_level3_default5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-3": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "402": {"description": "Client error level 2"},
-                    "403": {"description": "Client error level 3"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "502": {"description": "Server error level 2"},
-                    "503": {"description": "Server error level 3"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level1/level2/level3/default5": {
+                "get": {
+                    "tags": [
+                        "level1a",
+                        "level1b",
+                        "level2a",
+                        "level2b",
+                        "level3a",
+                        "level3b",
+                    ],
+                    "summary": "Path5 Default Router4 Default",
+                    "operationId": "path5_default_router4_default_level1_level2_level3_default5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-3": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "402": {"description": "Client error level 2"},
+                        "403": {"description": "Client error level 3"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "502": {"description": "Server error level 2"},
+                        "503": {"description": "Server error level 3"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level1/level2/level4/override5": {
-            "get": {
-                "tags": [
-                    "level1a",
-                    "level1b",
-                    "level2a",
-                    "level2b",
-                    "level4a",
-                    "level4b",
-                    "path5a",
-                    "path5b",
-                ],
-                "summary": "Path5 Override Router4 Override",
-                "operationId": "path5_override_router4_override_level1_level2_level4_override5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-5": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "402": {"description": "Client error level 2"},
-                    "404": {"description": "Client error level 4"},
-                    "405": {"description": "Client error level 5"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "502": {"description": "Server error level 2"},
-                    "504": {"description": "Server error level 4"},
-                    "505": {"description": "Server error level 5"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback4": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback4",
-                                "operationId": "callback4__get",
-                                "parameters": [
-                                    {
-                                        "name": "level4",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level4", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback5": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback5",
-                                "operationId": "callback5__get",
-                                "parameters": [
-                                    {
-                                        "name": "level5",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level5", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level1/level2/level4/default5": {
-            "get": {
-                "tags": [
-                    "level1a",
-                    "level1b",
-                    "level2a",
-                    "level2b",
-                    "level4a",
-                    "level4b",
-                ],
-                "summary": "Path5 Default Router4 Override",
-                "operationId": "path5_default_router4_override_level1_level2_level4_default5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-4": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "402": {"description": "Client error level 2"},
-                    "404": {"description": "Client error level 4"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "502": {"description": "Server error level 2"},
-                    "504": {"description": "Server error level 4"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback4": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback4",
-                                "operationId": "callback4__get",
-                                "parameters": [
-                                    {
-                                        "name": "level4",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level4", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level1/level2/override5": {
-            "get": {
-                "tags": [
-                    "level1a",
-                    "level1b",
-                    "level2a",
-                    "level2b",
-                    "path5a",
-                    "path5b",
-                ],
-                "summary": "Path5 Override Router4 Default",
-                "operationId": "path5_override_router4_default_level1_level2_override5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-5": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "402": {"description": "Client error level 2"},
-                    "405": {"description": "Client error level 5"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "502": {"description": "Server error level 2"},
-                    "505": {"description": "Server error level 5"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback5": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback5",
-                                "operationId": "callback5__get",
-                                "parameters": [
-                                    {
-                                        "name": "level5",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level5", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level1/level2/level4/override5": {
+                "get": {
+                    "tags": [
+                        "level1a",
+                        "level1b",
+                        "level2a",
+                        "level2b",
+                        "level4a",
+                        "level4b",
+                        "path5a",
+                        "path5b",
+                    ],
+                    "summary": "Path5 Override Router4 Override",
+                    "operationId": "path5_override_router4_override_level1_level2_level4_override5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-5": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "402": {"description": "Client error level 2"},
+                        "404": {"description": "Client error level 4"},
+                        "405": {"description": "Client error level 5"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level1/level2/default5": {
-            "get": {
-                "tags": ["level1a", "level1b", "level2a", "level2b"],
-                "summary": "Path5 Default Router4 Default",
-                "operationId": "path5_default_router4_default_level1_level2_default5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-2": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "402": {"description": "Client error level 2"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
-                            }
+                            },
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "502": {"description": "Server error level 2"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "502": {"description": "Server error level 2"},
+                        "504": {"description": "Server error level 4"},
+                        "505": {"description": "Server error level 5"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level1/override3": {
-            "get": {
-                "tags": ["level1a", "level1b", "path3a", "path3b"],
-                "summary": "Path3 Override Router2 Default",
-                "operationId": "path3_override_router2_default_level1_override3_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level3", "type": "string"},
-                        "name": "level3",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-3": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "403": {"description": "Client error level 3"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "503": {"description": "Server error level 3"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level1/default3": {
-            "get": {
-                "tags": ["level1a", "level1b"],
-                "summary": "Path3 Default Router2 Default",
-                "operationId": "path3_default_router2_default_level1_default3_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level3", "type": "string"},
-                        "name": "level3",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-1": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                },
-            }
-        },
-        "/level1/level3/level4/override5": {
-            "get": {
-                "tags": [
-                    "level1a",
-                    "level1b",
-                    "level3a",
-                    "level3b",
-                    "level4a",
-                    "level4b",
-                    "path5a",
-                    "path5b",
-                ],
-                "summary": "Path5 Override Router4 Override",
-                "operationId": "path5_override_router4_override_level1_level3_level4_override5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-5": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "403": {"description": "Client error level 3"},
-                    "404": {"description": "Client error level 4"},
-                    "405": {"description": "Client error level 5"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "503": {"description": "Server error level 3"},
-                    "504": {"description": "Server error level 4"},
-                    "505": {"description": "Server error level 5"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback4": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback4",
-                                "operationId": "callback4__get",
-                                "parameters": [
-                                    {
-                                        "name": "level4",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level4", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback5": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback5",
-                                "operationId": "callback5__get",
-                                "parameters": [
-                                    {
-                                        "name": "level5",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level5", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        "callback4": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback4",
+                                    "operationId": "callback4__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level4",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level4",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level1/level3/level4/default5": {
-            "get": {
-                "tags": [
-                    "level1a",
-                    "level1b",
-                    "level3a",
-                    "level3b",
-                    "level4a",
-                    "level4b",
-                ],
-                "summary": "Path5 Default Router4 Override",
-                "operationId": "path5_default_router4_override_level1_level3_level4_default5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-4": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "403": {"description": "Client error level 3"},
-                    "404": {"description": "Client error level 4"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "503": {"description": "Server error level 3"},
-                    "504": {"description": "Server error level 4"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        "callback5": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback5",
+                                    "operationId": "callback5__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level5",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level5",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback4": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback4",
-                                "operationId": "callback4__get",
-                                "parameters": [
-                                    {
-                                        "name": "level4",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level4", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level1/level3/override5": {
-            "get": {
-                "tags": [
-                    "level1a",
-                    "level1b",
-                    "level3a",
-                    "level3b",
-                    "path5a",
-                    "path5b",
-                ],
-                "summary": "Path5 Override Router4 Default",
-                "operationId": "path5_override_router4_default_level1_level3_override5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-5": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "403": {"description": "Client error level 3"},
-                    "405": {"description": "Client error level 5"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "503": {"description": "Server error level 3"},
-                    "505": {"description": "Server error level 5"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
-                                        },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level1/level2/level4/default5": {
+                "get": {
+                    "tags": [
+                        "level1a",
+                        "level1b",
+                        "level2a",
+                        "level2b",
+                        "level4a",
+                        "level4b",
+                    ],
+                    "summary": "Path5 Default Router4 Override",
+                    "operationId": "path5_default_router4_override_level1_level2_level4_default5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-4": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "402": {"description": "Client error level 2"},
+                        "404": {"description": "Client error level 4"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "502": {"description": "Server error level 2"},
+                        "504": {"description": "Server error level 4"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback5": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback5",
-                                "operationId": "callback5__get",
-                                "parameters": [
-                                    {
-                                        "name": "level5",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level5", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level1/level3/default5": {
-            "get": {
-                "tags": ["level1a", "level1b", "level3a", "level3b"],
-                "summary": "Path5 Default Router4 Default",
-                "operationId": "path5_default_router4_default_level1_level3_default5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-3": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "403": {"description": "Client error level 3"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "503": {"description": "Server error level 3"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        "callback4": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback4",
+                                    "operationId": "callback4__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level4",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level4",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level1/level2/override5": {
+                "get": {
+                    "tags": [
+                        "level1a",
+                        "level1b",
+                        "level2a",
+                        "level2b",
+                        "path5a",
+                        "path5b",
+                    ],
+                    "summary": "Path5 Override Router4 Default",
+                    "operationId": "path5_override_router4_default_level1_level2_override5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-5": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "402": {"description": "Client error level 2"},
+                        "405": {"description": "Client error level 5"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "502": {"description": "Server error level 2"},
+                        "505": {"description": "Server error level 5"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-            }
-        },
-        "/level1/level4/override5": {
-            "get": {
-                "tags": [
-                    "level1a",
-                    "level1b",
-                    "level4a",
-                    "level4b",
-                    "path5a",
-                    "path5b",
-                ],
-                "summary": "Path5 Override Router4 Override",
-                "operationId": "path5_override_router4_override_level1_level4_override5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-5": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "404": {"description": "Client error level 4"},
-                    "405": {"description": "Client error level 5"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "504": {"description": "Server error level 4"},
-                    "505": {"description": "Server error level 5"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback5": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback5",
+                                    "operationId": "callback5__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level5",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level5",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback4": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback4",
-                                "operationId": "callback4__get",
-                                "parameters": [
-                                    {
-                                        "name": "level4",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level4", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level1/level2/default5": {
+                "get": {
+                    "tags": ["level1a", "level1b", "level2a", "level2b"],
+                    "summary": "Path5 Default Router4 Default",
+                    "operationId": "path5_default_router4_default_level1_level2_default5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-2": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "402": {"description": "Client error level 2"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "502": {"description": "Server error level 2"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback5": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback5",
-                                "operationId": "callback5__get",
-                                "parameters": [
-                                    {
-                                        "name": "level5",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level5", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level1/level4/default5": {
-            "get": {
-                "tags": ["level1a", "level1b", "level4a", "level4b"],
-                "summary": "Path5 Default Router4 Override",
-                "operationId": "path5_default_router4_override_level1_level4_default5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-4": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "404": {"description": "Client error level 4"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "504": {"description": "Server error level 4"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level1/override3": {
+                "get": {
+                    "tags": ["level1a", "level1b", "path3a", "path3b"],
+                    "summary": "Path3 Override Router2 Default",
+                    "operationId": "path3_override_router2_default_level1_override3_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level3", "type": "string"},
+                            "name": "level3",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-3": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "403": {"description": "Client error level 3"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "503": {"description": "Server error level 3"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback4": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback4",
-                                "operationId": "callback4__get",
-                                "parameters": [
-                                    {
-                                        "name": "level4",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level4", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level1/override5": {
-            "get": {
-                "tags": ["level1a", "level1b", "path5a", "path5b"],
-                "summary": "Path5 Override Router4 Default",
-                "operationId": "path5_override_router4_default_level1_override5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-5": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "405": {"description": "Client error level 5"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                    "505": {"description": "Server error level 5"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level1/default3": {
+                "get": {
+                    "tags": ["level1a", "level1b"],
+                    "summary": "Path3 Default Router2 Default",
+                    "operationId": "path3_default_router2_default_level1_default3_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level3", "type": "string"},
+                            "name": "level3",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-1": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback5": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback5",
-                                "operationId": "callback5__get",
-                                "parameters": [
-                                    {
-                                        "name": "level5",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level5", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level1/default5": {
-            "get": {
-                "tags": ["level1a", "level1b"],
-                "summary": "Path5 Default Router4 Default",
-                "operationId": "path5_default_router4_default_level1_default5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-1": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "401": {"description": "Client error level 1"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                    "501": {"description": "Server error level 1"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                }
+            },
+            "/level1/level3/level4/override5": {
+                "get": {
+                    "tags": [
+                        "level1a",
+                        "level1b",
+                        "level3a",
+                        "level3b",
+                        "level4a",
+                        "level4b",
+                        "path5a",
+                        "path5b",
+                    ],
+                    "summary": "Path5 Override Router4 Override",
+                    "operationId": "path5_override_router4_override_level1_level3_level4_override5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-5": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "403": {"description": "Client error level 3"},
+                        "404": {"description": "Client error level 4"},
+                        "405": {"description": "Client error level 5"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "503": {"description": "Server error level 3"},
+                        "504": {"description": "Server error level 4"},
+                        "505": {"description": "Server error level 5"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback1": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback1",
-                                "operationId": "callback1__get",
-                                "parameters": [
-                                    {
-                                        "name": "level1",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level1", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-            }
-        },
-        "/level2/override3": {
-            "get": {
-                "tags": ["level2a", "level2b", "path3a", "path3b"],
-                "summary": "Path3 Override Router2 Override",
-                "operationId": "path3_override_router2_override_level2_override3_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level3", "type": "string"},
-                        "name": "level3",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-3": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "402": {"description": "Client error level 2"},
-                    "403": {"description": "Client error level 3"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "502": {"description": "Server error level 2"},
-                    "503": {"description": "Server error level 3"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
+                        },
+                        "callback4": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback4",
+                                    "operationId": "callback4__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level4",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level4",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
                                     },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            }
+                        },
+                        "callback5": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback5",
+                                    "operationId": "callback5__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level5",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level5",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level1/level3/level4/default5": {
+                "get": {
+                    "tags": [
+                        "level1a",
+                        "level1b",
+                        "level3a",
+                        "level3b",
+                        "level4a",
+                        "level4b",
+                    ],
+                    "summary": "Path5 Default Router4 Override",
+                    "operationId": "path5_default_router4_override_level1_level3_level4_default5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-4": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "403": {"description": "Client error level 3"},
+                        "404": {"description": "Client error level 4"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "503": {"description": "Server error level 3"},
+                        "504": {"description": "Server error level 4"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level2/default3": {
-            "get": {
-                "tags": ["level2a", "level2b"],
-                "summary": "Path3 Default Router2 Override",
-                "operationId": "path3_default_router2_override_level2_default3_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level3", "type": "string"},
-                        "name": "level3",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-2": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "402": {"description": "Client error level 2"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
+                                    },
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "502": {"description": "Server error level 2"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
                                     },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            }
+                        },
+                        "callback4": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback4",
+                                    "operationId": "callback4__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level4",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level4",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level1/level3/override5": {
+                "get": {
+                    "tags": [
+                        "level1a",
+                        "level1b",
+                        "level3a",
+                        "level3b",
+                        "path5a",
+                        "path5b",
+                    ],
+                    "summary": "Path5 Override Router4 Default",
+                    "operationId": "path5_override_router4_default_level1_level3_override5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-5": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "403": {"description": "Client error level 3"},
+                        "405": {"description": "Client error level 5"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "503": {"description": "Server error level 3"},
+                        "505": {"description": "Server error level 5"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level2/level3/level4/override5": {
-            "get": {
-                "tags": [
-                    "level2a",
-                    "level2b",
-                    "level3a",
-                    "level3b",
-                    "level4a",
-                    "level4b",
-                    "path5a",
-                    "path5b",
-                ],
-                "summary": "Path5 Override Router4 Override",
-                "operationId": "path5_override_router4_override_level2_level3_level4_override5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-5": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "402": {"description": "Client error level 2"},
-                    "403": {"description": "Client error level 3"},
-                    "404": {"description": "Client error level 4"},
-                    "405": {"description": "Client error level 5"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
+                                    },
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "502": {"description": "Server error level 2"},
-                    "503": {"description": "Server error level 3"},
-                    "504": {"description": "Server error level 4"},
-                    "505": {"description": "Server error level 5"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
                                     },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            }
+                        },
+                        "callback5": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback5",
+                                    "operationId": "callback5__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level5",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level5",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level1/level3/default5": {
+                "get": {
+                    "tags": ["level1a", "level1b", "level3a", "level3b"],
+                    "summary": "Path5 Default Router4 Default",
+                    "operationId": "path5_default_router4_default_level1_level3_default5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-3": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "403": {"description": "Client error level 3"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "503": {"description": "Server error level 3"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
                                     },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            }
+                        },
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback4": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback4",
-                                "operationId": "callback4__get",
-                                "parameters": [
-                                    {
-                                        "name": "level4",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level4", "type": "string"},
+                }
+            },
+            "/level1/level4/override5": {
+                "get": {
+                    "tags": [
+                        "level1a",
+                        "level1b",
+                        "level4a",
+                        "level4b",
+                        "path5a",
+                        "path5b",
+                    ],
+                    "summary": "Path5 Override Router4 Override",
+                    "operationId": "path5_override_router4_override_level1_level4_override5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-5": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "404": {"description": "Client error level 4"},
+                        "405": {"description": "Client error level 5"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "504": {"description": "Server error level 4"},
+                        "505": {"description": "Server error level 5"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback5": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback5",
-                                "operationId": "callback5__get",
-                                "parameters": [
-                                    {
-                                        "name": "level5",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level5", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
                                     },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            }
+                        },
+                        "callback4": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback4",
+                                    "operationId": "callback4__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level4",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level4",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level2/level3/level4/default5": {
-            "get": {
-                "tags": [
-                    "level2a",
-                    "level2b",
-                    "level3a",
-                    "level3b",
-                    "level4a",
-                    "level4b",
-                ],
-                "summary": "Path5 Default Router4 Override",
-                "operationId": "path5_default_router4_override_level2_level3_level4_default5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-4": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "402": {"description": "Client error level 2"},
-                    "403": {"description": "Client error level 3"},
-                    "404": {"description": "Client error level 4"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                        },
+                        "callback5": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback5",
+                                    "operationId": "callback5__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level5",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level5",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
+                                    },
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                    "502": {"description": "Server error level 2"},
-                    "503": {"description": "Server error level 3"},
-                    "504": {"description": "Server error level 4"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level1/level4/default5": {
+                "get": {
+                    "tags": ["level1a", "level1b", "level4a", "level4b"],
+                    "summary": "Path5 Default Router4 Override",
+                    "operationId": "path5_default_router4_override_level1_level4_default5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-4": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "404": {"description": "Client error level 4"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "504": {"description": "Server error level 4"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback4": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback4",
+                                    "operationId": "callback4__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level4",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level4",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback4": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback4",
-                                "operationId": "callback4__get",
-                                "parameters": [
-                                    {
-                                        "name": "level4",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level4", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level1/override5": {
+                "get": {
+                    "tags": ["level1a", "level1b", "path5a", "path5b"],
+                    "summary": "Path5 Override Router4 Default",
+                    "operationId": "path5_override_router4_default_level1_override5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-5": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "405": {"description": "Client error level 5"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                        "505": {"description": "Server error level 5"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level2/level3/override5": {
-            "get": {
-                "tags": [
-                    "level2a",
-                    "level2b",
-                    "level3a",
-                    "level3b",
-                    "path5a",
-                    "path5b",
-                ],
-                "summary": "Path5 Override Router4 Default",
-                "operationId": "path5_override_router4_default_level2_level3_override5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-5": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "402": {"description": "Client error level 2"},
-                    "403": {"description": "Client error level 3"},
-                    "405": {"description": "Client error level 5"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "502": {"description": "Server error level 2"},
-                    "503": {"description": "Server error level 3"},
-                    "505": {"description": "Server error level 5"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback5": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback5",
+                                    "operationId": "callback5__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level5",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level5",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level1/default5": {
+                "get": {
+                    "tags": ["level1a", "level1b"],
+                    "summary": "Path5 Default Router4 Default",
+                    "operationId": "path5_default_router4_default_level1_default5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-1": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "401": {"description": "Client error level 1"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "501": {"description": "Server error level 1"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback5": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback5",
-                                "operationId": "callback5__get",
-                                "parameters": [
-                                    {
-                                        "name": "level5",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level5", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback1": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback1",
+                                    "operationId": "callback1__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level1",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level1",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level2/level3/default5": {
-            "get": {
-                "tags": ["level2a", "level2b", "level3a", "level3b"],
-                "summary": "Path5 Default Router4 Default",
-                "operationId": "path5_default_router4_default_level2_level3_default5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-3": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "402": {"description": "Client error level 2"},
-                    "403": {"description": "Client error level 3"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                    "502": {"description": "Server error level 2"},
-                    "503": {"description": "Server error level 3"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                }
+            },
+            "/level2/override3": {
+                "get": {
+                    "tags": ["level2a", "level2b", "path3a", "path3b"],
+                    "summary": "Path3 Override Router2 Override",
+                    "operationId": "path3_override_router2_override_level2_override3_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level3", "type": "string"},
+                            "name": "level3",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-3": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "402": {"description": "Client error level 2"},
+                        "403": {"description": "Client error level 3"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "502": {"description": "Server error level 2"},
+                        "503": {"description": "Server error level 3"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level2/level4/override5": {
-            "get": {
-                "tags": [
-                    "level2a",
-                    "level2b",
-                    "level4a",
-                    "level4b",
-                    "path5a",
-                    "path5b",
-                ],
-                "summary": "Path5 Override Router4 Override",
-                "operationId": "path5_override_router4_override_level2_level4_override5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-5": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "402": {"description": "Client error level 2"},
-                    "404": {"description": "Client error level 4"},
-                    "405": {"description": "Client error level 5"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                    "502": {"description": "Server error level 2"},
-                    "504": {"description": "Server error level 4"},
-                    "505": {"description": "Server error level 5"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level2/default3": {
+                "get": {
+                    "tags": ["level2a", "level2b"],
+                    "summary": "Path3 Default Router2 Override",
+                    "operationId": "path3_default_router2_override_level2_default3_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level3", "type": "string"},
+                            "name": "level3",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-2": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "402": {"description": "Client error level 2"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "502": {"description": "Server error level 2"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback4": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback4",
-                                "operationId": "callback4__get",
-                                "parameters": [
-                                    {
-                                        "name": "level4",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level4", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level2/level3/level4/override5": {
+                "get": {
+                    "tags": [
+                        "level2a",
+                        "level2b",
+                        "level3a",
+                        "level3b",
+                        "level4a",
+                        "level4b",
+                        "path5a",
+                        "path5b",
+                    ],
+                    "summary": "Path5 Override Router4 Override",
+                    "operationId": "path5_override_router4_override_level2_level3_level4_override5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-5": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "402": {"description": "Client error level 2"},
+                        "403": {"description": "Client error level 3"},
+                        "404": {"description": "Client error level 4"},
+                        "405": {"description": "Client error level 5"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "502": {"description": "Server error level 2"},
+                        "503": {"description": "Server error level 3"},
+                        "504": {"description": "Server error level 4"},
+                        "505": {"description": "Server error level 5"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback5": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback5",
-                                "operationId": "callback5__get",
-                                "parameters": [
-                                    {
-                                        "name": "level5",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level5", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level2/level4/default5": {
-            "get": {
-                "tags": ["level2a", "level2b", "level4a", "level4b"],
-                "summary": "Path5 Default Router4 Override",
-                "operationId": "path5_default_router4_override_level2_level4_default5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-4": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "402": {"description": "Client error level 2"},
-                    "404": {"description": "Client error level 4"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "502": {"description": "Server error level 2"},
-                    "504": {"description": "Server error level 4"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback4": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback4",
+                                    "operationId": "callback4__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level4",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level4",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback4": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback4",
-                                "operationId": "callback4__get",
-                                "parameters": [
-                                    {
-                                        "name": "level4",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level4", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback5": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback5",
+                                    "operationId": "callback5__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level5",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level5",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level2/override5": {
-            "get": {
-                "tags": ["level2a", "level2b", "path5a", "path5b"],
-                "summary": "Path5 Override Router4 Default",
-                "operationId": "path5_override_router4_default_level2_override5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-5": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "402": {"description": "Client error level 2"},
-                    "405": {"description": "Client error level 5"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                    "502": {"description": "Server error level 2"},
-                    "505": {"description": "Server error level 5"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level2/level3/level4/default5": {
+                "get": {
+                    "tags": [
+                        "level2a",
+                        "level2b",
+                        "level3a",
+                        "level3b",
+                        "level4a",
+                        "level4b",
+                    ],
+                    "summary": "Path5 Default Router4 Override",
+                    "operationId": "path5_default_router4_override_level2_level3_level4_default5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-4": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "402": {"description": "Client error level 2"},
+                        "403": {"description": "Client error level 3"},
+                        "404": {"description": "Client error level 4"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "502": {"description": "Server error level 2"},
+                        "503": {"description": "Server error level 3"},
+                        "504": {"description": "Server error level 4"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
                                     },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            }
+                        },
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
+                        },
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
                                     },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            }
+                        },
+                        "callback4": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback4",
+                                    "operationId": "callback4__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level4",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level4",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback5": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback5",
-                                "operationId": "callback5__get",
-                                "parameters": [
-                                    {
-                                        "name": "level5",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level5", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level2/level3/override5": {
+                "get": {
+                    "tags": [
+                        "level2a",
+                        "level2b",
+                        "level3a",
+                        "level3b",
+                        "path5a",
+                        "path5b",
+                    ],
+                    "summary": "Path5 Override Router4 Default",
+                    "operationId": "path5_override_router4_default_level2_level3_override5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-5": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "402": {"description": "Client error level 2"},
+                        "403": {"description": "Client error level 3"},
+                        "405": {"description": "Client error level 5"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "502": {"description": "Server error level 2"},
+                        "503": {"description": "Server error level 3"},
+                        "505": {"description": "Server error level 5"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level2/default5": {
-            "get": {
-                "tags": ["level2a", "level2b"],
-                "summary": "Path5 Default Router4 Default",
-                "operationId": "path5_default_router4_default_level2_default5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-2": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "402": {"description": "Client error level 2"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                        },
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
+                                    },
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "502": {"description": "Server error level 2"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
                                     },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            }
+                        },
+                        "callback5": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback5",
+                                    "operationId": "callback5__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level5",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level5",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback2": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback2",
-                                "operationId": "callback2__get",
-                                "parameters": [
-                                    {
-                                        "name": "level2",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level2", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level2/level3/default5": {
+                "get": {
+                    "tags": ["level2a", "level2b", "level3a", "level3b"],
+                    "summary": "Path5 Default Router4 Default",
+                    "operationId": "path5_default_router4_default_level2_level3_default5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-3": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "402": {"description": "Client error level 2"},
+                        "403": {"description": "Client error level 3"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "502": {"description": "Server error level 2"},
+                        "503": {"description": "Server error level 3"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/override3": {
-            "get": {
-                "tags": ["path3a", "path3b"],
-                "summary": "Path3 Override Router2 Default",
-                "operationId": "path3_override_router2_default_override3_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level3", "type": "string"},
-                        "name": "level3",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-3": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "403": {"description": "Client error level 3"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "503": {"description": "Server error level 3"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
                                     },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            }
+                        },
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level2/level4/override5": {
+                "get": {
+                    "tags": [
+                        "level2a",
+                        "level2b",
+                        "level4a",
+                        "level4b",
+                        "path5a",
+                        "path5b",
+                    ],
+                    "summary": "Path5 Override Router4 Override",
+                    "operationId": "path5_override_router4_override_level2_level4_override5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-5": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "402": {"description": "Client error level 2"},
+                        "404": {"description": "Client error level 4"},
+                        "405": {"description": "Client error level 5"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "502": {"description": "Server error level 2"},
+                        "504": {"description": "Server error level 4"},
+                        "505": {"description": "Server error level 5"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
                                     },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            }
+                        },
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/default3": {
-            "get": {
-                "summary": "Path3 Default Router2 Default",
-                "operationId": "path3_default_router2_default_default3_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level3", "type": "string"},
-                        "name": "level3",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-0": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                        },
+                        "callback4": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback4",
+                                    "operationId": "callback4__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level4",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level4",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
+                                    },
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        "callback5": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback5",
+                                    "operationId": "callback5__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level5",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level5",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    }
-                },
-            }
-        },
-        "/level3/level4/override5": {
-            "get": {
-                "tags": [
-                    "level3a",
-                    "level3b",
-                    "level4a",
-                    "level4b",
-                    "path5a",
-                    "path5b",
-                ],
-                "summary": "Path5 Override Router4 Override",
-                "operationId": "path5_override_router4_override_level3_level4_override5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-5": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "403": {"description": "Client error level 3"},
-                    "404": {"description": "Client error level 4"},
-                    "405": {"description": "Client error level 5"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                    "503": {"description": "Server error level 3"},
-                    "504": {"description": "Server error level 4"},
-                    "505": {"description": "Server error level 5"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level2/level4/default5": {
+                "get": {
+                    "tags": ["level2a", "level2b", "level4a", "level4b"],
+                    "summary": "Path5 Default Router4 Override",
+                    "operationId": "path5_default_router4_override_level2_level4_default5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-4": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "402": {"description": "Client error level 2"},
+                        "404": {"description": "Client error level 4"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "502": {"description": "Server error level 2"},
+                        "504": {"description": "Server error level 4"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback4": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback4",
-                                "operationId": "callback4__get",
-                                "parameters": [
-                                    {
-                                        "name": "level4",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level4", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback4": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback4",
+                                    "operationId": "callback4__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level4",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level4",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback5": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback5",
-                                "operationId": "callback5__get",
-                                "parameters": [
-                                    {
-                                        "name": "level5",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level5", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level2/override5": {
+                "get": {
+                    "tags": ["level2a", "level2b", "path5a", "path5b"],
+                    "summary": "Path5 Override Router4 Default",
+                    "operationId": "path5_override_router4_default_level2_override5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-5": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "402": {"description": "Client error level 2"},
+                        "405": {"description": "Client error level 5"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "502": {"description": "Server error level 2"},
+                        "505": {"description": "Server error level 5"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level3/level4/default5": {
-            "get": {
-                "tags": ["level3a", "level3b", "level4a", "level4b"],
-                "summary": "Path5 Default Router4 Override",
-                "operationId": "path5_default_router4_override_level3_level4_default5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-4": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "403": {"description": "Client error level 3"},
-                    "404": {"description": "Client error level 4"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "503": {"description": "Server error level 3"},
-                    "504": {"description": "Server error level 4"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback5": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback5",
+                                    "operationId": "callback5__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level5",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level5",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback4": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback4",
-                                "operationId": "callback4__get",
-                                "parameters": [
-                                    {
-                                        "name": "level4",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level4", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level2/default5": {
+                "get": {
+                    "tags": ["level2a", "level2b"],
+                    "summary": "Path5 Default Router4 Default",
+                    "operationId": "path5_default_router4_default_level2_default5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-2": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "402": {"description": "Client error level 2"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "502": {"description": "Server error level 2"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level3/override5": {
-            "get": {
-                "tags": ["level3a", "level3b", "path5a", "path5b"],
-                "summary": "Path5 Override Router4 Default",
-                "operationId": "path5_override_router4_default_level3_override5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-5": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "403": {"description": "Client error level 3"},
-                    "405": {"description": "Client error level 5"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                        },
+                        "callback2": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback2",
+                                    "operationId": "callback2__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level2",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level2",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
+                                    },
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                    "503": {"description": "Server error level 3"},
-                    "505": {"description": "Server error level 5"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/override3": {
+                "get": {
+                    "tags": ["path3a", "path3b"],
+                    "summary": "Path3 Override Router2 Default",
+                    "operationId": "path3_override_router2_default_override3_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level3", "type": "string"},
+                            "name": "level3",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-3": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "403": {"description": "Client error level 3"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "503": {"description": "Server error level 3"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
                                     },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            }
+                        },
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/default3": {
+                "get": {
+                    "summary": "Path3 Default Router2 Default",
+                    "operationId": "path3_default_router2_default_default3_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level3", "type": "string"},
+                            "name": "level3",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-0": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
                         }
                     },
-                    "callback5": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback5",
-                                "operationId": "callback5__get",
-                                "parameters": [
-                                    {
-                                        "name": "level5",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level5", "type": "string"},
+                }
+            },
+            "/level3/level4/override5": {
+                "get": {
+                    "tags": [
+                        "level3a",
+                        "level3b",
+                        "level4a",
+                        "level4b",
+                        "path5a",
+                        "path5b",
+                    ],
+                    "summary": "Path5 Override Router4 Override",
+                    "operationId": "path5_override_router4_override_level3_level4_override5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-5": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "403": {"description": "Client error level 3"},
+                        "404": {"description": "Client error level 4"},
+                        "405": {"description": "Client error level 5"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "503": {"description": "Server error level 3"},
+                        "504": {"description": "Server error level 4"},
+                        "505": {"description": "Server error level 5"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
-                            }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level3/default5": {
-            "get": {
-                "tags": ["level3a", "level3b"],
-                "summary": "Path5 Default Router4 Default",
-                "operationId": "path5_default_router4_default_level3_default5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-3": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "403": {"description": "Client error level 3"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
                                 }
                             }
                         },
-                    },
-                    "500": {"description": "Server error level 0"},
-                    "503": {"description": "Server error level 3"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback3": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback3",
-                                "operationId": "callback3__get",
-                                "parameters": [
-                                    {
-                                        "name": "level3",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level3", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                        },
+                        "callback4": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback4",
+                                    "operationId": "callback4__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level4",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level4",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                },
-            }
-        },
-        "/level4/override5": {
-            "get": {
-                "tags": ["level4a", "level4b", "path5a", "path5b"],
-                "summary": "Path5 Override Router4 Override",
-                "operationId": "path5_override_router4_override_level4_override5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-5": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "404": {"description": "Client error level 4"},
-                    "405": {"description": "Client error level 5"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                        },
+                        "callback5": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback5",
+                                    "operationId": "callback5__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level5",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level5",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
+                                    },
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                    "504": {"description": "Server error level 4"},
-                    "505": {"description": "Server error level 5"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level3/level4/default5": {
+                "get": {
+                    "tags": ["level3a", "level3b", "level4a", "level4b"],
+                    "summary": "Path5 Default Router4 Override",
+                    "operationId": "path5_default_router4_override_level3_level4_default5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-4": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "403": {"description": "Client error level 3"},
+                        "404": {"description": "Client error level 4"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "503": {"description": "Server error level 3"},
+                        "504": {"description": "Server error level 4"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                    "callback4": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback4",
-                                "operationId": "callback4__get",
-                                "parameters": [
-                                    {
-                                        "name": "level4",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level4", "type": "string"},
-                                    }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
+                        },
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
                                     },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            }
+                        },
+                        "callback4": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback4",
+                                    "operationId": "callback4__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level4",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level4",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback5": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback5",
-                                "operationId": "callback5__get",
-                                "parameters": [
-                                    {
-                                        "name": "level5",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level5", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level3/override5": {
+                "get": {
+                    "tags": ["level3a", "level3b", "path5a", "path5b"],
+                    "summary": "Path5 Override Router4 Default",
+                    "operationId": "path5_override_router4_default_level3_override5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-5": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "403": {"description": "Client error level 3"},
+                        "405": {"description": "Client error level 5"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "503": {"description": "Server error level 3"},
+                        "505": {"description": "Server error level 5"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
                                     },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            }
+                        },
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/level4/default5": {
-            "get": {
-                "tags": ["level4a", "level4b"],
-                "summary": "Path5 Default Router4 Override",
-                "operationId": "path5_default_router4_override_level4_default5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-4": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "404": {"description": "Client error level 4"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                        },
+                        "callback5": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback5",
+                                    "operationId": "callback5__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level5",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level5",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
+                                    },
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                    "504": {"description": "Server error level 4"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level3/default5": {
+                "get": {
+                    "tags": ["level3a", "level3b"],
+                    "summary": "Path5 Default Router4 Default",
+                    "operationId": "path5_default_router4_default_level3_default5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-3": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "403": {"description": "Client error level 3"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "503": {"description": "Server error level 3"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
                                     },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            }
+                        },
+                        "callback3": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback3",
+                                    "operationId": "callback3__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level3",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level3",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback4": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback4",
-                                "operationId": "callback4__get",
-                                "parameters": [
-                                    {
-                                        "name": "level4",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level4", "type": "string"},
+                }
+            },
+            "/level4/override5": {
+                "get": {
+                    "tags": ["level4a", "level4b", "path5a", "path5b"],
+                    "summary": "Path5 Override Router4 Override",
+                    "operationId": "path5_override_router4_override_level4_override5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-5": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "404": {"description": "Client error level 4"},
+                        "405": {"description": "Client error level 5"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "504": {"description": "Server error level 4"},
+                        "505": {"description": "Server error level 5"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
                                     },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            }
+                        },
+                        "callback4": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback4",
+                                    "operationId": "callback4__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level4",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level4",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/override5": {
-            "get": {
-                "tags": ["path5a", "path5b"],
-                "summary": "Path5 Override Router4 Default",
-                "operationId": "path5_override_router4_default_override5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-5": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "405": {"description": "Client error level 5"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                        },
+                        "callback5": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback5",
+                                    "operationId": "callback5__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level5",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level5",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
+                                    },
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                    "505": {"description": "Server error level 5"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/level4/default5": {
+                "get": {
+                    "tags": ["level4a", "level4b"],
+                    "summary": "Path5 Default Router4 Override",
+                    "operationId": "path5_default_router4_override_level4_default5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-4": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "404": {"description": "Client error level 4"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "504": {"description": "Server error level 4"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
                                     },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            }
+                        },
+                        "callback4": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback4",
+                                    "operationId": "callback4__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level4",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level4",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
+                        },
                     },
-                    "callback5": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback5",
-                                "operationId": "callback5__get",
-                                "parameters": [
-                                    {
-                                        "name": "level5",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level5", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/override5": {
+                "get": {
+                    "tags": ["path5a", "path5b"],
+                    "summary": "Path5 Override Router4 Default",
+                    "operationId": "path5_override_router4_default_override5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-5": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "405": {"description": "Client error level 5"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                        "505": {"description": "Server error level 5"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
                                         },
                                     },
-                                },
+                                }
                             }
-                        }
-                    },
-                },
-                "deprecated": True,
-            }
-        },
-        "/default5": {
-            "get": {
-                "summary": "Path5 Default Router4 Default",
-                "operationId": "path5_default_router4_default_default5_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Level5", "type": "string"},
-                        "name": "level5",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/x-level-0": {"schema": {}}},
-                    },
-                    "400": {"description": "Client error level 0"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                        },
+                        "callback5": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback5",
+                                    "operationId": "callback5__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level5",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level5",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {"schema": {}}
+                                            },
+                                        },
+                                        "422": {
+                                            "description": "Validation Error",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                                    }
+                                                }
+                                            },
+                                        },
+                                    },
                                 }
                             }
                         },
                     },
-                    "500": {"description": "Server error level 0"},
-                },
-                "callbacks": {
-                    "callback0": {
-                        "/": {
-                            "get": {
-                                "summary": "Callback0",
-                                "operationId": "callback0__get",
-                                "parameters": [
-                                    {
-                                        "name": "level0",
-                                        "in": "query",
-                                        "required": True,
-                                        "schema": {"title": "Level0", "type": "string"},
+                    "deprecated": True,
+                }
+            },
+            "/default5": {
+                "get": {
+                    "summary": "Path5 Default Router4 Default",
+                    "operationId": "path5_default_router4_default_default5_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Level5", "type": "string"},
+                            "name": "level5",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/x-level-0": {"schema": {}}},
+                        },
+                        "400": {"description": "Client error level 0"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
                                     }
-                                ],
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                                }
-                                            }
+                                }
+                            },
+                        },
+                        "500": {"description": "Server error level 0"},
+                    },
+                    "callbacks": {
+                        "callback0": {
+                            "/": {
+                                "get": {
+                                    "summary": "Callback0",
+                                    "operationId": "callback0__get",
+                                    "parameters": [
+                                        {
+                                            "name": "level0",
+                                            "in": "query",
+                                            "required": True,
+                                            "schema": {
+                                                "title": "Level0",
+                                                "type": "string",
+                                            },
+                                        }
+                                    ],
+                                    "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
+        "components": {
+            "schemas": {
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
                 },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
                     },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
                 },
-            },
-        }
-    },
-}
+            }
+        },
+    }
index 8b1aea03164930e3254d23dc69baf18778a9e8a5..1ebcaee8cf264377098d53adb2a59089daa0e623 100644 (file)
@@ -4,130 +4,6 @@ from .app.main import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/a/compute": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Compute",
-                "operationId": "compute_a_compute_post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_compute_a_compute_post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/b/compute/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Compute",
-                "operationId": "compute_b_compute__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_compute_b_compute__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Body_compute_b_compute__post": {
-                "title": "Body_compute_b_compute__post",
-                "required": ["a", "b"],
-                "type": "object",
-                "properties": {
-                    "a": {"title": "A", "type": "integer"},
-                    "b": {"title": "B", "type": "string"},
-                },
-            },
-            "Body_compute_a_compute_post": {
-                "title": "Body_compute_a_compute_post",
-                "required": ["a", "b"],
-                "type": "object",
-                "properties": {
-                    "a": {"title": "A", "type": "integer"},
-                    "b": {"title": "B", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_post_a():
     data = {"a": 2, "b": "foo"}
@@ -153,3 +29,127 @@ def test_post_b_invalid():
     data = {"a": "bar", "b": "foo"}
     response = client.post("/b/compute/", json=data)
     assert response.status_code == 422, response.text
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/a/compute": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Compute",
+                    "operationId": "compute_a_compute_post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_compute_a_compute_post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/b/compute/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Compute",
+                    "operationId": "compute_b_compute__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_compute_b_compute__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Body_compute_b_compute__post": {
+                    "title": "Body_compute_b_compute__post",
+                    "required": ["a", "b"],
+                    "type": "object",
+                    "properties": {
+                        "a": {"title": "A", "type": "integer"},
+                        "b": {"title": "B", "type": "string"},
+                    },
+                },
+                "Body_compute_a_compute_post": {
+                    "title": "Body_compute_a_compute_post",
+                    "required": ["a", "b"],
+                    "type": "object",
+                    "properties": {
+                        "a": {"title": "A", "type": "integer"},
+                        "b": {"title": "B", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 31308ea85cdbcd2f7603fa2d73b31a87516569fa..358684bc5cef8194cb048540c5a52ac8c93fb862 100644 (file)
@@ -21,85 +21,6 @@ def save_item_no_body(item: List[Item]):
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Save Item No Body",
-                "operationId": "save_item_no_body_items__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {
-                                "title": "Item",
-                                "type": "array",
-                                "items": {"$ref": "#/components/schemas/Item"},
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "age"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "age": {"title": "Age", "exclusiveMinimum": 0.0, "type": "number"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 single_error = {
     "detail": [
         {
@@ -137,12 +58,6 @@ multiple_errors = {
 }
 
 
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_put_correct_body():
     response = client.post("/items/", json=[{"name": "Foo", "age": 5}])
     assert response.status_code == 200, response.text
@@ -159,3 +74,92 @@ def test_put_incorrect_body_multiple():
     response = client.post("/items/", json=[{"age": "five"}, {"age": "six"}])
     assert response.status_code == 422, response.text
     assert response.json() == multiple_errors
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Save Item No Body",
+                    "operationId": "save_item_no_body_items__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {
+                                    "title": "Item",
+                                    "type": "array",
+                                    "items": {"$ref": "#/components/schemas/Item"},
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "age"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "age": {
+                            "title": "Age",
+                            "exclusiveMinimum": 0.0,
+                            "type": "number",
+                        },
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 3da461af5a532c7c0514f13ef2388ecf3d384fd5..e7a833f2baf03f75d85bf2fca478c43e498e826d 100644 (file)
@@ -14,76 +14,6 @@ def read_items(q: List[int] = Query(default=None)):
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Q",
-                            "type": "array",
-                            "items": {"type": "integer"},
-                        },
-                        "name": "q",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 multiple_errors = {
     "detail": [
         {
@@ -100,12 +30,6 @@ multiple_errors = {
 }
 
 
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_multi_query():
     response = client.get("/items/?q=5&q=6")
     assert response.status_code == 200, response.text
@@ -116,3 +40,79 @@ def test_multi_query_incorrect():
     response = client.get("/items/?q=five&q=six")
     assert response.status_code == 422, response.text
     assert response.json() == multiple_errors
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Q",
+                                "type": "array",
+                                "items": {"type": "integer"},
+                            },
+                            "name": "q",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index d3996f26ee4176017d36bdcad5e7fe2314508d3f..8a9086ebe1dab2ae9f8a27805f4736c8e6baa9d4 100644 (file)
@@ -32,96 +32,95 @@ def route_with_extra_query_parameters(standard_query_param: Optional[int] = 50):
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/": {
-            "get": {
-                "summary": "Route With Extra Query Parameters",
-                "operationId": "route_with_extra_query_parameters__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Standard Query Param",
-                            "type": "integer",
-                            "default": 50,
+def test_get_route():
+    response = client.get("/")
+    assert response.status_code == 200, response.text
+    assert response.json() == {}
+
+
+def test_openapi():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/": {
+                "get": {
+                    "summary": "Route With Extra Query Parameters",
+                    "operationId": "route_with_extra_query_parameters__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Standard Query Param",
+                                "type": "integer",
+                                "default": 50,
+                            },
+                            "name": "standard_query_param",
+                            "in": "query",
                         },
-                        "name": "standard_query_param",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Extra Param 1"},
-                        "name": "extra_param_1",
-                        "in": "query",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "Extra Param 2"},
-                        "name": "extra_param_2",
-                        "in": "query",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                        {
+                            "required": False,
+                            "schema": {"title": "Extra Param 1"},
+                            "name": "extra_param_1",
+                            "in": "query",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "Extra Param 2"},
+                            "name": "extra_param_2",
+                            "in": "query",
+                        },
+                    ],
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
+        },
+        "components": {
+            "schemas": {
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
                 },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
                     },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
                 },
-            },
-        }
-    },
-}
-
-
-def test_openapi():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
-def test_get_route():
-    response = client.get("/")
-    assert response.status_code == 200, response.text
-    assert response.json() == {}
+            }
+        },
+    }
index 8a1080d6972cb035397fff5b95befbb044ec2e99..943dc43f2debda354c8e8336bcb9ba03022eacba 100644 (file)
@@ -12,34 +12,31 @@ def route_with_extras():
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                },
-                "summary": "Route With Extras",
-                "operationId": "route_with_extras__get",
-                "x-custom-extension": "value",
-            }
-        },
-    },
-}
+def test_get_route():
+    response = client.get("/")
+    assert response.status_code == 200, response.text
+    assert response.json() == {}
 
 
 def test_openapi():
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
-def test_get_route():
-    response = client.get("/")
-    assert response.status_code == 200, response.text
-    assert response.json() == {}
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                    },
+                    "summary": "Route With Extras",
+                    "operationId": "route_with_extras__get",
+                    "x-custom-extension": "value",
+                }
+            },
+        },
+    }
index a210154f60e88ab7168eb4cb258337cdaebd6362..26abeaa12d68cb601b1491381183ef6c4410c17f 100644 (file)
@@ -21,40 +21,37 @@ def foo():
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "servers": [
-        {"url": "/", "description": "Default, relative server"},
-        {
-            "url": "http://staging.localhost.tiangolo.com:8000",
-            "description": "Staging but actually localhost still",
-        },
-        {"url": "https://prod.example.com"},
-    ],
-    "paths": {
-        "/foo": {
-            "get": {
-                "summary": "Foo",
-                "operationId": "foo_foo_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        }
-    },
-}
-
-
-def test_openapi_servers():
-    response = client.get("/openapi.json")
+def test_app():
+    response = client.get("/foo")
     assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
 
 
-def test_app():
-    response = client.get("/foo")
+def test_openapi_schema():
+    response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "servers": [
+            {"url": "/", "description": "Default, relative server"},
+            {
+                "url": "http://staging.localhost.tiangolo.com:8000",
+                "description": "Staging but actually localhost still",
+            },
+            {"url": "https://prod.example.com"},
+        ],
+        "paths": {
+            "/foo": {
+                "get": {
+                    "summary": "Foo",
+                    "operationId": "foo_foo_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            }
+        },
+    }
index 4d85afbceef2aede708d90e3255b30cb68469f3c..0aef7ac7bca04493dbc669cd728d11b9aca501b4 100644 (file)
@@ -15,79 +15,79 @@ async def read_users(user_id: int):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/{user_id}": {
-            "get": {
-                "summary": "Read Users",
-                "operationId": "read_users_users__user_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "User Id", "type": "integer"},
-                        "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"
+
+def test_read_users():
+    response = client.get("/users/42")
+    assert response.status_code == 200, response.text
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    data = response.json()
+    assert data == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/{user_id}": {
+                "get": {
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__user_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "User Id", "type": "integer"},
+                            "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"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
+                }
             }
-        }
-    },
-    "components": {
-        "schemas": {
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
+        },
+        "components": {
+            "schemas": {
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
                 },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
                     },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
                 },
-            },
-        }
-    },
-}
-
-
-def test_reused_param():
-    response = client.get("/openapi.json")
-    data = response.json()
-    assert data == openapi_schema
-
-
-def test_read_users():
-    response = client.get("/users/42")
-    assert response.status_code == 200, response.text
+            }
+        },
+    }
index 3da294ccf735f4c58622bbd779305a1ba3c08ac6..a02d1152c82a62d788824bffe3f3e7b810a56cfc 100644 (file)
@@ -12,79 +12,6 @@ def save_item_no_body(item_id: str):
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Save Item No Body",
-                "operationId": "save_item_no_body_items__item_id__put",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_put_no_body():
     response = client.put("/items/foo")
     assert response.status_code == 200, response.text
@@ -95,3 +22,75 @@ def test_put_no_body_with_body():
     response = client.put("/items/foo", json={"name": "Foo"})
     assert response.status_code == 200, response.text
     assert response.json() == {"item_id": "foo"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Save Item No Body",
+                    "operationId": "save_item_no_body_items__item_id__put",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 823f53a95a2cf88d8aec95871f2c9116f0253b95..c656a161df4dfd6e7beb7f0b4e27973d2ae45778 100644 (file)
@@ -14,87 +14,87 @@ def get_parameters_with_repeated_aliases(
 
 client = TestClient(app)
 
-openapi_schema = {
-    "components": {
-        "schemas": {
-            "HTTPValidationError": {
-                "properties": {
-                    "detail": {
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                        "title": "Detail",
-                        "type": "array",
-                    }
-                },
-                "title": "HTTPValidationError",
-                "type": "object",
-            },
-            "ValidationError": {
-                "properties": {
-                    "loc": {
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                        "title": "Location",
-                        "type": "array",
+
+def test_get_parameters():
+    response = client.get("/test_path", params={"repeated_alias": "test_query"})
+    assert response.status_code == 200, response.text
+    assert response.json() == {"path": "test_path", "query": "test_query"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == status.HTTP_200_OK
+    actual_schema = response.json()
+    assert actual_schema == {
+        "components": {
+            "schemas": {
+                "HTTPValidationError": {
+                    "properties": {
+                        "detail": {
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                            "title": "Detail",
+                            "type": "array",
+                        }
                     },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
+                    "title": "HTTPValidationError",
+                    "type": "object",
                 },
-                "required": ["loc", "msg", "type"],
-                "title": "ValidationError",
-                "type": "object",
-            },
-        }
-    },
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "openapi": "3.0.2",
-    "paths": {
-        "/{repeated_alias}": {
-            "get": {
-                "operationId": "get_parameters_with_repeated_aliases__repeated_alias__get",
-                "parameters": [
-                    {
-                        "in": "path",
-                        "name": "repeated_alias",
-                        "required": True,
-                        "schema": {"title": "Repeated Alias", "type": "string"},
-                    },
-                    {
-                        "in": "query",
-                        "name": "repeated_alias",
-                        "required": True,
-                        "schema": {"title": "Repeated Alias", "type": "string"},
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "content": {"application/json": {"schema": {}}},
-                        "description": "Successful Response",
+                "ValidationError": {
+                    "properties": {
+                        "loc": {
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                            "title": "Location",
+                            "type": "array",
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
                     },
-                    "422": {
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "required": ["loc", "msg", "type"],
+                    "title": "ValidationError",
+                    "type": "object",
+                },
+            }
+        },
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "openapi": "3.0.2",
+        "paths": {
+            "/{repeated_alias}": {
+                "get": {
+                    "operationId": "get_parameters_with_repeated_aliases__repeated_alias__get",
+                    "parameters": [
+                        {
+                            "in": "path",
+                            "name": "repeated_alias",
+                            "required": True,
+                            "schema": {"title": "Repeated Alias", "type": "string"},
+                        },
+                        {
+                            "in": "query",
+                            "name": "repeated_alias",
+                            "required": True,
+                            "schema": {"title": "Repeated Alias", "type": "string"},
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "content": {"application/json": {"schema": {}}},
+                            "description": "Successful Response",
+                        },
+                        "422": {
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
+                            "description": "Validation Error",
                         },
-                        "description": "Validation Error",
                     },
-                },
-                "summary": "Get Parameters With Repeated Aliases",
+                    "summary": "Get Parameters With Repeated Aliases",
+                }
             }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == status.HTTP_200_OK
-    actual_schema = response.json()
-    assert actual_schema == openapi_schema
-
-
-def test_get_parameters():
-    response = client.get("/test_path", params={"repeated_alias": "test_query"})
-    assert response.status_code == 200, response.text
-    assert response.json() == {"path": "test_path", "query": "test_query"}
+        },
+    }
index 50ec753a0076efa1d570043d783cced2fea780e4..14770fed0a80aa174e6abec7f0218b4de20bfef2 100644 (file)
@@ -22,77 +22,76 @@ async def delete_deployment(
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/{id}": {
-            "delete": {
-                "summary": "Delete Deployment",
-                "operationId": "delete_deployment__id__delete",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Id", "type": "integer"},
-                        "name": "id",
-                        "in": "path",
-                    }
-                ],
-                "responses": {
-                    "204": {"description": "Successful Response"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+def test_dependency_set_status_code():
+    response = client.delete("/1")
+    assert response.status_code == 400 and response.content
+    assert response.json() == {"msg": "Status overwritten", "id": 1}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/{id}": {
+                "delete": {
+                    "summary": "Delete Deployment",
+                    "operationId": "delete_deployment__id__delete",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Id", "type": "integer"},
+                            "name": "id",
+                            "in": "path",
+                        }
+                    ],
+                    "responses": {
+                        "204": {"description": "Successful Response"},
+                        "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
+        },
+        "components": {
+            "schemas": {
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
                 },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
                     },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
                 },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
-def test_dependency_set_status_code():
-    response = client.delete("/1")
-    assert response.status_code == 400 and response.content
-    assert response.json() == {"msg": "Status overwritten", "id": 1}
+            }
+        },
+    }
index de45e0880ff0ac8f97c38cb9f77f489fd9301e3c..1861a40fab0c52b08d26ce53ba2aef95ee2c5e51 100644 (file)
@@ -68,198 +68,9 @@ def no_alias_list():
     return [{"name": "Foo"}, {"name": "Bar"}]
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/dict": {
-            "get": {
-                "summary": "Read Dict",
-                "operationId": "read_dict_dict_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Model"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/model": {
-            "get": {
-                "summary": "Read Model",
-                "operationId": "read_model_model_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Model"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/list": {
-            "get": {
-                "summary": "Read List",
-                "operationId": "read_list_list_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read List List Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/Model"},
-                                }
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/by-alias/dict": {
-            "get": {
-                "summary": "By Alias Dict",
-                "operationId": "by_alias_dict_by_alias_dict_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Model"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/by-alias/model": {
-            "get": {
-                "summary": "By Alias Model",
-                "operationId": "by_alias_model_by_alias_model_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Model"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/by-alias/list": {
-            "get": {
-                "summary": "By Alias List",
-                "operationId": "by_alias_list_by_alias_list_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response By Alias List By Alias List Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/Model"},
-                                }
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/no-alias/dict": {
-            "get": {
-                "summary": "No Alias Dict",
-                "operationId": "no_alias_dict_no_alias_dict_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/ModelNoAlias"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/no-alias/model": {
-            "get": {
-                "summary": "No Alias Model",
-                "operationId": "no_alias_model_no_alias_model_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/ModelNoAlias"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/no-alias/list": {
-            "get": {
-                "summary": "No Alias List",
-                "operationId": "no_alias_list_no_alias_list_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response No Alias List No Alias List Get",
-                                    "type": "array",
-                                    "items": {
-                                        "$ref": "#/components/schemas/ModelNoAlias"
-                                    },
-                                }
-                            }
-                        },
-                    }
-                },
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Model": {
-                "title": "Model",
-                "required": ["alias"],
-                "type": "object",
-                "properties": {"alias": {"title": "Alias", "type": "string"}},
-            },
-            "ModelNoAlias": {
-                "title": "ModelNoAlias",
-                "required": ["name"],
-                "type": "object",
-                "properties": {"name": {"title": "Name", "type": "string"}},
-                "description": "response_model_by_alias=False is basically a quick hack, to support proper OpenAPI use another model with the correct field names",
-            },
-        }
-    },
-}
-
-
 client = TestClient(app)
 
 
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_read_dict():
     response = client.get("/dict")
     assert response.status_code == 200, response.text
@@ -321,3 +132,193 @@ def test_read_list_no_alias():
         {"name": "Foo"},
         {"name": "Bar"},
     ]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/dict": {
+                "get": {
+                    "summary": "Read Dict",
+                    "operationId": "read_dict_dict_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Model"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/model": {
+                "get": {
+                    "summary": "Read Model",
+                    "operationId": "read_model_model_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Model"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/list": {
+                "get": {
+                    "summary": "Read List",
+                    "operationId": "read_list_list_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read List List Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/Model"},
+                                    }
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/by-alias/dict": {
+                "get": {
+                    "summary": "By Alias Dict",
+                    "operationId": "by_alias_dict_by_alias_dict_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Model"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/by-alias/model": {
+                "get": {
+                    "summary": "By Alias Model",
+                    "operationId": "by_alias_model_by_alias_model_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Model"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/by-alias/list": {
+                "get": {
+                    "summary": "By Alias List",
+                    "operationId": "by_alias_list_by_alias_list_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response By Alias List By Alias List Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/Model"},
+                                    }
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/no-alias/dict": {
+                "get": {
+                    "summary": "No Alias Dict",
+                    "operationId": "no_alias_dict_no_alias_dict_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/ModelNoAlias"
+                                    }
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/no-alias/model": {
+                "get": {
+                    "summary": "No Alias Model",
+                    "operationId": "no_alias_model_no_alias_model_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/ModelNoAlias"
+                                    }
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/no-alias/list": {
+                "get": {
+                    "summary": "No Alias List",
+                    "operationId": "no_alias_list_no_alias_list_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response No Alias List No Alias List Get",
+                                        "type": "array",
+                                        "items": {
+                                            "$ref": "#/components/schemas/ModelNoAlias"
+                                        },
+                                    }
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Model": {
+                    "title": "Model",
+                    "required": ["alias"],
+                    "type": "object",
+                    "properties": {"alias": {"title": "Alias", "type": "string"}},
+                },
+                "ModelNoAlias": {
+                    "title": "ModelNoAlias",
+                    "required": ["name"],
+                    "type": "object",
+                    "properties": {"name": {"title": "Name", "type": "string"}},
+                    "description": "response_model_by_alias=False is basically a quick hack, to support proper OpenAPI use another model with the correct field names",
+                },
+            }
+        },
+    }
index eb8500f3a872d877ccccee7a9065ff2d33496b1e..2d75c7535827d7ca3b6aaa49804cbb7f8c2d7962 100644 (file)
@@ -35,80 +35,79 @@ async def b():
     pass  # pragma: no cover
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/a": {
-            "get": {
-                "responses": {
-                    "500": {
-                        "description": "Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/JsonApiError"}
-                            }
+client = TestClient(app)
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/a": {
+                "get": {
+                    "responses": {
+                        "500": {
+                            "description": "Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/JsonApiError"
+                                    }
+                                }
+                            },
                         },
+                        "200": {"description": "Successful Response"},
                     },
-                    "200": {"description": "Successful Response"},
-                },
-                "summary": "A",
-                "operationId": "a_a_get",
-            }
-        },
-        "/b": {
-            "get": {
-                "responses": {
-                    "500": {
-                        "description": "Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Error"}
-                            }
+                    "summary": "A",
+                    "operationId": "a_a_get",
+                }
+            },
+            "/b": {
+                "get": {
+                    "responses": {
+                        "500": {
+                            "description": "Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Error"}
+                                }
+                            },
+                        },
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
                         },
                     },
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
+                    "summary": "B",
+                    "operationId": "b_b_get",
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Error": {
+                    "title": "Error",
+                    "required": ["status", "title"],
+                    "type": "object",
+                    "properties": {
+                        "status": {"title": "Status", "type": "string"},
+                        "title": {"title": "Title", "type": "string"},
+                    },
+                },
+                "JsonApiError": {
+                    "title": "JsonApiError",
+                    "required": ["errors"],
+                    "type": "object",
+                    "properties": {
+                        "errors": {
+                            "title": "Errors",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/Error"},
+                        }
                     },
                 },
-                "summary": "B",
-                "operationId": "b_b_get",
             }
         },
-    },
-    "components": {
-        "schemas": {
-            "Error": {
-                "title": "Error",
-                "required": ["status", "title"],
-                "type": "object",
-                "properties": {
-                    "status": {"title": "Status", "type": "string"},
-                    "title": {"title": "Title", "type": "string"},
-                },
-            },
-            "JsonApiError": {
-                "title": "JsonApiError",
-                "required": ["errors"],
-                "type": "object",
-                "properties": {
-                    "errors": {
-                        "title": "Errors",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/Error"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-client = TestClient(app)
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
+    }
index 6d9b5c333401b65ae6421af9ab37fbc34dc3e5d5..3851a325de585b1ba6bea3a4f1b4bdfaeaebdb78 100644 (file)
@@ -36,80 +36,79 @@ async def b():
     pass  # pragma: no cover
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/a": {
-            "get": {
-                "responses": {
-                    "500": {
-                        "description": "Error",
-                        "content": {
-                            "application/vnd.api+json": {
-                                "schema": {"$ref": "#/components/schemas/JsonApiError"}
-                            }
-                        },
-                    },
-                    "204": {"description": "Successful Response"},
-                },
-                "summary": "A",
-                "operationId": "a_a_get",
-            }
-        },
-        "/b": {
-            "get": {
-                "responses": {
-                    "204": {"description": "No Content"},
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                },
-                "summary": "B",
-                "operationId": "b_b_get",
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Error": {
-                "title": "Error",
-                "required": ["status", "title"],
-                "type": "object",
-                "properties": {
-                    "status": {"title": "Status", "type": "string"},
-                    "title": {"title": "Title", "type": "string"},
-                },
-            },
-            "JsonApiError": {
-                "title": "JsonApiError",
-                "required": ["errors"],
-                "type": "object",
-                "properties": {
-                    "errors": {
-                        "title": "Errors",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/Error"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
 client = TestClient(app)
 
 
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_get_response():
     response = client.get("/a")
     assert response.status_code == 204, response.text
     assert "content-length" not in response.headers
     assert response.content == b""
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/a": {
+                "get": {
+                    "responses": {
+                        "500": {
+                            "description": "Error",
+                            "content": {
+                                "application/vnd.api+json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/JsonApiError"
+                                    }
+                                }
+                            },
+                        },
+                        "204": {"description": "Successful Response"},
+                    },
+                    "summary": "A",
+                    "operationId": "a_a_get",
+                }
+            },
+            "/b": {
+                "get": {
+                    "responses": {
+                        "204": {"description": "No Content"},
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                    },
+                    "summary": "B",
+                    "operationId": "b_b_get",
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Error": {
+                    "title": "Error",
+                    "required": ["status", "title"],
+                    "type": "object",
+                    "properties": {
+                        "status": {"title": "Status", "type": "string"},
+                        "title": {"title": "Title", "type": "string"},
+                    },
+                },
+                "JsonApiError": {
+                    "title": "JsonApiError",
+                    "required": ["errors"],
+                    "type": "object",
+                    "properties": {
+                        "errors": {
+                            "title": "Errors",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/Error"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index e453641497ad7c82da375bf899154b8386ad7738..7decdff7d0713ca99114845000579f34b5f598a8 100644 (file)
@@ -249,617 +249,9 @@ def no_response_model_annotation_json_response_class() -> JSONResponse:
     return JSONResponse(content={"foo": "bar"})
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/no_response_model-no_annotation-return_model": {
-            "get": {
-                "summary": "No Response Model No Annotation Return Model",
-                "operationId": "no_response_model_no_annotation_return_model_no_response_model_no_annotation_return_model_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-        "/no_response_model-no_annotation-return_dict": {
-            "get": {
-                "summary": "No Response Model No Annotation Return Dict",
-                "operationId": "no_response_model_no_annotation_return_dict_no_response_model_no_annotation_return_dict_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-        "/response_model-no_annotation-return_same_model": {
-            "get": {
-                "summary": "Response Model No Annotation Return Same Model",
-                "operationId": "response_model_no_annotation_return_same_model_response_model_no_annotation_return_same_model_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/response_model-no_annotation-return_exact_dict": {
-            "get": {
-                "summary": "Response Model No Annotation Return Exact Dict",
-                "operationId": "response_model_no_annotation_return_exact_dict_response_model_no_annotation_return_exact_dict_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/response_model-no_annotation-return_invalid_dict": {
-            "get": {
-                "summary": "Response Model No Annotation Return Invalid Dict",
-                "operationId": "response_model_no_annotation_return_invalid_dict_response_model_no_annotation_return_invalid_dict_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/response_model-no_annotation-return_invalid_model": {
-            "get": {
-                "summary": "Response Model No Annotation Return Invalid Model",
-                "operationId": "response_model_no_annotation_return_invalid_model_response_model_no_annotation_return_invalid_model_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/response_model-no_annotation-return_dict_with_extra_data": {
-            "get": {
-                "summary": "Response Model No Annotation Return Dict With Extra Data",
-                "operationId": "response_model_no_annotation_return_dict_with_extra_data_response_model_no_annotation_return_dict_with_extra_data_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/response_model-no_annotation-return_submodel_with_extra_data": {
-            "get": {
-                "summary": "Response Model No Annotation Return Submodel With Extra Data",
-                "operationId": "response_model_no_annotation_return_submodel_with_extra_data_response_model_no_annotation_return_submodel_with_extra_data_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/no_response_model-annotation-return_same_model": {
-            "get": {
-                "summary": "No Response Model Annotation Return Same Model",
-                "operationId": "no_response_model_annotation_return_same_model_no_response_model_annotation_return_same_model_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/no_response_model-annotation-return_exact_dict": {
-            "get": {
-                "summary": "No Response Model Annotation Return Exact Dict",
-                "operationId": "no_response_model_annotation_return_exact_dict_no_response_model_annotation_return_exact_dict_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/no_response_model-annotation-return_invalid_dict": {
-            "get": {
-                "summary": "No Response Model Annotation Return Invalid Dict",
-                "operationId": "no_response_model_annotation_return_invalid_dict_no_response_model_annotation_return_invalid_dict_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/no_response_model-annotation-return_invalid_model": {
-            "get": {
-                "summary": "No Response Model Annotation Return Invalid Model",
-                "operationId": "no_response_model_annotation_return_invalid_model_no_response_model_annotation_return_invalid_model_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/no_response_model-annotation-return_dict_with_extra_data": {
-            "get": {
-                "summary": "No Response Model Annotation Return Dict With Extra Data",
-                "operationId": "no_response_model_annotation_return_dict_with_extra_data_no_response_model_annotation_return_dict_with_extra_data_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/no_response_model-annotation-return_submodel_with_extra_data": {
-            "get": {
-                "summary": "No Response Model Annotation Return Submodel With Extra Data",
-                "operationId": "no_response_model_annotation_return_submodel_with_extra_data_no_response_model_annotation_return_submodel_with_extra_data_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/response_model_none-annotation-return_same_model": {
-            "get": {
-                "summary": "Response Model None Annotation Return Same Model",
-                "operationId": "response_model_none_annotation_return_same_model_response_model_none_annotation_return_same_model_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-        "/response_model_none-annotation-return_exact_dict": {
-            "get": {
-                "summary": "Response Model None Annotation Return Exact Dict",
-                "operationId": "response_model_none_annotation_return_exact_dict_response_model_none_annotation_return_exact_dict_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-        "/response_model_none-annotation-return_invalid_dict": {
-            "get": {
-                "summary": "Response Model None Annotation Return Invalid Dict",
-                "operationId": "response_model_none_annotation_return_invalid_dict_response_model_none_annotation_return_invalid_dict_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-        "/response_model_none-annotation-return_invalid_model": {
-            "get": {
-                "summary": "Response Model None Annotation Return Invalid Model",
-                "operationId": "response_model_none_annotation_return_invalid_model_response_model_none_annotation_return_invalid_model_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-        "/response_model_none-annotation-return_dict_with_extra_data": {
-            "get": {
-                "summary": "Response Model None Annotation Return Dict With Extra Data",
-                "operationId": "response_model_none_annotation_return_dict_with_extra_data_response_model_none_annotation_return_dict_with_extra_data_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-        "/response_model_none-annotation-return_submodel_with_extra_data": {
-            "get": {
-                "summary": "Response Model None Annotation Return Submodel With Extra Data",
-                "operationId": "response_model_none_annotation_return_submodel_with_extra_data_response_model_none_annotation_return_submodel_with_extra_data_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-        "/response_model_model1-annotation_model2-return_same_model": {
-            "get": {
-                "summary": "Response Model Model1 Annotation Model2 Return Same Model",
-                "operationId": "response_model_model1_annotation_model2_return_same_model_response_model_model1_annotation_model2_return_same_model_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/response_model_model1-annotation_model2-return_exact_dict": {
-            "get": {
-                "summary": "Response Model Model1 Annotation Model2 Return Exact Dict",
-                "operationId": "response_model_model1_annotation_model2_return_exact_dict_response_model_model1_annotation_model2_return_exact_dict_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/response_model_model1-annotation_model2-return_invalid_dict": {
-            "get": {
-                "summary": "Response Model Model1 Annotation Model2 Return Invalid Dict",
-                "operationId": "response_model_model1_annotation_model2_return_invalid_dict_response_model_model1_annotation_model2_return_invalid_dict_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/response_model_model1-annotation_model2-return_invalid_model": {
-            "get": {
-                "summary": "Response Model Model1 Annotation Model2 Return Invalid Model",
-                "operationId": "response_model_model1_annotation_model2_return_invalid_model_response_model_model1_annotation_model2_return_invalid_model_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/response_model_model1-annotation_model2-return_dict_with_extra_data": {
-            "get": {
-                "summary": "Response Model Model1 Annotation Model2 Return Dict With Extra Data",
-                "operationId": "response_model_model1_annotation_model2_return_dict_with_extra_data_response_model_model1_annotation_model2_return_dict_with_extra_data_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/response_model_model1-annotation_model2-return_submodel_with_extra_data": {
-            "get": {
-                "summary": "Response Model Model1 Annotation Model2 Return Submodel With Extra Data",
-                "operationId": "response_model_model1_annotation_model2_return_submodel_with_extra_data_response_model_model1_annotation_model2_return_submodel_with_extra_data_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/response_model_filtering_model-annotation_submodel-return_submodel": {
-            "get": {
-                "summary": "Response Model Filtering Model Annotation Submodel Return Submodel",
-                "operationId": "response_model_filtering_model_annotation_submodel_return_submodel_response_model_filtering_model_annotation_submodel_return_submodel_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/response_model_list_of_model-no_annotation": {
-            "get": {
-                "summary": "Response Model List Of Model No Annotation",
-                "operationId": "response_model_list_of_model_no_annotation_response_model_list_of_model_no_annotation_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Response Model List Of Model No Annotation Response Model List Of Model No Annotation Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/User"},
-                                }
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/no_response_model-annotation_list_of_model": {
-            "get": {
-                "summary": "No Response Model Annotation List Of Model",
-                "operationId": "no_response_model_annotation_list_of_model_no_response_model_annotation_list_of_model_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response No Response Model Annotation List Of Model No Response Model Annotation List Of Model Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/User"},
-                                }
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/no_response_model-annotation_forward_ref_list_of_model": {
-            "get": {
-                "summary": "No Response Model Annotation Forward Ref List Of Model",
-                "operationId": "no_response_model_annotation_forward_ref_list_of_model_no_response_model_annotation_forward_ref_list_of_model_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response No Response Model Annotation Forward Ref List Of Model No Response Model Annotation Forward Ref List Of Model Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/User"},
-                                }
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/response_model_union-no_annotation-return_model1": {
-            "get": {
-                "summary": "Response Model Union No Annotation Return Model1",
-                "operationId": "response_model_union_no_annotation_return_model1_response_model_union_no_annotation_return_model1_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Response Model Union No Annotation Return Model1 Response Model Union No Annotation Return Model1 Get",
-                                    "anyOf": [
-                                        {"$ref": "#/components/schemas/User"},
-                                        {"$ref": "#/components/schemas/Item"},
-                                    ],
-                                }
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/response_model_union-no_annotation-return_model2": {
-            "get": {
-                "summary": "Response Model Union No Annotation Return Model2",
-                "operationId": "response_model_union_no_annotation_return_model2_response_model_union_no_annotation_return_model2_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Response Model Union No Annotation Return Model2 Response Model Union No Annotation Return Model2 Get",
-                                    "anyOf": [
-                                        {"$ref": "#/components/schemas/User"},
-                                        {"$ref": "#/components/schemas/Item"},
-                                    ],
-                                }
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/no_response_model-annotation_union-return_model1": {
-            "get": {
-                "summary": "No Response Model Annotation Union Return Model1",
-                "operationId": "no_response_model_annotation_union_return_model1_no_response_model_annotation_union_return_model1_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response No Response Model Annotation Union Return Model1 No Response Model Annotation Union Return Model1 Get",
-                                    "anyOf": [
-                                        {"$ref": "#/components/schemas/User"},
-                                        {"$ref": "#/components/schemas/Item"},
-                                    ],
-                                }
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/no_response_model-annotation_union-return_model2": {
-            "get": {
-                "summary": "No Response Model Annotation Union Return Model2",
-                "operationId": "no_response_model_annotation_union_return_model2_no_response_model_annotation_union_return_model2_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response No Response Model Annotation Union Return Model2 No Response Model Annotation Union Return Model2 Get",
-                                    "anyOf": [
-                                        {"$ref": "#/components/schemas/User"},
-                                        {"$ref": "#/components/schemas/Item"},
-                                    ],
-                                }
-                            }
-                        },
-                    }
-                },
-            }
-        },
-        "/no_response_model-annotation_response_class": {
-            "get": {
-                "summary": "No Response Model Annotation Response Class",
-                "operationId": "no_response_model_annotation_response_class_no_response_model_annotation_response_class_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-        "/no_response_model-annotation_json_response_class": {
-            "get": {
-                "summary": "No Response Model Annotation Json Response Class",
-                "operationId": "no_response_model_annotation_json_response_class_no_response_model_annotation_json_response_class_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                },
-            },
-            "User": {
-                "title": "User",
-                "required": ["name", "surname"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "surname": {"title": "Surname", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
 client = TestClient(app)
 
 
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_no_response_model_no_annotation_return_model():
     response = client.get("/no_response_model-no_annotation-return_model")
     assert response.status_code == 200, response.text
@@ -1109,3 +501,608 @@ def test_invalid_response_model_field():
 
     assert "valid Pydantic field type" in e.value.args[0]
     assert "parameter response_model=None" in e.value.args[0]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/no_response_model-no_annotation-return_model": {
+                "get": {
+                    "summary": "No Response Model No Annotation Return Model",
+                    "operationId": "no_response_model_no_annotation_return_model_no_response_model_no_annotation_return_model_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+            "/no_response_model-no_annotation-return_dict": {
+                "get": {
+                    "summary": "No Response Model No Annotation Return Dict",
+                    "operationId": "no_response_model_no_annotation_return_dict_no_response_model_no_annotation_return_dict_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+            "/response_model-no_annotation-return_same_model": {
+                "get": {
+                    "summary": "Response Model No Annotation Return Same Model",
+                    "operationId": "response_model_no_annotation_return_same_model_response_model_no_annotation_return_same_model_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/response_model-no_annotation-return_exact_dict": {
+                "get": {
+                    "summary": "Response Model No Annotation Return Exact Dict",
+                    "operationId": "response_model_no_annotation_return_exact_dict_response_model_no_annotation_return_exact_dict_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/response_model-no_annotation-return_invalid_dict": {
+                "get": {
+                    "summary": "Response Model No Annotation Return Invalid Dict",
+                    "operationId": "response_model_no_annotation_return_invalid_dict_response_model_no_annotation_return_invalid_dict_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/response_model-no_annotation-return_invalid_model": {
+                "get": {
+                    "summary": "Response Model No Annotation Return Invalid Model",
+                    "operationId": "response_model_no_annotation_return_invalid_model_response_model_no_annotation_return_invalid_model_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/response_model-no_annotation-return_dict_with_extra_data": {
+                "get": {
+                    "summary": "Response Model No Annotation Return Dict With Extra Data",
+                    "operationId": "response_model_no_annotation_return_dict_with_extra_data_response_model_no_annotation_return_dict_with_extra_data_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/response_model-no_annotation-return_submodel_with_extra_data": {
+                "get": {
+                    "summary": "Response Model No Annotation Return Submodel With Extra Data",
+                    "operationId": "response_model_no_annotation_return_submodel_with_extra_data_response_model_no_annotation_return_submodel_with_extra_data_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/no_response_model-annotation-return_same_model": {
+                "get": {
+                    "summary": "No Response Model Annotation Return Same Model",
+                    "operationId": "no_response_model_annotation_return_same_model_no_response_model_annotation_return_same_model_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/no_response_model-annotation-return_exact_dict": {
+                "get": {
+                    "summary": "No Response Model Annotation Return Exact Dict",
+                    "operationId": "no_response_model_annotation_return_exact_dict_no_response_model_annotation_return_exact_dict_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/no_response_model-annotation-return_invalid_dict": {
+                "get": {
+                    "summary": "No Response Model Annotation Return Invalid Dict",
+                    "operationId": "no_response_model_annotation_return_invalid_dict_no_response_model_annotation_return_invalid_dict_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/no_response_model-annotation-return_invalid_model": {
+                "get": {
+                    "summary": "No Response Model Annotation Return Invalid Model",
+                    "operationId": "no_response_model_annotation_return_invalid_model_no_response_model_annotation_return_invalid_model_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/no_response_model-annotation-return_dict_with_extra_data": {
+                "get": {
+                    "summary": "No Response Model Annotation Return Dict With Extra Data",
+                    "operationId": "no_response_model_annotation_return_dict_with_extra_data_no_response_model_annotation_return_dict_with_extra_data_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/no_response_model-annotation-return_submodel_with_extra_data": {
+                "get": {
+                    "summary": "No Response Model Annotation Return Submodel With Extra Data",
+                    "operationId": "no_response_model_annotation_return_submodel_with_extra_data_no_response_model_annotation_return_submodel_with_extra_data_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/response_model_none-annotation-return_same_model": {
+                "get": {
+                    "summary": "Response Model None Annotation Return Same Model",
+                    "operationId": "response_model_none_annotation_return_same_model_response_model_none_annotation_return_same_model_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+            "/response_model_none-annotation-return_exact_dict": {
+                "get": {
+                    "summary": "Response Model None Annotation Return Exact Dict",
+                    "operationId": "response_model_none_annotation_return_exact_dict_response_model_none_annotation_return_exact_dict_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+            "/response_model_none-annotation-return_invalid_dict": {
+                "get": {
+                    "summary": "Response Model None Annotation Return Invalid Dict",
+                    "operationId": "response_model_none_annotation_return_invalid_dict_response_model_none_annotation_return_invalid_dict_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+            "/response_model_none-annotation-return_invalid_model": {
+                "get": {
+                    "summary": "Response Model None Annotation Return Invalid Model",
+                    "operationId": "response_model_none_annotation_return_invalid_model_response_model_none_annotation_return_invalid_model_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+            "/response_model_none-annotation-return_dict_with_extra_data": {
+                "get": {
+                    "summary": "Response Model None Annotation Return Dict With Extra Data",
+                    "operationId": "response_model_none_annotation_return_dict_with_extra_data_response_model_none_annotation_return_dict_with_extra_data_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+            "/response_model_none-annotation-return_submodel_with_extra_data": {
+                "get": {
+                    "summary": "Response Model None Annotation Return Submodel With Extra Data",
+                    "operationId": "response_model_none_annotation_return_submodel_with_extra_data_response_model_none_annotation_return_submodel_with_extra_data_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+            "/response_model_model1-annotation_model2-return_same_model": {
+                "get": {
+                    "summary": "Response Model Model1 Annotation Model2 Return Same Model",
+                    "operationId": "response_model_model1_annotation_model2_return_same_model_response_model_model1_annotation_model2_return_same_model_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/response_model_model1-annotation_model2-return_exact_dict": {
+                "get": {
+                    "summary": "Response Model Model1 Annotation Model2 Return Exact Dict",
+                    "operationId": "response_model_model1_annotation_model2_return_exact_dict_response_model_model1_annotation_model2_return_exact_dict_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/response_model_model1-annotation_model2-return_invalid_dict": {
+                "get": {
+                    "summary": "Response Model Model1 Annotation Model2 Return Invalid Dict",
+                    "operationId": "response_model_model1_annotation_model2_return_invalid_dict_response_model_model1_annotation_model2_return_invalid_dict_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/response_model_model1-annotation_model2-return_invalid_model": {
+                "get": {
+                    "summary": "Response Model Model1 Annotation Model2 Return Invalid Model",
+                    "operationId": "response_model_model1_annotation_model2_return_invalid_model_response_model_model1_annotation_model2_return_invalid_model_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/response_model_model1-annotation_model2-return_dict_with_extra_data": {
+                "get": {
+                    "summary": "Response Model Model1 Annotation Model2 Return Dict With Extra Data",
+                    "operationId": "response_model_model1_annotation_model2_return_dict_with_extra_data_response_model_model1_annotation_model2_return_dict_with_extra_data_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/response_model_model1-annotation_model2-return_submodel_with_extra_data": {
+                "get": {
+                    "summary": "Response Model Model1 Annotation Model2 Return Submodel With Extra Data",
+                    "operationId": "response_model_model1_annotation_model2_return_submodel_with_extra_data_response_model_model1_annotation_model2_return_submodel_with_extra_data_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/response_model_filtering_model-annotation_submodel-return_submodel": {
+                "get": {
+                    "summary": "Response Model Filtering Model Annotation Submodel Return Submodel",
+                    "operationId": "response_model_filtering_model_annotation_submodel_return_submodel_response_model_filtering_model_annotation_submodel_return_submodel_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/response_model_list_of_model-no_annotation": {
+                "get": {
+                    "summary": "Response Model List Of Model No Annotation",
+                    "operationId": "response_model_list_of_model_no_annotation_response_model_list_of_model_no_annotation_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Response Model List Of Model No Annotation Response Model List Of Model No Annotation Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/User"},
+                                    }
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/no_response_model-annotation_list_of_model": {
+                "get": {
+                    "summary": "No Response Model Annotation List Of Model",
+                    "operationId": "no_response_model_annotation_list_of_model_no_response_model_annotation_list_of_model_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response No Response Model Annotation List Of Model No Response Model Annotation List Of Model Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/User"},
+                                    }
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/no_response_model-annotation_forward_ref_list_of_model": {
+                "get": {
+                    "summary": "No Response Model Annotation Forward Ref List Of Model",
+                    "operationId": "no_response_model_annotation_forward_ref_list_of_model_no_response_model_annotation_forward_ref_list_of_model_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response No Response Model Annotation Forward Ref List Of Model No Response Model Annotation Forward Ref List Of Model Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/User"},
+                                    }
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/response_model_union-no_annotation-return_model1": {
+                "get": {
+                    "summary": "Response Model Union No Annotation Return Model1",
+                    "operationId": "response_model_union_no_annotation_return_model1_response_model_union_no_annotation_return_model1_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Response Model Union No Annotation Return Model1 Response Model Union No Annotation Return Model1 Get",
+                                        "anyOf": [
+                                            {"$ref": "#/components/schemas/User"},
+                                            {"$ref": "#/components/schemas/Item"},
+                                        ],
+                                    }
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/response_model_union-no_annotation-return_model2": {
+                "get": {
+                    "summary": "Response Model Union No Annotation Return Model2",
+                    "operationId": "response_model_union_no_annotation_return_model2_response_model_union_no_annotation_return_model2_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Response Model Union No Annotation Return Model2 Response Model Union No Annotation Return Model2 Get",
+                                        "anyOf": [
+                                            {"$ref": "#/components/schemas/User"},
+                                            {"$ref": "#/components/schemas/Item"},
+                                        ],
+                                    }
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/no_response_model-annotation_union-return_model1": {
+                "get": {
+                    "summary": "No Response Model Annotation Union Return Model1",
+                    "operationId": "no_response_model_annotation_union_return_model1_no_response_model_annotation_union_return_model1_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response No Response Model Annotation Union Return Model1 No Response Model Annotation Union Return Model1 Get",
+                                        "anyOf": [
+                                            {"$ref": "#/components/schemas/User"},
+                                            {"$ref": "#/components/schemas/Item"},
+                                        ],
+                                    }
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/no_response_model-annotation_union-return_model2": {
+                "get": {
+                    "summary": "No Response Model Annotation Union Return Model2",
+                    "operationId": "no_response_model_annotation_union_return_model2_no_response_model_annotation_union_return_model2_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response No Response Model Annotation Union Return Model2 No Response Model Annotation Union Return Model2 Get",
+                                        "anyOf": [
+                                            {"$ref": "#/components/schemas/User"},
+                                            {"$ref": "#/components/schemas/Item"},
+                                        ],
+                                    }
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+            "/no_response_model-annotation_response_class": {
+                "get": {
+                    "summary": "No Response Model Annotation Response Class",
+                    "operationId": "no_response_model_annotation_response_class_no_response_model_annotation_response_class_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+            "/no_response_model-annotation_json_response_class": {
+                "get": {
+                    "summary": "No Response Model Annotation Json Response Class",
+                    "operationId": "no_response_model_annotation_json_response_class_no_response_model_annotation_json_response_class_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                    },
+                },
+                "User": {
+                    "title": "User",
+                    "required": ["name", "surname"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "surname": {"title": "Surname", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index fd972e6a3d4724fc341866b1457853683f51ec5b..e462006ff173566951f1234009c0f93d0ee47597 100644 (file)
@@ -32,129 +32,127 @@ def valid4():
     pass
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/valid1": {
-            "get": {
-                "summary": "Valid1",
-                "operationId": "valid1_valid1_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "500": {
-                        "description": "Internal Server Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response 500 Valid1 Valid1 Get",
-                                    "type": "integer",
+client = TestClient(app)
+
+
+def test_path_operations():
+    response = client.get("/valid1")
+    assert response.status_code == 200, response.text
+    response = client.get("/valid2")
+    assert response.status_code == 200, response.text
+    response = client.get("/valid3")
+    assert response.status_code == 200, response.text
+    response = client.get("/valid4")
+    assert response.status_code == 200, response.text
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/valid1": {
+                "get": {
+                    "summary": "Valid1",
+                    "operationId": "valid1_valid1_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "500": {
+                            "description": "Internal Server Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response 500 Valid1 Valid1 Get",
+                                        "type": "integer",
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-            }
-        },
-        "/valid2": {
-            "get": {
-                "summary": "Valid2",
-                "operationId": "valid2_valid2_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "500": {
-                        "description": "Internal Server Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response 500 Valid2 Valid2 Get",
-                                    "type": "array",
-                                    "items": {"type": "integer"},
+                }
+            },
+            "/valid2": {
+                "get": {
+                    "summary": "Valid2",
+                    "operationId": "valid2_valid2_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "500": {
+                            "description": "Internal Server Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response 500 Valid2 Valid2 Get",
+                                        "type": "array",
+                                        "items": {"type": "integer"},
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-            }
-        },
-        "/valid3": {
-            "get": {
-                "summary": "Valid3",
-                "operationId": "valid3_valid3_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "500": {
-                        "description": "Internal Server Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Model"}
-                            }
+                }
+            },
+            "/valid3": {
+                "get": {
+                    "summary": "Valid3",
+                    "operationId": "valid3_valid3_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "500": {
+                            "description": "Internal Server Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Model"}
+                                }
+                            },
                         },
                     },
-                },
-            }
-        },
-        "/valid4": {
-            "get": {
-                "summary": "Valid4",
-                "operationId": "valid4_valid4_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "500": {
-                        "description": "Internal Server Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response 500 Valid4 Valid4 Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/Model"},
+                }
+            },
+            "/valid4": {
+                "get": {
+                    "summary": "Valid4",
+                    "operationId": "valid4_valid4_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "500": {
+                            "description": "Internal Server Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response 500 Valid4 Valid4 Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/Model"},
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-            }
+                }
+            },
         },
-    },
-    "components": {
-        "schemas": {
-            "Model": {
-                "title": "Model",
-                "required": ["name"],
-                "type": "object",
-                "properties": {"name": {"title": "Name", "type": "string"}},
+        "components": {
+            "schemas": {
+                "Model": {
+                    "title": "Model",
+                    "required": ["name"],
+                    "type": "object",
+                    "properties": {"name": {"title": "Name", "type": "string"}},
+                }
             }
-        }
-    },
-}
-
-client = TestClient(app)
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
-def test_path_operations():
-    response = client.get("/valid1")
-    assert response.status_code == 200, response.text
-    response = client.get("/valid2")
-    assert response.status_code == 200, response.text
-    response = client.get("/valid3")
-    assert response.status_code == 200, response.text
-    response = client.get("/valid4")
-    assert response.status_code == 200, response.text
+        },
+    }
index f07d2c3b8c4d76e861e9a6287d01356e7da8e9d6..74e15d59acb18f777a173e1f6968994fe4a3595e 100644 (file)
@@ -234,653 +234,654 @@ def cookie_example_examples(
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/schema_extra/": {
-            "post": {
-                "summary": "Schema Extra",
-                "operationId": "schema_extra_schema_extra__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
+def test_call_api():
+    response = client.post("/schema_extra/", json={"data": "Foo"})
+    assert response.status_code == 200, response.text
+    response = client.post("/example/", json={"data": "Foo"})
+    assert response.status_code == 200, response.text
+    response = client.post("/examples/", json={"data": "Foo"})
+    assert response.status_code == 200, response.text
+    response = client.post("/example_examples/", json={"data": "Foo"})
+    assert response.status_code == 200, response.text
+    response = client.get("/path_example/foo")
+    assert response.status_code == 200, response.text
+    response = client.get("/path_examples/foo")
+    assert response.status_code == 200, response.text
+    response = client.get("/path_example_examples/foo")
+    assert response.status_code == 200, response.text
+    response = client.get("/query_example/")
+    assert response.status_code == 200, response.text
+    response = client.get("/query_examples/")
+    assert response.status_code == 200, response.text
+    response = client.get("/query_example_examples/")
+    assert response.status_code == 200, response.text
+    response = client.get("/header_example/")
+    assert response.status_code == 200, response.text
+    response = client.get("/header_examples/")
+    assert response.status_code == 200, response.text
+    response = client.get("/header_example_examples/")
+    assert response.status_code == 200, response.text
+    response = client.get("/cookie_example/")
+    assert response.status_code == 200, response.text
+    response = client.get("/cookie_examples/")
+    assert response.status_code == 200, response.text
+    response = client.get("/cookie_example_examples/")
+    assert response.status_code == 200, response.text
+
+
+def test_openapi_schema():
+    """
+    Test that example overrides work:
+
+    * pydantic model schema_extra is included
+    * Body(example={}) overrides schema_extra in pydantic model
+    * Body(examples{}) overrides Body(example={}) and schema_extra in pydantic model
+    """
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/schema_extra/": {
+                "post": {
+                    "summary": "Schema Extra",
+                    "operationId": "schema_extra_schema_extra__post",
+                    "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
+                                "schema": {"$ref": "#/components/schemas/Item"}
                             }
                         },
+                        "required": True,
                     },
-                },
-            }
-        },
-        "/example/": {
-            "post": {
-                "summary": "Example",
-                "operationId": "example_example__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"},
-                            "example": {"data": "Data in Body example"},
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
                     },
-                    "422": {
-                        "description": "Validation Error",
+                }
+            },
+            "/example/": {
+                "post": {
+                    "summary": "Example",
+                    "operationId": "example_example__post",
+                    "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
+                                "schema": {"$ref": "#/components/schemas/Item"},
+                                "example": {"data": "Data in Body example"},
                             }
                         },
+                        "required": True,
                     },
-                },
-            }
-        },
-        "/examples/": {
-            "post": {
-                "summary": "Examples",
-                "operationId": "examples_examples__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"},
-                            "examples": {
-                                "example1": {
-                                    "summary": "example1 summary",
-                                    "value": {
-                                        "data": "Data in Body examples, example1"
-                                    },
-                                },
-                                "example2": {
-                                    "value": {"data": "Data in Body examples, example2"}
-                                },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
                             },
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
+                        },
                     },
-                    "422": {
-                        "description": "Validation Error",
+                }
+            },
+            "/examples/": {
+                "post": {
+                    "summary": "Examples",
+                    "operationId": "examples_examples__post",
+                    "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
+                                "schema": {"$ref": "#/components/schemas/Item"},
+                                "examples": {
+                                    "example1": {
+                                        "summary": "example1 summary",
+                                        "value": {
+                                            "data": "Data in Body examples, example1"
+                                        },
+                                    },
+                                    "example2": {
+                                        "value": {
+                                            "data": "Data in Body examples, example2"
+                                        }
+                                    },
+                                },
                             }
                         },
+                        "required": True,
                     },
-                },
-            }
-        },
-        "/example_examples/": {
-            "post": {
-                "summary": "Example Examples",
-                "operationId": "example_examples_example_examples__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"},
-                            "examples": {
-                                "example1": {
-                                    "value": {"data": "examples example_examples 1"}
-                                },
-                                "example2": {
-                                    "value": {"data": "examples example_examples 2"}
-                                },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
                             },
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
+                        },
                     },
-                    "422": {
-                        "description": "Validation Error",
+                }
+            },
+            "/example_examples/": {
+                "post": {
+                    "summary": "Example Examples",
+                    "operationId": "example_examples_example_examples__post",
+                    "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
+                                "schema": {"$ref": "#/components/schemas/Item"},
+                                "examples": {
+                                    "example1": {
+                                        "value": {"data": "examples example_examples 1"}
+                                    },
+                                    "example2": {
+                                        "value": {"data": "examples example_examples 2"}
+                                    },
+                                },
                             }
                         },
-                    },
-                },
-            }
-        },
-        "/path_example/{item_id}": {
-            "get": {
-                "summary": "Path Example",
-                "operationId": "path_example_path_example__item_id__get",
-                "parameters": [
-                    {
                         "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "example": "item_1",
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
                     },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-            }
-        },
-        "/path_examples/{item_id}": {
-            "get": {
-                "summary": "Path Examples",
-                "operationId": "path_examples_path_examples__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "examples": {
-                            "example1": {
-                                "summary": "item ID summary",
-                                "value": "item_1",
+                }
+            },
+            "/path_example/{item_id}": {
+                "get": {
+                    "summary": "Path Example",
+                    "operationId": "path_example_path_example__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "example": "item_1",
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
                             },
-                            "example2": {"value": "item_2"},
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
+                        },
                     },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                }
+            },
+            "/path_examples/{item_id}": {
+                "get": {
+                    "summary": "Path Examples",
+                    "operationId": "path_examples_path_examples__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "examples": {
+                                "example1": {
+                                    "summary": "item ID summary",
+                                    "value": "item_1",
+                                },
+                                "example2": {"value": "item_2"},
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-            }
-        },
-        "/path_example_examples/{item_id}": {
-            "get": {
-                "summary": "Path Example Examples",
-                "operationId": "path_example_examples_path_example_examples__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "examples": {
-                            "example1": {
-                                "summary": "item ID summary",
-                                "value": "item_1",
+                }
+            },
+            "/path_example_examples/{item_id}": {
+                "get": {
+                    "summary": "Path Example Examples",
+                    "operationId": "path_example_examples_path_example_examples__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "examples": {
+                                "example1": {
+                                    "summary": "item ID summary",
+                                    "value": "item_1",
+                                },
+                                "example2": {"value": "item_2"},
                             },
-                            "example2": {"value": "item_2"},
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-            }
-        },
-        "/query_example/": {
-            "get": {
-                "summary": "Query Example",
-                "operationId": "query_example_query_example__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Data", "type": "string"},
-                        "example": "query1",
-                        "name": "data",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                }
+            },
+            "/query_example/": {
+                "get": {
+                    "summary": "Query Example",
+                    "operationId": "query_example_query_example__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Data", "type": "string"},
+                            "example": "query1",
+                            "name": "data",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-            }
-        },
-        "/query_examples/": {
-            "get": {
-                "summary": "Query Examples",
-                "operationId": "query_examples_query_examples__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Data", "type": "string"},
-                        "examples": {
-                            "example1": {
-                                "summary": "Query example 1",
-                                "value": "query1",
+                }
+            },
+            "/query_examples/": {
+                "get": {
+                    "summary": "Query Examples",
+                    "operationId": "query_examples_query_examples__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Data", "type": "string"},
+                            "examples": {
+                                "example1": {
+                                    "summary": "Query example 1",
+                                    "value": "query1",
+                                },
+                                "example2": {"value": "query2"},
                             },
-                            "example2": {"value": "query2"},
-                        },
-                        "name": "data",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                            "name": "data",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-            }
-        },
-        "/query_example_examples/": {
-            "get": {
-                "summary": "Query Example Examples",
-                "operationId": "query_example_examples_query_example_examples__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Data", "type": "string"},
-                        "examples": {
-                            "example1": {
-                                "summary": "Query example 1",
-                                "value": "query1",
+                }
+            },
+            "/query_example_examples/": {
+                "get": {
+                    "summary": "Query Example Examples",
+                    "operationId": "query_example_examples_query_example_examples__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Data", "type": "string"},
+                            "examples": {
+                                "example1": {
+                                    "summary": "Query example 1",
+                                    "value": "query1",
+                                },
+                                "example2": {"value": "query2"},
                             },
-                            "example2": {"value": "query2"},
-                        },
-                        "name": "data",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                            "name": "data",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-            }
-        },
-        "/header_example/": {
-            "get": {
-                "summary": "Header Example",
-                "operationId": "header_example_header_example__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Data", "type": "string"},
-                        "example": "header1",
-                        "name": "data",
-                        "in": "header",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                }
+            },
+            "/header_example/": {
+                "get": {
+                    "summary": "Header Example",
+                    "operationId": "header_example_header_example__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Data", "type": "string"},
+                            "example": "header1",
+                            "name": "data",
+                            "in": "header",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-            }
-        },
-        "/header_examples/": {
-            "get": {
-                "summary": "Header Examples",
-                "operationId": "header_examples_header_examples__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Data", "type": "string"},
-                        "examples": {
-                            "example1": {
-                                "summary": "header example 1",
-                                "value": "header1",
+                }
+            },
+            "/header_examples/": {
+                "get": {
+                    "summary": "Header Examples",
+                    "operationId": "header_examples_header_examples__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Data", "type": "string"},
+                            "examples": {
+                                "example1": {
+                                    "summary": "header example 1",
+                                    "value": "header1",
+                                },
+                                "example2": {"value": "header2"},
                             },
-                            "example2": {"value": "header2"},
-                        },
-                        "name": "data",
-                        "in": "header",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                            "name": "data",
+                            "in": "header",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-            }
-        },
-        "/header_example_examples/": {
-            "get": {
-                "summary": "Header Example Examples",
-                "operationId": "header_example_examples_header_example_examples__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Data", "type": "string"},
-                        "examples": {
-                            "example1": {
-                                "summary": "Query example 1",
-                                "value": "header1",
+                }
+            },
+            "/header_example_examples/": {
+                "get": {
+                    "summary": "Header Example Examples",
+                    "operationId": "header_example_examples_header_example_examples__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Data", "type": "string"},
+                            "examples": {
+                                "example1": {
+                                    "summary": "Query example 1",
+                                    "value": "header1",
+                                },
+                                "example2": {"value": "header2"},
                             },
-                            "example2": {"value": "header2"},
-                        },
-                        "name": "data",
-                        "in": "header",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                            "name": "data",
+                            "in": "header",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-            }
-        },
-        "/cookie_example/": {
-            "get": {
-                "summary": "Cookie Example",
-                "operationId": "cookie_example_cookie_example__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Data", "type": "string"},
-                        "example": "cookie1",
-                        "name": "data",
-                        "in": "cookie",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                }
+            },
+            "/cookie_example/": {
+                "get": {
+                    "summary": "Cookie Example",
+                    "operationId": "cookie_example_cookie_example__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Data", "type": "string"},
+                            "example": "cookie1",
+                            "name": "data",
+                            "in": "cookie",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-            }
-        },
-        "/cookie_examples/": {
-            "get": {
-                "summary": "Cookie Examples",
-                "operationId": "cookie_examples_cookie_examples__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Data", "type": "string"},
-                        "examples": {
-                            "example1": {
-                                "summary": "cookie example 1",
-                                "value": "cookie1",
+                }
+            },
+            "/cookie_examples/": {
+                "get": {
+                    "summary": "Cookie Examples",
+                    "operationId": "cookie_examples_cookie_examples__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Data", "type": "string"},
+                            "examples": {
+                                "example1": {
+                                    "summary": "cookie example 1",
+                                    "value": "cookie1",
+                                },
+                                "example2": {"value": "cookie2"},
                             },
-                            "example2": {"value": "cookie2"},
-                        },
-                        "name": "data",
-                        "in": "cookie",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                            "name": "data",
+                            "in": "cookie",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
                                 }
-                            }
+                            },
                         },
                     },
-                },
-            }
-        },
-        "/cookie_example_examples/": {
-            "get": {
-                "summary": "Cookie Example Examples",
-                "operationId": "cookie_example_examples_cookie_example_examples__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Data", "type": "string"},
-                        "examples": {
-                            "example1": {
-                                "summary": "Query example 1",
-                                "value": "cookie1",
+                }
+            },
+            "/cookie_example_examples/": {
+                "get": {
+                    "summary": "Cookie Example Examples",
+                    "operationId": "cookie_example_examples_cookie_example_examples__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Data", "type": "string"},
+                            "examples": {
+                                "example1": {
+                                    "summary": "Query example 1",
+                                    "value": "cookie1",
+                                },
+                                "example2": {"value": "cookie2"},
                             },
-                            "example2": {"value": "cookie2"},
-                        },
-                        "name": "data",
-                        "in": "cookie",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                            "name": "data",
+                            "in": "cookie",
+                        }
+                    ],
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
+        "components": {
+            "schemas": {
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
                 },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["data"],
-                "type": "object",
-                "properties": {"data": {"title": "Data", "type": "string"}},
-                "example": {"data": "Data in schema_extra"},
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
+                "Item": {
+                    "title": "Item",
+                    "required": ["data"],
+                    "type": "object",
+                    "properties": {"data": {"title": "Data", "type": "string"}},
+                    "example": {"data": "Data in schema_extra"},
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
                     },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
                 },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    """
-    Test that example overrides work:
-
-    * pydantic model schema_extra is included
-    * Body(example={}) overrides schema_extra in pydantic model
-    * Body(examples{}) overrides Body(example={}) and schema_extra in pydantic model
-    """
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
-def test_call_api():
-    response = client.post("/schema_extra/", json={"data": "Foo"})
-    assert response.status_code == 200, response.text
-    response = client.post("/example/", json={"data": "Foo"})
-    assert response.status_code == 200, response.text
-    response = client.post("/examples/", json={"data": "Foo"})
-    assert response.status_code == 200, response.text
-    response = client.post("/example_examples/", json={"data": "Foo"})
-    assert response.status_code == 200, response.text
-    response = client.get("/path_example/foo")
-    assert response.status_code == 200, response.text
-    response = client.get("/path_examples/foo")
-    assert response.status_code == 200, response.text
-    response = client.get("/path_example_examples/foo")
-    assert response.status_code == 200, response.text
-    response = client.get("/query_example/")
-    assert response.status_code == 200, response.text
-    response = client.get("/query_examples/")
-    assert response.status_code == 200, response.text
-    response = client.get("/query_example_examples/")
-    assert response.status_code == 200, response.text
-    response = client.get("/header_example/")
-    assert response.status_code == 200, response.text
-    response = client.get("/header_examples/")
-    assert response.status_code == 200, response.text
-    response = client.get("/header_example_examples/")
-    assert response.status_code == 200, response.text
-    response = client.get("/cookie_example/")
-    assert response.status_code == 200, response.text
-    response = client.get("/cookie_examples/")
-    assert response.status_code == 200, response.text
-    response = client.get("/cookie_example_examples/")
-    assert response.status_code == 200, response.text
+            }
+        },
+    }
index 0bf4e9bb3ad25db88c2a23a3cdaa9b8f43fb2302..b1c648c55e184925fec3a0cda0773c98bd47706d 100644 (file)
@@ -22,39 +22,6 @@ def read_current_user(current_user: User = Depends(get_current_user)):
     return current_user
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"APIKeyCookie": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "APIKeyCookie": {"type": "apiKey", "name": "key", "in": "cookie"}
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    client = TestClient(app)
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_security_api_key():
     client = TestClient(app, cookies={"key": "secret"})
     response = client.get("/users/me")
@@ -67,3 +34,33 @@ def test_security_api_key_no_key():
     response = client.get("/users/me")
     assert response.status_code == 403, response.text
     assert response.json() == {"detail": "Not authenticated"}
+
+
+def test_openapi_schema():
+    client = TestClient(app)
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"APIKeyCookie": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "APIKeyCookie": {"type": "apiKey", "name": "key", "in": "cookie"}
+            }
+        },
+    }
index ed4e6523944827c7e68b0b33591b0f2ad8010b4b..ac8b4abf8791b862393e54119fd4d639877d0840 100644 (file)
@@ -22,44 +22,6 @@ def read_current_user(current_user: User = Depends(get_current_user)):
     return current_user
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"APIKeyCookie": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "APIKeyCookie": {
-                "type": "apiKey",
-                "name": "key",
-                "in": "cookie",
-                "description": "An API Cookie Key",
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    client = TestClient(app)
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_security_api_key():
     client = TestClient(app, cookies={"key": "secret"})
     response = client.get("/users/me")
@@ -72,3 +34,38 @@ def test_security_api_key_no_key():
     response = client.get("/users/me")
     assert response.status_code == 403, response.text
     assert response.json() == {"detail": "Not authenticated"}
+
+
+def test_openapi_schema():
+    client = TestClient(app)
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"APIKeyCookie": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "APIKeyCookie": {
+                    "type": "apiKey",
+                    "name": "key",
+                    "in": "cookie",
+                    "description": "An API Cookie Key",
+                }
+            }
+        },
+    }
index 3e7aa81c07a5ab5b64db4abac1f6d85a3fb7f977..b8c440c9d703f2faa8224f7d46d2cc26d096b3b5 100644 (file)
@@ -29,39 +29,6 @@ def read_current_user(current_user: User = Depends(get_current_user)):
         return current_user
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"APIKeyCookie": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "APIKeyCookie": {"type": "apiKey", "name": "key", "in": "cookie"}
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    client = TestClient(app)
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_security_api_key():
     client = TestClient(app, cookies={"key": "secret"})
     response = client.get("/users/me")
@@ -74,3 +41,33 @@ def test_security_api_key_no_key():
     response = client.get("/users/me")
     assert response.status_code == 200, response.text
     assert response.json() == {"msg": "Create an account first"}
+
+
+def test_openapi_schema():
+    client = TestClient(app)
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"APIKeyCookie": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "APIKeyCookie": {"type": "apiKey", "name": "key", "in": "cookie"}
+            }
+        },
+    }
index d53395f9991acd76f7abdec0bac35594d69954a4..96ad80b54a5bfff5f845a3e3dd6bd6ba2962ee77 100644 (file)
@@ -24,37 +24,6 @@ def read_current_user(current_user: User = Depends(get_current_user)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"APIKeyHeader": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "APIKeyHeader": {"type": "apiKey", "name": "key", "in": "header"}
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_api_key():
     response = client.get("/users/me", headers={"key": "secret"})
@@ -66,3 +35,32 @@ def test_security_api_key_no_key():
     response = client.get("/users/me")
     assert response.status_code == 403, response.text
     assert response.json() == {"detail": "Not authenticated"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"APIKeyHeader": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "APIKeyHeader": {"type": "apiKey", "name": "key", "in": "header"}
+            }
+        },
+    }
index cc980270806ffb07b39d28ed347b23d94042aa9c..382f53dd7819785905f293e79b15d9238457f5f5 100644 (file)
@@ -24,42 +24,6 @@ def read_current_user(current_user: User = Depends(get_current_user)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"APIKeyHeader": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "APIKeyHeader": {
-                "type": "apiKey",
-                "name": "key",
-                "in": "header",
-                "description": "An API Key Header",
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_api_key():
     response = client.get("/users/me", headers={"key": "secret"})
@@ -71,3 +35,37 @@ def test_security_api_key_no_key():
     response = client.get("/users/me")
     assert response.status_code == 403, response.text
     assert response.json() == {"detail": "Not authenticated"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"APIKeyHeader": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "APIKeyHeader": {
+                    "type": "apiKey",
+                    "name": "key",
+                    "in": "header",
+                    "description": "An API Key Header",
+                }
+            }
+        },
+    }
index 4ab599c2ddd282592b56bb5ef315e94043290faf..adfb20ba08d0c9efd2b5b1af6ccb30b95590d71a 100644 (file)
@@ -30,37 +30,6 @@ def read_current_user(current_user: Optional[User] = Depends(get_current_user)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"APIKeyHeader": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "APIKeyHeader": {"type": "apiKey", "name": "key", "in": "header"}
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_api_key():
     response = client.get("/users/me", headers={"key": "secret"})
@@ -72,3 +41,32 @@ def test_security_api_key_no_key():
     response = client.get("/users/me")
     assert response.status_code == 200, response.text
     assert response.json() == {"msg": "Create an account first"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"APIKeyHeader": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "APIKeyHeader": {"type": "apiKey", "name": "key", "in": "header"}
+            }
+        },
+    }
index 4844c65e22ad446f73cf6b1aac419a2d02389ce9..da98eafd6cce22daa1314522e0cbb16db5d34b61 100644 (file)
@@ -24,37 +24,6 @@ def read_current_user(current_user: User = Depends(get_current_user)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"APIKeyQuery": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "APIKeyQuery": {"type": "apiKey", "name": "key", "in": "query"}
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_api_key():
     response = client.get("/users/me?key=secret")
@@ -66,3 +35,32 @@ def test_security_api_key_no_key():
     response = client.get("/users/me")
     assert response.status_code == 403, response.text
     assert response.json() == {"detail": "Not authenticated"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"APIKeyQuery": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "APIKeyQuery": {"type": "apiKey", "name": "key", "in": "query"}
+            }
+        },
+    }
index 9b608233a56bade917b864c418f2e64216ef499f..3c08afc5f4d8b602b5efaf56806cdd8a4d7329f9 100644 (file)
@@ -24,42 +24,6 @@ def read_current_user(current_user: User = Depends(get_current_user)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"APIKeyQuery": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "APIKeyQuery": {
-                "type": "apiKey",
-                "name": "key",
-                "in": "query",
-                "description": "API Key Query",
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_api_key():
     response = client.get("/users/me?key=secret")
@@ -71,3 +35,37 @@ def test_security_api_key_no_key():
     response = client.get("/users/me")
     assert response.status_code == 403, response.text
     assert response.json() == {"detail": "Not authenticated"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"APIKeyQuery": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "APIKeyQuery": {
+                    "type": "apiKey",
+                    "name": "key",
+                    "in": "query",
+                    "description": "API Key Query",
+                }
+            }
+        },
+    }
index 9339b7b3aa0c093270b929469f06689a93eb126f..99a26cfd0bec3938aab24433a6026dd94596ea06 100644 (file)
@@ -30,37 +30,6 @@ def read_current_user(current_user: Optional[User] = Depends(get_current_user)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"APIKeyQuery": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "APIKeyQuery": {"type": "apiKey", "name": "key", "in": "query"}
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_api_key():
     response = client.get("/users/me?key=secret")
@@ -72,3 +41,32 @@ def test_security_api_key_no_key():
     response = client.get("/users/me")
     assert response.status_code == 200, response.text
     assert response.json() == {"msg": "Create an account first"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"APIKeyQuery": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "APIKeyQuery": {"type": "apiKey", "name": "key", "in": "query"}
+            }
+        },
+    }
index 89471627968fad63fcee1105cae11f695dccc101..d3a7542034685be08a99a86058c1afa240dac6f9 100644 (file)
@@ -14,35 +14,6 @@ def read_current_user(credentials: HTTPAuthorizationCredentials = Security(secur
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"HTTPBase": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {"HTTPBase": {"type": "http", "scheme": "Other"}}
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_http_base():
     response = client.get("/users/me", headers={"Authorization": "Other foobar"})
@@ -54,3 +25,30 @@ def test_security_http_base_no_credentials():
     response = client.get("/users/me")
     assert response.status_code == 403, response.text
     assert response.json() == {"detail": "Not authenticated"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"HTTPBase": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {"HTTPBase": {"type": "http", "scheme": "Other"}}
+        },
+    }
index 5855e8df405ca1f6ac4568fde7f6edcd2abb1786..3d7d150166bf7befb1cc8f6528446d0957cd7481 100644 (file)
@@ -14,41 +14,6 @@ def read_current_user(credentials: HTTPAuthorizationCredentials = Security(secur
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"HTTPBase": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "HTTPBase": {
-                "type": "http",
-                "scheme": "Other",
-                "description": "Other Security Scheme",
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_http_base():
     response = client.get("/users/me", headers={"Authorization": "Other foobar"})
@@ -60,3 +25,36 @@ def test_security_http_base_no_credentials():
     response = client.get("/users/me")
     assert response.status_code == 403, response.text
     assert response.json() == {"detail": "Not authenticated"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"HTTPBase": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "HTTPBase": {
+                    "type": "http",
+                    "scheme": "Other",
+                    "description": "Other Security Scheme",
+                }
+            }
+        },
+    }
index 5a50f9b88c54d88234b1af30aef96f7e80c503a7..180c9110e9919d20eb2d41e29df0587f5b6a04f2 100644 (file)
@@ -20,35 +20,6 @@ def read_current_user(
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"HTTPBase": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {"HTTPBase": {"type": "http", "scheme": "Other"}}
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_http_base():
     response = client.get("/users/me", headers={"Authorization": "Other foobar"})
@@ -60,3 +31,30 @@ def test_security_http_base_no_credentials():
     response = client.get("/users/me")
     assert response.status_code == 200, response.text
     assert response.json() == {"msg": "Create an account first"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"HTTPBase": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {"HTTPBase": {"type": "http", "scheme": "Other"}}
+        },
+    }
index 91824d22347b7bdf3d6e645e720dc9d6d6e041b0..7e7fcac32a8e72f1e617a53b6c4f7a6f854f9679 100644 (file)
@@ -19,35 +19,6 @@ def read_current_user(credentials: Optional[HTTPBasicCredentials] = Security(sec
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"HTTPBasic": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_http_basic():
     response = client.get("/users/me", auth=("john", "secret"))
@@ -77,3 +48,30 @@ def test_security_http_basic_non_basic_credentials():
     assert response.status_code == 401, response.text
     assert response.headers["WWW-Authenticate"] == "Basic"
     assert response.json() == {"detail": "Invalid authentication credentials"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"HTTPBasic": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
+        },
+    }
index 6d760c0f92e2a12be1b82fa5e93f9a2a62ae61f6..470afd662a4e607c807f9539e0b43a324a35287f 100644 (file)
@@ -16,35 +16,6 @@ def read_current_user(credentials: HTTPBasicCredentials = Security(security)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"HTTPBasic": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_http_basic():
     response = client.get("/users/me", auth=("john", "secret"))
@@ -75,3 +46,30 @@ def test_security_http_basic_non_basic_credentials():
     assert response.status_code == 401, response.text
     assert response.headers["WWW-Authenticate"] == 'Basic realm="simple"'
     assert response.json() == {"detail": "Invalid authentication credentials"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"HTTPBasic": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
+        },
+    }
index 7cc5475614ddf1f32df12694a27802794dc2ba20..44289007b55d49d6084265b24ba3d4bfd0382068 100644 (file)
@@ -16,41 +16,6 @@ def read_current_user(credentials: HTTPBasicCredentials = Security(security)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"HTTPBasic": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "HTTPBasic": {
-                "type": "http",
-                "scheme": "basic",
-                "description": "HTTPBasic scheme",
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_http_basic():
     response = client.get("/users/me", auth=("john", "secret"))
@@ -81,3 +46,36 @@ def test_security_http_basic_non_basic_credentials():
     assert response.status_code == 401, response.text
     assert response.headers["WWW-Authenticate"] == 'Basic realm="simple"'
     assert response.json() == {"detail": "Invalid authentication credentials"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"HTTPBasic": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "HTTPBasic": {
+                    "type": "http",
+                    "scheme": "basic",
+                    "description": "HTTPBasic scheme",
+                }
+            }
+        },
+    }
index 39d8c84029d875c8a3167f01a3381f1d9a7c6445..f24869fc323600f0c800be0f8f58410a4ef7aade 100644 (file)
@@ -14,35 +14,6 @@ def read_current_user(credentials: HTTPAuthorizationCredentials = Security(secur
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"HTTPBearer": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {"HTTPBearer": {"type": "http", "scheme": "bearer"}}
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_http_bearer():
     response = client.get("/users/me", headers={"Authorization": "Bearer foobar"})
@@ -60,3 +31,30 @@ def test_security_http_bearer_incorrect_scheme_credentials():
     response = client.get("/users/me", headers={"Authorization": "Basic notreally"})
     assert response.status_code == 403, response.text
     assert response.json() == {"detail": "Invalid authentication credentials"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"HTTPBearer": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {"HTTPBearer": {"type": "http", "scheme": "bearer"}}
+        },
+    }
index 132e720fc12b1381c1c0737a8595092df8329349..6d5ad0b8e7e00c104d5ea480817f36b326753aa8 100644 (file)
@@ -14,41 +14,6 @@ def read_current_user(credentials: HTTPAuthorizationCredentials = Security(secur
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"HTTPBearer": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "HTTPBearer": {
-                "type": "http",
-                "scheme": "bearer",
-                "description": "HTTP Bearer token scheme",
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_http_bearer():
     response = client.get("/users/me", headers={"Authorization": "Bearer foobar"})
@@ -66,3 +31,36 @@ def test_security_http_bearer_incorrect_scheme_credentials():
     response = client.get("/users/me", headers={"Authorization": "Basic notreally"})
     assert response.status_code == 403, response.text
     assert response.json() == {"detail": "Invalid authentication credentials"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"HTTPBearer": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "HTTPBearer": {
+                    "type": "http",
+                    "scheme": "bearer",
+                    "description": "HTTP Bearer token scheme",
+                }
+            }
+        },
+    }
index 2e7dfb8a4e7c4bdfddf88573b753594b68475f2c..b596ac7300d9d514a396c8f1811305d7145aec9c 100644 (file)
@@ -20,35 +20,6 @@ def read_current_user(
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"HTTPBearer": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {"HTTPBearer": {"type": "http", "scheme": "bearer"}}
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_http_bearer():
     response = client.get("/users/me", headers={"Authorization": "Bearer foobar"})
@@ -66,3 +37,30 @@ def test_security_http_bearer_incorrect_scheme_credentials():
     response = client.get("/users/me", headers={"Authorization": "Basic notreally"})
     assert response.status_code == 200, response.text
     assert response.json() == {"msg": "Create an account first"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"HTTPBearer": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {"HTTPBearer": {"type": "http", "scheme": "bearer"}}
+        },
+    }
index 8388824ff2bded8495e55fab07eac67a0dd8e7f9..2a25efe0233254929ac78f9682475d616435b276 100644 (file)
@@ -14,35 +14,6 @@ def read_current_user(credentials: HTTPAuthorizationCredentials = Security(secur
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"HTTPDigest": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {"HTTPDigest": {"type": "http", "scheme": "digest"}}
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_http_digest():
     response = client.get("/users/me", headers={"Authorization": "Digest foobar"})
@@ -62,3 +33,30 @@ def test_security_http_digest_incorrect_scheme_credentials():
     )
     assert response.status_code == 403, response.text
     assert response.json() == {"detail": "Invalid authentication credentials"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"HTTPDigest": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {"HTTPDigest": {"type": "http", "scheme": "digest"}}
+        },
+    }
index d00aa1b6e344e18a32d76fc02808fad47b9cf581..721f7cfde5e545c738b76aa16cd75f932c6a98ee 100644 (file)
@@ -14,41 +14,6 @@ def read_current_user(credentials: HTTPAuthorizationCredentials = Security(secur
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"HTTPDigest": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "HTTPDigest": {
-                "type": "http",
-                "scheme": "digest",
-                "description": "HTTPDigest scheme",
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_http_digest():
     response = client.get("/users/me", headers={"Authorization": "Digest foobar"})
@@ -68,3 +33,36 @@ def test_security_http_digest_incorrect_scheme_credentials():
     )
     assert response.status_code == 403, response.text
     assert response.json() == {"detail": "Invalid authentication credentials"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"HTTPDigest": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "HTTPDigest": {
+                    "type": "http",
+                    "scheme": "digest",
+                    "description": "HTTPDigest scheme",
+                }
+            }
+        },
+    }
index 2177b819f3b26397d20a1312391bb5efc70485c3..d4c3597bcbe2e6cfc1bc28c34c4c4b4b957b55bf 100644 (file)
@@ -20,35 +20,6 @@ def read_current_user(
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"HTTPDigest": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {"HTTPDigest": {"type": "http", "scheme": "digest"}}
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_http_digest():
     response = client.get("/users/me", headers={"Authorization": "Digest foobar"})
@@ -68,3 +39,30 @@ def test_security_http_digest_incorrect_scheme_credentials():
     )
     assert response.status_code == 403, response.text
     assert response.json() == {"detail": "Invalid authentication credentials"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"HTTPDigest": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {"HTTPDigest": {"type": "http", "scheme": "digest"}}
+        },
+    }
index b9ac488eea545a6d98cca217e8b3b132edb07672..23dce7cfa9664ca7f4f92a23ae1a1bca197709dd 100644 (file)
@@ -40,124 +40,6 @@ def read_current_user(current_user: "User" = Depends(get_current_user)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "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 Current User",
-                "operationId": "read_current_user_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", "type": "string"},
-                    "client_secret": {"title": "Client Secret", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        },
-        "securitySchemes": {
-            "OAuth2": {
-                "type": "oauth2",
-                "flows": {
-                    "password": {
-                        "scopes": {
-                            "read:users": "Read the users",
-                            "write:users": "Create users",
-                        },
-                        "tokenUrl": "token",
-                    }
-                },
-            }
-        },
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_oauth2():
     response = client.get("/users/me", headers={"Authorization": "Bearer footokenbar"})
@@ -247,3 +129,121 @@ def test_strict_login(data, expected_status, expected_response):
     response = client.post("/login", data=data)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "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 Current User",
+                    "operationId": "read_current_user_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", "type": "string"},
+                        "client_secret": {"title": "Client Secret", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            },
+            "securitySchemes": {
+                "OAuth2": {
+                    "type": "oauth2",
+                    "flows": {
+                        "password": {
+                            "scopes": {
+                                "read:users": "Read the users",
+                                "write:users": "Create users",
+                            },
+                            "tokenUrl": "token",
+                        }
+                    },
+                }
+            },
+        },
+    }
index ad9a39ded746c8e7f86cc46f338b692e9490125b..6df81528db7ecb21e4a193b9e090ae41bdd70b03 100644 (file)
@@ -18,46 +18,6 @@ async def read_items(token: Optional[str] = Security(oauth2_scheme)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "security": [{"OAuth2AuthorizationCodeBearer": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "OAuth2AuthorizationCodeBearer": {
-                "type": "oauth2",
-                "flows": {
-                    "authorizationCode": {
-                        "authorizationUrl": "authorize",
-                        "tokenUrl": "token",
-                        "scopes": {},
-                    }
-                },
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_no_token():
     response = client.get("/items")
@@ -75,3 +35,41 @@ def test_token():
     response = client.get("/items", headers={"Authorization": "Bearer testtoken"})
     assert response.status_code == 200, response.text
     assert response.json() == {"token": "testtoken"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "security": [{"OAuth2AuthorizationCodeBearer": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "OAuth2AuthorizationCodeBearer": {
+                    "type": "oauth2",
+                    "flows": {
+                        "authorizationCode": {
+                            "authorizationUrl": "authorize",
+                            "tokenUrl": "token",
+                            "scopes": {},
+                        }
+                    },
+                }
+            }
+        },
+    }
index bdaa543fc343a2d3bad999f2d7a70e95f7b4f898..c119abde4da18d5b81b1a57bca3004f8f1ed63c4 100644 (file)
@@ -21,47 +21,6 @@ async def read_items(token: Optional[str] = Security(oauth2_scheme)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "security": [{"OAuth2AuthorizationCodeBearer": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "OAuth2AuthorizationCodeBearer": {
-                "type": "oauth2",
-                "flows": {
-                    "authorizationCode": {
-                        "authorizationUrl": "authorize",
-                        "tokenUrl": "token",
-                        "scopes": {},
-                    }
-                },
-                "description": "OAuth2 Code Bearer",
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_no_token():
     response = client.get("/items")
@@ -79,3 +38,42 @@ def test_token():
     response = client.get("/items", headers={"Authorization": "Bearer testtoken"})
     assert response.status_code == 200, response.text
     assert response.json() == {"token": "testtoken"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "security": [{"OAuth2AuthorizationCodeBearer": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "OAuth2AuthorizationCodeBearer": {
+                    "type": "oauth2",
+                    "flows": {
+                        "authorizationCode": {
+                            "authorizationUrl": "authorize",
+                            "tokenUrl": "token",
+                            "scopes": {},
+                        }
+                    },
+                    "description": "OAuth2 Code Bearer",
+                }
+            }
+        },
+    }
index a5fd49b8c7a7a7df672eb2f4844faa3f6dbe0417..3ef9f4a8d2448495012d5e8fe18387ce58d7e9be 100644 (file)
@@ -44,124 +44,6 @@ def read_users_me(current_user: Optional[User] = Depends(get_current_user)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "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", "type": "string"},
-                    "client_secret": {"title": "Client Secret", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        },
-        "securitySchemes": {
-            "OAuth2": {
-                "type": "oauth2",
-                "flows": {
-                    "password": {
-                        "scopes": {
-                            "read:users": "Read the users",
-                            "write:users": "Create users",
-                        },
-                        "tokenUrl": "token",
-                    }
-                },
-            }
-        },
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_oauth2():
     response = client.get("/users/me", headers={"Authorization": "Bearer footokenbar"})
@@ -251,3 +133,121 @@ def test_strict_login(data, expected_status, expected_response):
     response = client.post("/login", data=data)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "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", "type": "string"},
+                        "client_secret": {"title": "Client Secret", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            },
+            "securitySchemes": {
+                "OAuth2": {
+                    "type": "oauth2",
+                    "flows": {
+                        "password": {
+                            "scopes": {
+                                "read:users": "Read the users",
+                                "write:users": "Create users",
+                            },
+                            "tokenUrl": "token",
+                        }
+                    },
+                }
+            },
+        },
+    }
index 171f96b762e7f27004f2da14183d359b52d23382..b6425fde4db197034abbe0159298753101e290a5 100644 (file)
@@ -45,125 +45,6 @@ def read_users_me(current_user: Optional[User] = Depends(get_current_user)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "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", "type": "string"},
-                    "client_secret": {"title": "Client Secret", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        },
-        "securitySchemes": {
-            "OAuth2": {
-                "type": "oauth2",
-                "flows": {
-                    "password": {
-                        "scopes": {
-                            "read:users": "Read the users",
-                            "write:users": "Create users",
-                        },
-                        "tokenUrl": "token",
-                    }
-                },
-                "description": "OAuth2 security scheme",
-            }
-        },
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_oauth2():
     response = client.get("/users/me", headers={"Authorization": "Bearer footokenbar"})
@@ -253,3 +134,122 @@ def test_strict_login(data, expected_status, expected_response):
     response = client.post("/login", data=data)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "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", "type": "string"},
+                        "client_secret": {"title": "Client Secret", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            },
+            "securitySchemes": {
+                "OAuth2": {
+                    "type": "oauth2",
+                    "flows": {
+                        "password": {
+                            "scopes": {
+                                "read:users": "Read the users",
+                                "write:users": "Create users",
+                            },
+                            "tokenUrl": "token",
+                        }
+                    },
+                    "description": "OAuth2 security scheme",
+                }
+            },
+        },
+    }
index 3d6637d4a5a6d1e4f10a872e96a2c5b583ead39a..e5dcbb553d589313e4c3d4e3a97a98324445fd28 100644 (file)
@@ -18,40 +18,6 @@ async def read_items(token: Optional[str] = Security(oauth2_scheme)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "security": [{"OAuth2PasswordBearer": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "OAuth2PasswordBearer": {
-                "type": "oauth2",
-                "flows": {"password": {"scopes": {}, "tokenUrl": "/token"}},
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_no_token():
     response = client.get("/items")
@@ -69,3 +35,35 @@ def test_incorrect_token():
     response = client.get("/items", headers={"Authorization": "Notexistent testtoken"})
     assert response.status_code == 200, response.text
     assert response.json() == {"msg": "Create an account first"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "security": [{"OAuth2PasswordBearer": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "OAuth2PasswordBearer": {
+                    "type": "oauth2",
+                    "flows": {"password": {"scopes": {}, "tokenUrl": "/token"}},
+                }
+            }
+        },
+    }
index 9d6a862e3c431bb4d65344ffc05bd9f975fb82b8..9ff48e7156dc51b394d7b92497baa05cba1bf468 100644 (file)
@@ -22,41 +22,6 @@ async def read_items(token: Optional[str] = Security(oauth2_scheme)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "security": [{"OAuth2PasswordBearer": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "OAuth2PasswordBearer": {
-                "type": "oauth2",
-                "flows": {"password": {"scopes": {}, "tokenUrl": "/token"}},
-                "description": "OAuth2PasswordBearer security scheme",
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_no_token():
     response = client.get("/items")
@@ -74,3 +39,36 @@ def test_incorrect_token():
     response = client.get("/items", headers={"Authorization": "Notexistent testtoken"})
     assert response.status_code == 200, response.text
     assert response.json() == {"msg": "Create an account first"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "security": [{"OAuth2PasswordBearer": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "OAuth2PasswordBearer": {
+                    "type": "oauth2",
+                    "flows": {"password": {"scopes": {}, "tokenUrl": "/token"}},
+                    "description": "OAuth2PasswordBearer security scheme",
+                }
+            }
+        },
+    }
index 8203961bedb015677a54fa8a9a9528b02b105e5f..206de6574f893ea637f908004d7aea7e2f8fd520 100644 (file)
@@ -24,37 +24,6 @@ def read_current_user(current_user: User = Depends(get_current_user)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"OpenIdConnect": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "OpenIdConnect": {"type": "openIdConnect", "openIdConnectUrl": "/openid"}
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_oauth2():
     response = client.get("/users/me", headers={"Authorization": "Bearer footokenbar"})
@@ -72,3 +41,35 @@ def test_security_oauth2_password_bearer_no_header():
     response = client.get("/users/me")
     assert response.status_code == 403, response.text
     assert response.json() == {"detail": "Not authenticated"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"OpenIdConnect": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "OpenIdConnect": {
+                    "type": "openIdConnect",
+                    "openIdConnectUrl": "/openid",
+                }
+            }
+        },
+    }
index 218cbfc8f7d2931a7eec8ee3a06e2a4b0220d24b..5884de79308170c2535aecf9482019df620ff035 100644 (file)
@@ -26,41 +26,6 @@ def read_current_user(current_user: User = Depends(get_current_user)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"OpenIdConnect": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "OpenIdConnect": {
-                "type": "openIdConnect",
-                "openIdConnectUrl": "/openid",
-                "description": "OpenIdConnect security scheme",
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_oauth2():
     response = client.get("/users/me", headers={"Authorization": "Bearer footokenbar"})
@@ -78,3 +43,36 @@ def test_security_oauth2_password_bearer_no_header():
     response = client.get("/users/me")
     assert response.status_code == 403, response.text
     assert response.json() == {"detail": "Not authenticated"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"OpenIdConnect": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "OpenIdConnect": {
+                    "type": "openIdConnect",
+                    "openIdConnectUrl": "/openid",
+                    "description": "OpenIdConnect security scheme",
+                }
+            }
+        },
+    }
index 4577dfebb02f4947f6378f4afaf10b374ca30f6d..8ac719118320e673dccf5623da05783cbdd96b4c 100644 (file)
@@ -30,37 +30,6 @@ def read_current_user(current_user: Optional[User] = Depends(get_current_user)):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"OpenIdConnect": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "OpenIdConnect": {"type": "openIdConnect", "openIdConnectUrl": "/openid"}
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_oauth2():
     response = client.get("/users/me", headers={"Authorization": "Bearer footokenbar"})
@@ -78,3 +47,35 @@ def test_security_oauth2_password_bearer_no_header():
     response = client.get("/users/me")
     assert response.status_code == 200, response.text
     assert response.json() == {"msg": "Create an account first"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"OpenIdConnect": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "OpenIdConnect": {
+                    "type": "openIdConnect",
+                    "openIdConnectUrl": "/openid",
+                }
+            }
+        },
+    }
index 418ddff7ddf80cadbffa05c176be496b26b358fc..96f835b935aaef44f643eff34e42ab49377b2f13 100644 (file)
@@ -37,132 +37,6 @@ async def read_starlette_item(item_id: str):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/http-no-body-statuscode-exception": {
-            "get": {
-                "operationId": "no_body_status_code_exception_http_no_body_statuscode_exception_get",
-                "responses": {
-                    "200": {
-                        "content": {"application/json": {"schema": {}}},
-                        "description": "Successful Response",
-                    }
-                },
-                "summary": "No Body Status Code Exception",
-            }
-        },
-        "/http-no-body-statuscode-with-detail-exception": {
-            "get": {
-                "operationId": "no_body_status_code_with_detail_exception_http_no_body_statuscode_with_detail_exception_get",
-                "responses": {
-                    "200": {
-                        "content": {"application/json": {"schema": {}}},
-                        "description": "Successful Response",
-                    }
-                },
-                "summary": "No Body Status Code With Detail Exception",
-            }
-        },
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/starlette-items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Starlette Item",
-                "operationId": "read_starlette_item_starlette_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_item():
     response = client.get("/items/foo")
@@ -200,3 +74,129 @@ def test_no_body_status_code_with_detail_exception_handlers():
     response = client.get("/http-no-body-statuscode-with-detail-exception")
     assert response.status_code == 204
     assert not response.content
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/http-no-body-statuscode-exception": {
+                "get": {
+                    "operationId": "no_body_status_code_exception_http_no_body_statuscode_exception_get",
+                    "responses": {
+                        "200": {
+                            "content": {"application/json": {"schema": {}}},
+                            "description": "Successful Response",
+                        }
+                    },
+                    "summary": "No Body Status Code Exception",
+                }
+            },
+            "/http-no-body-statuscode-with-detail-exception": {
+                "get": {
+                    "operationId": "no_body_status_code_with_detail_exception_http_no_body_statuscode_with_detail_exception_get",
+                    "responses": {
+                        "200": {
+                            "content": {"application/json": {"schema": {}}},
+                            "description": "Successful Response",
+                        }
+                    },
+                    "summary": "No Body Status Code With Detail Exception",
+                }
+            },
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/starlette-items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Starlette Item",
+                    "operationId": "read_starlette_item_starlette_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 7574d6fbc5fb2f190bf9754846fd26b7e0477dfd..c5a0237e8035506207b671285a463f84ed2cc2ba 100644 (file)
@@ -74,209 +74,212 @@ app.include_router(subrouter, callbacks=events_callback_router.routes)
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/invoices/": {
-            "post": {
-                "summary": "Create Invoice",
-                "description": 'Create an invoice.\n\nThis will (let\'s imagine) let the API user (some external developer) create an\ninvoice.\n\nAnd this path operation will:\n\n* Send the invoice to the client.\n* Collect the money from the client.\n* Send a notification back to the API user (the external developer), as a callback.\n    * At this point is that the API will somehow send a POST request to the\n        external API with the notification of the invoice event\n        (e.g. "payment successful").',
-                "operationId": "create_invoice_invoices__post",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Callback Url",
-                            "maxLength": 2083,
-                            "minLength": 1,
-                            "type": "string",
-                            "format": "uri",
-                        },
-                        "name": "callback_url",
-                        "in": "query",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Invoice"}
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
+
+def test_get():
+    response = client.post(
+        "/invoices/", json={"id": "fooinvoice", "customer": "John", "total": 5.3}
+    )
+    assert response.status_code == 200, response.text
+    assert response.json() == {"msg": "Invoice received"}
+
+
+def test_openapi_schema():
+    with client:
+        response = client.get("/openapi.json")
+        assert response.json() == {
+            "openapi": "3.0.2",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "paths": {
+                "/invoices/": {
+                    "post": {
+                        "summary": "Create Invoice",
+                        "description": 'Create an invoice.\n\nThis will (let\'s imagine) let the API user (some external developer) create an\ninvoice.\n\nAnd this path operation will:\n\n* Send the invoice to the client.\n* Collect the money from the client.\n* Send a notification back to the API user (the external developer), as a callback.\n    * At this point is that the API will somehow send a POST request to the\n        external API with the notification of the invoice event\n        (e.g. "payment successful").',
+                        "operationId": "create_invoice_invoices__post",
+                        "parameters": [
+                            {
+                                "required": False,
                                 "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
+                                    "title": "Callback Url",
+                                    "maxLength": 2083,
+                                    "minLength": 1,
+                                    "type": "string",
+                                    "format": "uri",
+                                },
+                                "name": "callback_url",
+                                "in": "query",
                             }
+                        ],
+                        "requestBody": {
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Invoice"}
+                                }
+                            },
+                            "required": True,
                         },
-                    },
-                },
-                "callbacks": {
-                    "event_callback": {
-                        "{$callback_url}/events/{$request.body.title}": {
-                            "get": {
-                                "summary": "Event Callback",
-                                "operationId": "event_callback__callback_url__events___request_body_title__get",
-                                "requestBody": {
-                                    "required": True,
-                                    "content": {
-                                        "application/json": {
-                                            "schema": {
-                                                "$ref": "#/components/schemas/Event"
-                                            }
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {"application/json": {"schema": {}}},
+                            },
+                            "422": {
+                                "description": "Validation Error",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/HTTPValidationError"
                                         }
-                                    },
+                                    }
                                 },
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {"application/json": {"schema": {}}},
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
+                            },
+                        },
+                        "callbacks": {
+                            "event_callback": {
+                                "{$callback_url}/events/{$request.body.title}": {
+                                    "get": {
+                                        "summary": "Event Callback",
+                                        "operationId": "event_callback__callback_url__events___request_body_title__get",
+                                        "requestBody": {
+                                            "required": True,
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/Event"
+                                                    }
                                                 }
-                                            }
+                                            },
                                         },
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "invoice_notification": {
-                        "{$callback_url}/invoices/{$request.body.id}": {
-                            "post": {
-                                "summary": "Invoice Notification",
-                                "operationId": "invoice_notification__callback_url__invoices___request_body_id__post",
-                                "requestBody": {
-                                    "required": True,
-                                    "content": {
-                                        "application/json": {
-                                            "schema": {
-                                                "$ref": "#/components/schemas/InvoiceEvent"
-                                            }
-                                        }
-                                    },
-                                },
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/InvoiceEventReceived"
-                                                }
-                                            }
+                                        "responses": {
+                                            "200": {
+                                                "description": "Successful Response",
+                                                "content": {
+                                                    "application/json": {"schema": {}}
+                                                },
+                                            },
+                                            "422": {
+                                                "description": "Validation Error",
+                                                "content": {
+                                                    "application/json": {
+                                                        "schema": {
+                                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                                        }
+                                                    }
+                                                },
+                                            },
                                         },
-                                    },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                            "invoice_notification": {
+                                "{$callback_url}/invoices/{$request.body.id}": {
+                                    "post": {
+                                        "summary": "Invoice Notification",
+                                        "operationId": "invoice_notification__callback_url__invoices___request_body_id__post",
+                                        "requestBody": {
+                                            "required": True,
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/InvoiceEvent"
+                                                    }
                                                 }
-                                            }
+                                            },
+                                        },
+                                        "responses": {
+                                            "200": {
+                                                "description": "Successful Response",
+                                                "content": {
+                                                    "application/json": {
+                                                        "schema": {
+                                                            "$ref": "#/components/schemas/InvoiceEventReceived"
+                                                        }
+                                                    }
+                                                },
+                                            },
+                                            "422": {
+                                                "description": "Validation Error",
+                                                "content": {
+                                                    "application/json": {
+                                                        "schema": {
+                                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                                        }
+                                                    }
+                                                },
+                                            },
                                         },
-                                    },
+                                    }
+                                }
+                            },
+                        },
+                    }
+                }
+            },
+            "components": {
+                "schemas": {
+                    "Event": {
+                        "title": "Event",
+                        "required": ["name", "total"],
+                        "type": "object",
+                        "properties": {
+                            "name": {"title": "Name", "type": "string"},
+                            "total": {"title": "Total", "type": "number"},
+                        },
+                    },
+                    "HTTPValidationError": {
+                        "title": "HTTPValidationError",
+                        "type": "object",
+                        "properties": {
+                            "detail": {
+                                "title": "Detail",
+                                "type": "array",
+                                "items": {
+                                    "$ref": "#/components/schemas/ValidationError"
                                 },
                             }
-                        }
+                        },
                     },
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Event": {
-                "title": "Event",
-                "required": ["name", "total"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "total": {"title": "Total", "type": "number"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "Invoice": {
-                "title": "Invoice",
-                "required": ["id", "customer", "total"],
-                "type": "object",
-                "properties": {
-                    "id": {"title": "Id", "type": "string"},
-                    "title": {"title": "Title", "type": "string"},
-                    "customer": {"title": "Customer", "type": "string"},
-                    "total": {"title": "Total", "type": "number"},
-                },
-            },
-            "InvoiceEvent": {
-                "title": "InvoiceEvent",
-                "required": ["description", "paid"],
-                "type": "object",
-                "properties": {
-                    "description": {"title": "Description", "type": "string"},
-                    "paid": {"title": "Paid", "type": "boolean"},
-                },
-            },
-            "InvoiceEventReceived": {
-                "title": "InvoiceEventReceived",
-                "required": ["ok"],
-                "type": "object",
-                "properties": {"ok": {"title": "Ok", "type": "boolean"}},
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
+                    "Invoice": {
+                        "title": "Invoice",
+                        "required": ["id", "customer", "total"],
+                        "type": "object",
+                        "properties": {
+                            "id": {"title": "Id", "type": "string"},
+                            "title": {"title": "Title", "type": "string"},
+                            "customer": {"title": "Customer", "type": "string"},
+                            "total": {"title": "Total", "type": "number"},
+                        },
                     },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
+                    "InvoiceEvent": {
+                        "title": "InvoiceEvent",
+                        "required": ["description", "paid"],
+                        "type": "object",
+                        "properties": {
+                            "description": {"title": "Description", "type": "string"},
+                            "paid": {"title": "Paid", "type": "boolean"},
+                        },
+                    },
+                    "InvoiceEventReceived": {
+                        "title": "InvoiceEventReceived",
+                        "required": ["ok"],
+                        "type": "object",
+                        "properties": {"ok": {"title": "Ok", "type": "boolean"}},
+                    },
+                    "ValidationError": {
+                        "title": "ValidationError",
+                        "required": ["loc", "msg", "type"],
+                        "type": "object",
+                        "properties": {
+                            "loc": {
+                                "title": "Location",
+                                "type": "array",
+                                "items": {
+                                    "anyOf": [{"type": "string"}, {"type": "integer"}]
+                                },
+                            },
+                            "msg": {"title": "Message", "type": "string"},
+                            "type": {"title": "Error Type", "type": "string"},
+                        },
+                    },
+                }
             },
         }
-    },
-}
-
-
-def test_openapi():
-    with client:
-        response = client.get("/openapi.json")
-
-        assert response.json() == openapi_schema
-
-
-def test_get():
-    response = client.post(
-        "/invoices/", json={"id": "fooinvoice", "customer": "John", "total": 5.3}
-    )
-    assert response.status_code == 200, response.text
-    assert response.json() == {"msg": "Invoice received"}
index 6e2cc0db676fa8830451b1abedb36e866a43ccbc..4fa1f7a133e5445a3c791986b23c49823c8504ed 100644 (file)
@@ -33,189 +33,6 @@ def hello(values: Tuple[int, int] = Form()):
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/model-with-tuple/": {
-            "post": {
-                "summary": "Post Model With Tuple",
-                "operationId": "post_model_with_tuple_model_with_tuple__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/ItemGroup"}
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/tuple-of-models/": {
-            "post": {
-                "summary": "Post Tuple Of Models",
-                "operationId": "post_tuple_of_models_tuple_of_models__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {
-                                "title": "Square",
-                                "maxItems": 2,
-                                "minItems": 2,
-                                "type": "array",
-                                "items": [
-                                    {"$ref": "#/components/schemas/Coordinate"},
-                                    {"$ref": "#/components/schemas/Coordinate"},
-                                ],
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/tuple-form/": {
-            "post": {
-                "summary": "Hello",
-                "operationId": "hello_tuple_form__post",
-                "requestBody": {
-                    "content": {
-                        "application/x-www-form-urlencoded": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_hello_tuple_form__post"
-                            }
-                        }
-                    },
-                    "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": {
-            "Body_hello_tuple_form__post": {
-                "title": "Body_hello_tuple_form__post",
-                "required": ["values"],
-                "type": "object",
-                "properties": {
-                    "values": {
-                        "title": "Values",
-                        "maxItems": 2,
-                        "minItems": 2,
-                        "type": "array",
-                        "items": [{"type": "integer"}, {"type": "integer"}],
-                    }
-                },
-            },
-            "Coordinate": {
-                "title": "Coordinate",
-                "required": ["x", "y"],
-                "type": "object",
-                "properties": {
-                    "x": {"title": "X", "type": "number"},
-                    "y": {"title": "Y", "type": "number"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ItemGroup": {
-                "title": "ItemGroup",
-                "required": ["items"],
-                "type": "object",
-                "properties": {
-                    "items": {
-                        "title": "Items",
-                        "type": "array",
-                        "items": {
-                            "maxItems": 2,
-                            "minItems": 2,
-                            "type": "array",
-                            "items": [{"type": "string"}, {"type": "string"}],
-                        },
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_model_with_tuple_valid():
     data = {"items": [["foo", "bar"], ["baz", "whatelse"]]}
@@ -263,3 +80,186 @@ def test_tuple_form_invalid():
 
     response = client.post("/tuple-form/", data={"values": ("1")})
     assert response.status_code == 422, response.text
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/model-with-tuple/": {
+                "post": {
+                    "summary": "Post Model With Tuple",
+                    "operationId": "post_model_with_tuple_model_with_tuple__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/ItemGroup"}
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/tuple-of-models/": {
+                "post": {
+                    "summary": "Post Tuple Of Models",
+                    "operationId": "post_tuple_of_models_tuple_of_models__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {
+                                    "title": "Square",
+                                    "maxItems": 2,
+                                    "minItems": 2,
+                                    "type": "array",
+                                    "items": [
+                                        {"$ref": "#/components/schemas/Coordinate"},
+                                        {"$ref": "#/components/schemas/Coordinate"},
+                                    ],
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/tuple-form/": {
+                "post": {
+                    "summary": "Hello",
+                    "operationId": "hello_tuple_form__post",
+                    "requestBody": {
+                        "content": {
+                            "application/x-www-form-urlencoded": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_hello_tuple_form__post"
+                                }
+                            }
+                        },
+                        "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": {
+                "Body_hello_tuple_form__post": {
+                    "title": "Body_hello_tuple_form__post",
+                    "required": ["values"],
+                    "type": "object",
+                    "properties": {
+                        "values": {
+                            "title": "Values",
+                            "maxItems": 2,
+                            "minItems": 2,
+                            "type": "array",
+                            "items": [{"type": "integer"}, {"type": "integer"}],
+                        }
+                    },
+                },
+                "Coordinate": {
+                    "title": "Coordinate",
+                    "required": ["x", "y"],
+                    "type": "object",
+                    "properties": {
+                        "x": {"title": "X", "type": "number"},
+                        "y": {"title": "Y", "type": "number"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ItemGroup": {
+                    "title": "ItemGroup",
+                    "required": ["items"],
+                    "type": "object",
+                    "properties": {
+                        "items": {
+                            "title": "Items",
+                            "type": "array",
+                            "items": {
+                                "maxItems": 2,
+                                "minItems": 2,
+                                "type": "array",
+                                "items": [{"type": "string"}, {"type": "string"}],
+                            },
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 1a8acb523154f576ff17270c74a0de21d30a781a..3d6267023e246aac82c4e08fca6847fa921a2335 100644 (file)
@@ -4,105 +4,6 @@ from docs_src.additional_responses.tutorial001 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "404": {
-                        "description": "Not Found",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Message"}
-                            }
-                        },
-                    },
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["id", "value"],
-                "type": "object",
-                "properties": {
-                    "id": {"title": "Id", "type": "string"},
-                    "value": {"title": "Value", "type": "string"},
-                },
-            },
-            "Message": {
-                "title": "Message",
-                "required": ["message"],
-                "type": "object",
-                "properties": {"message": {"title": "Message", "type": "string"}},
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_path_operation():
     response = client.get("/items/foo")
@@ -114,3 +15,102 @@ def test_path_operation_not_found():
     response = client.get("/items/bar")
     assert response.status_code == 404, response.text
     assert response.json() == {"message": "Item not found"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "404": {
+                            "description": "Not Found",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Message"}
+                                }
+                            },
+                        },
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["id", "value"],
+                    "type": "object",
+                    "properties": {
+                        "id": {"title": "Id", "type": "string"},
+                        "value": {"title": "Value", "type": "string"},
+                    },
+                },
+                "Message": {
+                    "title": "Message",
+                    "required": ["message"],
+                    "type": "object",
+                    "properties": {"message": {"title": "Message", "type": "string"}},
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 2adcf15d07f5121c4dc147ede5a58c0bf07cb9c3..6182ed5079025221eba51cacb3ac6ece77eddd15 100644 (file)
@@ -7,98 +7,6 @@ from docs_src.additional_responses.tutorial002 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Return the JSON item or an image.",
-                        "content": {
-                            "image/png": {},
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            },
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Img", "type": "boolean"},
-                        "name": "img",
-                        "in": "query",
-                    },
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["id", "value"],
-                "type": "object",
-                "properties": {
-                    "id": {"title": "Id", "type": "string"},
-                    "value": {"title": "Value", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_path_operation():
     response = client.get("/items/foo")
@@ -113,3 +21,95 @@ def test_path_operation_img():
     assert response.headers["Content-Type"] == "image/png"
     assert len(response.content)
     os.remove("./image.png")
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Return the JSON item or an image.",
+                            "content": {
+                                "image/png": {},
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                },
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        },
+                        {
+                            "required": False,
+                            "schema": {"title": "Img", "type": "boolean"},
+                            "name": "img",
+                            "in": "query",
+                        },
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["id", "value"],
+                    "type": "object",
+                    "properties": {
+                        "id": {"title": "Id", "type": "string"},
+                        "value": {"title": "Value", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 8b2167de0513c379e953358d41da6a669649d85c..77568d9d4f2166e7be6ceee576d9bd55ba27dd12 100644 (file)
@@ -4,106 +4,6 @@ from docs_src.additional_responses.tutorial003 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "404": {
-                        "description": "The item was not found",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Message"}
-                            }
-                        },
-                    },
-                    "200": {
-                        "description": "Item requested by ID",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"},
-                                "example": {"id": "bar", "value": "The bar tenders"},
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["id", "value"],
-                "type": "object",
-                "properties": {
-                    "id": {"title": "Id", "type": "string"},
-                    "value": {"title": "Value", "type": "string"},
-                },
-            },
-            "Message": {
-                "title": "Message",
-                "required": ["message"],
-                "type": "object",
-                "properties": {"message": {"title": "Message", "type": "string"}},
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_path_operation():
     response = client.get("/items/foo")
@@ -115,3 +15,106 @@ def test_path_operation_not_found():
     response = client.get("/items/bar")
     assert response.status_code == 404, response.text
     assert response.json() == {"message": "Item not found"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "404": {
+                            "description": "The item was not found",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Message"}
+                                }
+                            },
+                        },
+                        "200": {
+                            "description": "Item requested by ID",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"},
+                                    "example": {
+                                        "id": "bar",
+                                        "value": "The bar tenders",
+                                    },
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["id", "value"],
+                    "type": "object",
+                    "properties": {
+                        "id": {"title": "Id", "type": "string"},
+                        "value": {"title": "Value", "type": "string"},
+                    },
+                },
+                "Message": {
+                    "title": "Message",
+                    "required": ["message"],
+                    "type": "object",
+                    "properties": {"message": {"title": "Message", "type": "string"}},
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 990d5235aa1049786dcebd4a449aefb78dd75cda..3fbd91e5c2a3ca6bae7616e11a0232153f751d55 100644 (file)
@@ -7,101 +7,6 @@ from docs_src.additional_responses.tutorial004 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "404": {"description": "Item not found"},
-                    "302": {"description": "The item was moved"},
-                    "403": {"description": "Not enough privileges"},
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "image/png": {},
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            },
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Img", "type": "boolean"},
-                        "name": "img",
-                        "in": "query",
-                    },
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["id", "value"],
-                "type": "object",
-                "properties": {
-                    "id": {"title": "Id", "type": "string"},
-                    "value": {"title": "Value", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_path_operation():
     response = client.get("/items/foo")
@@ -116,3 +21,98 @@ def test_path_operation_img():
     assert response.headers["Content-Type"] == "image/png"
     assert len(response.content)
     os.remove("./image.png")
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "404": {"description": "Item not found"},
+                        "302": {"description": "The item was moved"},
+                        "403": {"description": "Not enough privileges"},
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "image/png": {},
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                },
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        },
+                        {
+                            "required": False,
+                            "schema": {"title": "Img", "type": "boolean"},
+                            "name": "img",
+                            "in": "query",
+                        },
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["id", "value"],
+                    "type": "object",
+                    "properties": {
+                        "id": {"title": "Id", "type": "string"},
+                        "value": {"title": "Value", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 1ad625db6a7a63ce970bc021b3df5f115f66ab46..3da362a50588ea611dd086ba4b33f77d31da16fc 100644 (file)
@@ -2,120 +2,6 @@ from fastapi.testclient import TestClient
 
 from docs_src.async_sql_databases.tutorial001 import app
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/notes/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Notes Notes  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/Note"},
-                                }
-                            }
-                        },
-                    }
-                },
-                "summary": "Read Notes",
-                "operationId": "read_notes_notes__get",
-            },
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Note"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Note",
-                "operationId": "create_note_notes__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/NoteIn"}
-                        }
-                    },
-                    "required": True,
-                },
-            },
-        }
-    },
-    "components": {
-        "schemas": {
-            "NoteIn": {
-                "title": "NoteIn",
-                "required": ["text", "completed"],
-                "type": "object",
-                "properties": {
-                    "text": {"title": "Text", "type": "string"},
-                    "completed": {"title": "Completed", "type": "boolean"},
-                },
-            },
-            "Note": {
-                "title": "Note",
-                "required": ["id", "text", "completed"],
-                "type": "object",
-                "properties": {
-                    "id": {"title": "Id", "type": "integer"},
-                    "text": {"title": "Text", "type": "string"},
-                    "completed": {"title": "Completed", "type": "boolean"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    with TestClient(app) as client:
-        response = client.get("/openapi.json")
-        assert response.status_code == 200, response.text
-        assert response.json() == openapi_schema
-
 
 def test_create_read():
     with TestClient(app) as client:
@@ -129,3 +15,121 @@ def test_create_read():
         response = client.get("/notes/")
         assert response.status_code == 200, response.text
         assert data in response.json()
+
+
+def test_openapi_schema():
+    with TestClient(app) as client:
+        response = client.get("/openapi.json")
+        assert response.status_code == 200, response.text
+        assert response.json() == {
+            "openapi": "3.0.2",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "paths": {
+                "/notes/": {
+                    "get": {
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "title": "Response Read Notes Notes  Get",
+                                            "type": "array",
+                                            "items": {
+                                                "$ref": "#/components/schemas/Note"
+                                            },
+                                        }
+                                    }
+                                },
+                            }
+                        },
+                        "summary": "Read Notes",
+                        "operationId": "read_notes_notes__get",
+                    },
+                    "post": {
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {"$ref": "#/components/schemas/Note"}
+                                    }
+                                },
+                            },
+                            "422": {
+                                "description": "Validation Error",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                        }
+                                    }
+                                },
+                            },
+                        },
+                        "summary": "Create Note",
+                        "operationId": "create_note_notes__post",
+                        "requestBody": {
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/NoteIn"}
+                                }
+                            },
+                            "required": True,
+                        },
+                    },
+                }
+            },
+            "components": {
+                "schemas": {
+                    "NoteIn": {
+                        "title": "NoteIn",
+                        "required": ["text", "completed"],
+                        "type": "object",
+                        "properties": {
+                            "text": {"title": "Text", "type": "string"},
+                            "completed": {"title": "Completed", "type": "boolean"},
+                        },
+                    },
+                    "Note": {
+                        "title": "Note",
+                        "required": ["id", "text", "completed"],
+                        "type": "object",
+                        "properties": {
+                            "id": {"title": "Id", "type": "integer"},
+                            "text": {"title": "Text", "type": "string"},
+                            "completed": {"title": "Completed", "type": "boolean"},
+                        },
+                    },
+                    "ValidationError": {
+                        "title": "ValidationError",
+                        "required": ["loc", "msg", "type"],
+                        "type": "object",
+                        "properties": {
+                            "loc": {
+                                "title": "Location",
+                                "type": "array",
+                                "items": {
+                                    "anyOf": [{"type": "string"}, {"type": "integer"}]
+                                },
+                            },
+                            "msg": {"title": "Message", "type": "string"},
+                            "type": {"title": "Error Type", "type": "string"},
+                        },
+                    },
+                    "HTTPValidationError": {
+                        "title": "HTTPValidationError",
+                        "type": "object",
+                        "properties": {
+                            "detail": {
+                                "title": "Detail",
+                                "type": "array",
+                                "items": {
+                                    "$ref": "#/components/schemas/ValidationError"
+                                },
+                            }
+                        },
+                    },
+                }
+            },
+        }
index be9e499bf8f1d13f8f61b773bb8e3f3b7ca22636..7533a1b689e76737652a23e4ed54140800d4d231 100644 (file)
@@ -4,34 +4,32 @@ from docs_src.behind_a_proxy.tutorial001 import app
 
 client = TestClient(app, root_path="/api/v1")
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/app": {
-            "get": {
-                "summary": "Read Main",
-                "operationId": "read_main_app_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        }
-    },
-    "servers": [{"url": "/api/v1"}],
-}
-
-
-def test_openapi():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200
-    assert response.json() == openapi_schema
-
 
 def test_main():
     response = client.get("/app")
     assert response.status_code == 200
     assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}
+
+
+def test_openapi():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/app": {
+                "get": {
+                    "summary": "Read Main",
+                    "operationId": "read_main_app_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            }
+        },
+        "servers": [{"url": "/api/v1"}],
+    }
index ac192e3db769b58f955dc04c8fc3f27b7f92b67a..930ab3bf5c7d7359330823856c1df019f0cbdd92 100644 (file)
@@ -4,34 +4,32 @@ from docs_src.behind_a_proxy.tutorial002 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/app": {
-            "get": {
-                "summary": "Read Main",
-                "operationId": "read_main_app_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        }
-    },
-    "servers": [{"url": "/api/v1"}],
-}
-
-
-def test_openapi():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200
-    assert response.json() == openapi_schema
-
 
 def test_main():
     response = client.get("/app")
     assert response.status_code == 200
     assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}
+
+
+def test_openapi():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/app": {
+                "get": {
+                    "summary": "Read Main",
+                    "operationId": "read_main_app_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            }
+        },
+        "servers": [{"url": "/api/v1"}],
+    }
index 2727525ca498d0a9fe0beca818e2cdb36b79f636..ae8f1a495dda6a57cfa9f06b128c100a77c2be99 100644 (file)
@@ -4,38 +4,39 @@ from docs_src.behind_a_proxy.tutorial003 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "servers": [
-        {"url": "/api/v1"},
-        {"url": "https://stag.example.com", "description": "Staging environment"},
-        {"url": "https://prod.example.com", "description": "Production environment"},
-    ],
-    "paths": {
-        "/app": {
-            "get": {
-                "summary": "Read Main",
-                "operationId": "read_main_app_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        }
-    },
-}
-
-
-def test_openapi():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200
-    assert response.json() == openapi_schema
-
 
 def test_main():
     response = client.get("/app")
     assert response.status_code == 200
     assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}
+
+
+def test_openapi():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "servers": [
+            {"url": "/api/v1"},
+            {"url": "https://stag.example.com", "description": "Staging environment"},
+            {
+                "url": "https://prod.example.com",
+                "description": "Production environment",
+            },
+        ],
+        "paths": {
+            "/app": {
+                "get": {
+                    "summary": "Read Main",
+                    "operationId": "read_main_app_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            }
+        },
+    }
index 4c4e4b75c264e216b83e8419e7e392d37a430ee6..e67ad1cb1fc0723de9bbac62d683f6e17fb087d4 100644 (file)
@@ -4,37 +4,38 @@ from docs_src.behind_a_proxy.tutorial004 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "servers": [
-        {"url": "https://stag.example.com", "description": "Staging environment"},
-        {"url": "https://prod.example.com", "description": "Production environment"},
-    ],
-    "paths": {
-        "/app": {
-            "get": {
-                "summary": "Read Main",
-                "operationId": "read_main_app_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        }
-    },
-}
-
-
-def test_openapi():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200
-    assert response.json() == openapi_schema
-
 
 def test_main():
     response = client.get("/app")
     assert response.status_code == 200
     assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}
+
+
+def test_openapi():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "servers": [
+            {"url": "https://stag.example.com", "description": "Staging environment"},
+            {
+                "url": "https://prod.example.com",
+                "description": "Production environment",
+            },
+        ],
+        "paths": {
+            "/app": {
+                "get": {
+                    "summary": "Read Main",
+                    "operationId": "read_main_app_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            }
+        },
+    }
index cd6d7b5c8b0d94af13beafa9b7df77f81fd3b1cf..a13decd75b86dfebd64e437142c600f6be93054f 100644 (file)
@@ -5,334 +5,6 @@ from docs_src.bigger_applications.app.main import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/": {
-            "get": {
-                "tags": ["users"],
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/users/me": {
-            "get": {
-                "tags": ["users"],
-                "summary": "Read User Me",
-                "operationId": "read_user_me_users_me_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/users/{username}": {
-            "get": {
-                "tags": ["users"],
-                "summary": "Read User",
-                "operationId": "read_user_users__username__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Username", "type": "string"},
-                        "name": "username",
-                        "in": "path",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/items/": {
-            "get": {
-                "tags": ["items"],
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "404": {"description": "Not found"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/items/{item_id}": {
-            "get": {
-                "tags": ["items"],
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "404": {"description": "Not found"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            },
-            "put": {
-                "tags": ["items", "custom"],
-                "summary": "Update Item",
-                "operationId": "update_item_items__item_id__put",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "404": {"description": "Not found"},
-                    "403": {"description": "Operation forbidden"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            },
-        },
-        "/admin/": {
-            "post": {
-                "tags": ["admin"],
-                "summary": "Update Admin",
-                "operationId": "update_admin_admin__post",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "418": {"description": "I'm a teapot"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/": {
-            "get": {
-                "summary": "Root",
-                "operationId": "root__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    }
-                ],
-                "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 no_jessica = {
     "detail": [
@@ -427,7 +99,6 @@ no_jessica = {
         ),
         ("/?token=jessica", 200, {"message": "Hello Bigger Applications!"}, {}),
         ("/", 422, no_jessica, {}),
-        ("/openapi.json", 200, openapi_schema, {}),
     ],
 )
 def test_get_path(path, expected_status, expected_response, headers):
@@ -489,3 +160,337 @@ def test_admin_invalid_header():
     response = client.post("/admin/", headers={"X-Token": "invalid"})
     assert response.status_code == 400, response.text
     assert response.json() == {"detail": "X-Token header invalid"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/": {
+                "get": {
+                    "tags": ["users"],
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/users/me": {
+                "get": {
+                    "tags": ["users"],
+                    "summary": "Read User Me",
+                    "operationId": "read_user_me_users_me_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/users/{username}": {
+                "get": {
+                    "tags": ["users"],
+                    "summary": "Read User",
+                    "operationId": "read_user_users__username__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Username", "type": "string"},
+                            "name": "username",
+                            "in": "path",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/items/": {
+                "get": {
+                    "tags": ["items"],
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "404": {"description": "Not found"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/items/{item_id}": {
+                "get": {
+                    "tags": ["items"],
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "404": {"description": "Not found"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                },
+                "put": {
+                    "tags": ["items", "custom"],
+                    "summary": "Update Item",
+                    "operationId": "update_item_items__item_id__put",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "404": {"description": "Not found"},
+                        "403": {"description": "Operation forbidden"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                },
+            },
+            "/admin/": {
+                "post": {
+                    "tags": ["admin"],
+                    "summary": "Update Admin",
+                    "operationId": "update_admin_admin__post",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "418": {"description": "I'm a teapot"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/": {
+                "get": {
+                    "summary": "Root",
+                    "operationId": "root__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        }
+                    ],
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 4b84a31b57e10df006b0819fe807325f227e626c..64e19c3f391c0b2f40b36c2aedd9465443f6e064 100644 (file)
@@ -5,334 +5,6 @@ from docs_src.bigger_applications.app_an.main import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/": {
-            "get": {
-                "tags": ["users"],
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/users/me": {
-            "get": {
-                "tags": ["users"],
-                "summary": "Read User Me",
-                "operationId": "read_user_me_users_me_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/users/{username}": {
-            "get": {
-                "tags": ["users"],
-                "summary": "Read User",
-                "operationId": "read_user_users__username__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Username", "type": "string"},
-                        "name": "username",
-                        "in": "path",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/items/": {
-            "get": {
-                "tags": ["items"],
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "404": {"description": "Not found"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/items/{item_id}": {
-            "get": {
-                "tags": ["items"],
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "404": {"description": "Not found"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            },
-            "put": {
-                "tags": ["items", "custom"],
-                "summary": "Update Item",
-                "operationId": "update_item_items__item_id__put",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "404": {"description": "Not found"},
-                    "403": {"description": "Operation forbidden"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            },
-        },
-        "/admin/": {
-            "post": {
-                "tags": ["admin"],
-                "summary": "Update Admin",
-                "operationId": "update_admin_admin__post",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "418": {"description": "I'm a teapot"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/": {
-            "get": {
-                "summary": "Root",
-                "operationId": "root__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    }
-                ],
-                "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 no_jessica = {
     "detail": [
@@ -427,7 +99,6 @@ no_jessica = {
         ),
         ("/?token=jessica", 200, {"message": "Hello Bigger Applications!"}, {}),
         ("/", 422, no_jessica, {}),
-        ("/openapi.json", 200, openapi_schema, {}),
     ],
 )
 def test_get_path(path, expected_status, expected_response, headers):
@@ -489,3 +160,337 @@ def test_admin_invalid_header():
     response = client.post("/admin/", headers={"X-Token": "invalid"})
     assert response.status_code == 400, response.text
     assert response.json() == {"detail": "X-Token header invalid"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/": {
+                "get": {
+                    "tags": ["users"],
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/users/me": {
+                "get": {
+                    "tags": ["users"],
+                    "summary": "Read User Me",
+                    "operationId": "read_user_me_users_me_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/users/{username}": {
+                "get": {
+                    "tags": ["users"],
+                    "summary": "Read User",
+                    "operationId": "read_user_users__username__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Username", "type": "string"},
+                            "name": "username",
+                            "in": "path",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/items/": {
+                "get": {
+                    "tags": ["items"],
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "404": {"description": "Not found"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/items/{item_id}": {
+                "get": {
+                    "tags": ["items"],
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "404": {"description": "Not found"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                },
+                "put": {
+                    "tags": ["items", "custom"],
+                    "summary": "Update Item",
+                    "operationId": "update_item_items__item_id__put",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "404": {"description": "Not found"},
+                        "403": {"description": "Operation forbidden"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                },
+            },
+            "/admin/": {
+                "post": {
+                    "tags": ["admin"],
+                    "summary": "Update Admin",
+                    "operationId": "update_admin_admin__post",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "418": {"description": "I'm a teapot"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/": {
+                "get": {
+                    "summary": "Root",
+                    "operationId": "root__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        }
+                    ],
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 1caf5bd49b198111a3141e26589cf035f0175ca4..70c86b4d7f2001f1abdb043a878d9666dc4fa990 100644 (file)
@@ -3,335 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/": {
-            "get": {
-                "tags": ["users"],
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/users/me": {
-            "get": {
-                "tags": ["users"],
-                "summary": "Read User Me",
-                "operationId": "read_user_me_users_me_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/users/{username}": {
-            "get": {
-                "tags": ["users"],
-                "summary": "Read User",
-                "operationId": "read_user_users__username__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Username", "type": "string"},
-                        "name": "username",
-                        "in": "path",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/items/": {
-            "get": {
-                "tags": ["items"],
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "404": {"description": "Not found"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/items/{item_id}": {
-            "get": {
-                "tags": ["items"],
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "404": {"description": "Not found"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            },
-            "put": {
-                "tags": ["items", "custom"],
-                "summary": "Update Item",
-                "operationId": "update_item_items__item_id__put",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "404": {"description": "Not found"},
-                    "403": {"description": "Operation forbidden"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            },
-        },
-        "/admin/": {
-            "post": {
-                "tags": ["admin"],
-                "summary": "Update Admin",
-                "operationId": "update_admin_admin__post",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "418": {"description": "I'm a teapot"},
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/": {
-            "get": {
-                "summary": "Root",
-                "operationId": "root__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Token", "type": "string"},
-                        "name": "token",
-                        "in": "query",
-                    }
-                ],
-                "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
 no_jessica = {
     "detail": [
         {
@@ -434,7 +105,6 @@ def get_client():
         ),
         ("/?token=jessica", 200, {"message": "Hello Bigger Applications!"}, {}),
         ("/", 422, no_jessica, {}),
-        ("/openapi.json", 200, openapi_schema, {}),
     ],
 )
 def test_get_path(
@@ -504,3 +174,338 @@ def test_admin_invalid_header(client: TestClient):
     response = client.post("/admin/", headers={"X-Token": "invalid"})
     assert response.status_code == 400, response.text
     assert response.json() == {"detail": "X-Token header invalid"}
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/": {
+                "get": {
+                    "tags": ["users"],
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/users/me": {
+                "get": {
+                    "tags": ["users"],
+                    "summary": "Read User Me",
+                    "operationId": "read_user_me_users_me_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/users/{username}": {
+                "get": {
+                    "tags": ["users"],
+                    "summary": "Read User",
+                    "operationId": "read_user_users__username__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Username", "type": "string"},
+                            "name": "username",
+                            "in": "path",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/items/": {
+                "get": {
+                    "tags": ["items"],
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "404": {"description": "Not found"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/items/{item_id}": {
+                "get": {
+                    "tags": ["items"],
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "404": {"description": "Not found"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                },
+                "put": {
+                    "tags": ["items", "custom"],
+                    "summary": "Update Item",
+                    "operationId": "update_item_items__item_id__put",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "404": {"description": "Not found"},
+                        "403": {"description": "Operation forbidden"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                },
+            },
+            "/admin/": {
+                "post": {
+                    "tags": ["admin"],
+                    "summary": "Update Admin",
+                    "operationId": "update_admin_admin__post",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "418": {"description": "I'm a teapot"},
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/": {
+                "get": {
+                    "summary": "Root",
+                    "operationId": "root__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Token", "type": "string"},
+                            "name": "token",
+                            "in": "query",
+                        }
+                    ],
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 65cdc758adc0052cc0957ada290053211bff81f9..cd1209adea5aae6050c3e3c928d1a4511cfb7025 100644 (file)
@@ -7,89 +7,6 @@ from docs_src.body.tutorial001 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Item",
-                "operationId": "create_item_items__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 price_missing = {
     "detail": [
@@ -277,3 +194,86 @@ def test_other_exceptions():
     with patch("json.loads", side_effect=Exception):
         response = client.post("/items/", json={"test": "test2"})
         assert response.status_code == 400, response.text
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Item",
+                    "operationId": "create_item_items__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 83bcb68f30d85161128945cbd8ebe5b963217e8a..5ebcbbf574aa720f80cf72df8a02508045ae087d 100644 (file)
@@ -5,83 +5,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Item",
-                "operationId": "create_item_items__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture
 def client():
@@ -91,13 +14,6 @@ def client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 price_missing = {
     "detail": [
         {
@@ -292,3 +208,87 @@ def test_other_exceptions(client: TestClient):
     with patch("json.loads", side_effect=Exception):
         response = client.post("/items/", json={"test": "test2"})
         assert response.status_code == 400, response.text
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Item",
+                    "operationId": "create_item_items__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index fe5a270f3611d4d2a724b1eff7b04872a45d06e2..a7ea0e9496664717c1c4bbfcd32994ed2262d6ba 100644 (file)
@@ -6,115 +6,6 @@ from docs_src.body_fields.tutorial001 import app
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "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/Body_update_item_items__item_id__put"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {
-                        "title": "The description of the item",
-                        "maxLength": 300,
-                        "type": "string",
-                    },
-                    "price": {
-                        "title": "Price",
-                        "exclusiveMinimum": 0.0,
-                        "type": "number",
-                        "description": "The price must be greater than zero",
-                    },
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "Body_update_item_items__item_id__put": {
-                "title": "Body_update_item_items__item_id__put",
-                "required": ["item"],
-                "type": "object",
-                "properties": {"item": {"$ref": "#/components/schemas/Item"}},
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 price_not_greater = {
     "detail": [
         {
@@ -167,3 +58,111 @@ def test(path, body, expected_status, expected_response):
     response = client.put(path, json=body)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "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/Body_update_item_items__item_id__put"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {
+                            "title": "The description of the item",
+                            "maxLength": 300,
+                            "type": "string",
+                        },
+                        "price": {
+                            "title": "Price",
+                            "exclusiveMinimum": 0.0,
+                            "type": "number",
+                            "description": "The price must be greater than zero",
+                        },
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "Body_update_item_items__item_id__put": {
+                    "title": "Body_update_item_items__item_id__put",
+                    "required": ["item"],
+                    "type": "object",
+                    "properties": {"item": {"$ref": "#/components/schemas/Item"}},
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 8797691475e5be5b6fe5b4798f69fb3c4dcb1964..32f996ecbd5d5d4b054abce645e287b910fff98a 100644 (file)
@@ -6,115 +6,6 @@ from docs_src.body_fields.tutorial001_an import app
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "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/Body_update_item_items__item_id__put"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {
-                        "title": "The description of the item",
-                        "maxLength": 300,
-                        "type": "string",
-                    },
-                    "price": {
-                        "title": "Price",
-                        "exclusiveMinimum": 0.0,
-                        "type": "number",
-                        "description": "The price must be greater than zero",
-                    },
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "Body_update_item_items__item_id__put": {
-                "title": "Body_update_item_items__item_id__put",
-                "required": ["item"],
-                "type": "object",
-                "properties": {"item": {"$ref": "#/components/schemas/Item"}},
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 price_not_greater = {
     "detail": [
         {
@@ -167,3 +58,111 @@ def test(path, body, expected_status, expected_response):
     response = client.put(path, json=body)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "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/Body_update_item_items__item_id__put"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {
+                            "title": "The description of the item",
+                            "maxLength": 300,
+                            "type": "string",
+                        },
+                        "price": {
+                            "title": "Price",
+                            "exclusiveMinimum": 0.0,
+                            "type": "number",
+                            "description": "The price must be greater than zero",
+                        },
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "Body_update_item_items__item_id__put": {
+                    "title": "Body_update_item_items__item_id__put",
+                    "required": ["item"],
+                    "type": "object",
+                    "properties": {"item": {"$ref": "#/components/schemas/Item"}},
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 0cd57a18746e5980a9069597c0da6d8ce5137bc0..20e032fcd8a0540cac20b32a9397f063ae655103 100644 (file)
@@ -3,108 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "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/Body_update_item_items__item_id__put"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {
-                        "title": "The description of the item",
-                        "maxLength": 300,
-                        "type": "string",
-                    },
-                    "price": {
-                        "title": "Price",
-                        "exclusiveMinimum": 0.0,
-                        "type": "number",
-                        "description": "The price must be greater than zero",
-                    },
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "Body_update_item_items__item_id__put": {
-                "title": "Body_update_item_items__item_id__put",
-                "required": ["item"],
-                "type": "object",
-                "properties": {"item": {"$ref": "#/components/schemas/Item"}},
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -114,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 price_not_greater = {
     "detail": [
         {
@@ -174,3 +65,112 @@ def test(path, body, expected_status, expected_response, client: TestClient):
     response = client.put(path, json=body)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "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/Body_update_item_items__item_id__put"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {
+                            "title": "The description of the item",
+                            "maxLength": 300,
+                            "type": "string",
+                        },
+                        "price": {
+                            "title": "Price",
+                            "exclusiveMinimum": 0.0,
+                            "type": "number",
+                            "description": "The price must be greater than zero",
+                        },
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "Body_update_item_items__item_id__put": {
+                    "title": "Body_update_item_items__item_id__put",
+                    "required": ["item"],
+                    "type": "object",
+                    "properties": {"item": {"$ref": "#/components/schemas/Item"}},
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 26ff26f503af6994b824b07bd1d0ca90ed9ee63b..e3baf5f2badf932d1e86d30fee8beb1ee8e8c54f 100644 (file)
@@ -3,108 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "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/Body_update_item_items__item_id__put"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {
-                        "title": "The description of the item",
-                        "maxLength": 300,
-                        "type": "string",
-                    },
-                    "price": {
-                        "title": "Price",
-                        "exclusiveMinimum": 0.0,
-                        "type": "number",
-                        "description": "The price must be greater than zero",
-                    },
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "Body_update_item_items__item_id__put": {
-                "title": "Body_update_item_items__item_id__put",
-                "required": ["item"],
-                "type": "object",
-                "properties": {"item": {"$ref": "#/components/schemas/Item"}},
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -114,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 price_not_greater = {
     "detail": [
         {
@@ -174,3 +65,112 @@ def test(path, body, expected_status, expected_response, client: TestClient):
     response = client.put(path, json=body)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "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/Body_update_item_items__item_id__put"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {
+                            "title": "The description of the item",
+                            "maxLength": 300,
+                            "type": "string",
+                        },
+                        "price": {
+                            "title": "Price",
+                            "exclusiveMinimum": 0.0,
+                            "type": "number",
+                            "description": "The price must be greater than zero",
+                        },
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "Body_update_item_items__item_id__put": {
+                    "title": "Body_update_item_items__item_id__put",
+                    "required": ["item"],
+                    "type": "object",
+                    "properties": {"item": {"$ref": "#/components/schemas/Item"}},
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 993e2a91d28367dccc212127d630621ad501d3e9..4c2f48674a7a3e3acbb0443447c1155896357e85 100644 (file)
@@ -3,108 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "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/Body_update_item_items__item_id__put"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {
-                        "title": "The description of the item",
-                        "maxLength": 300,
-                        "type": "string",
-                    },
-                    "price": {
-                        "title": "Price",
-                        "exclusiveMinimum": 0.0,
-                        "type": "number",
-                        "description": "The price must be greater than zero",
-                    },
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "Body_update_item_items__item_id__put": {
-                "title": "Body_update_item_items__item_id__put",
-                "required": ["item"],
-                "type": "object",
-                "properties": {"item": {"$ref": "#/components/schemas/Item"}},
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -114,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 price_not_greater = {
     "detail": [
         {
@@ -174,3 +65,112 @@ def test(path, body, expected_status, expected_response, client: TestClient):
     response = client.put(path, json=body)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "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/Body_update_item_items__item_id__put"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {
+                            "title": "The description of the item",
+                            "maxLength": 300,
+                            "type": "string",
+                        },
+                        "price": {
+                            "title": "Price",
+                            "exclusiveMinimum": 0.0,
+                            "type": "number",
+                            "description": "The price must be greater than zero",
+                        },
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "Body_update_item_items__item_id__put": {
+                    "title": "Body_update_item_items__item_id__put",
+                    "required": ["item"],
+                    "type": "object",
+                    "properties": {"item": {"$ref": "#/components/schemas/Item"}},
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 8dc710d7551830691408ed0c409ef24bb6d8a5f2..496ab38fb97a60edab50150379d75f3273ed190f 100644 (file)
@@ -5,107 +5,6 @@ from docs_src.body_multiple_params.tutorial001 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Update Item",
-                "operationId": "update_item_items__item_id__put",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "The ID of the item to get",
-                            "maximum": 1000.0,
-                            "minimum": 0.0,
-                            "type": "integer",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    }
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 item_id_not_int = {
     "detail": [
@@ -145,3 +44,104 @@ def test_post_body(path, body, expected_status, expected_response):
     response = client.put(path, json=body)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Update Item",
+                    "operationId": "update_item_items__item_id__put",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "The ID of the item to get",
+                                "maximum": 1000.0,
+                                "minimum": 0.0,
+                                "type": "integer",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        },
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        }
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 94ba8593aec8e974686711dc2bda84794710a0e5..74a8a9b2e4a4fc8200674c9f2d98a83c3494bd8c 100644 (file)
@@ -5,107 +5,6 @@ from docs_src.body_multiple_params.tutorial001_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Update Item",
-                "operationId": "update_item_items__item_id__put",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "The ID of the item to get",
-                            "maximum": 1000.0,
-                            "minimum": 0.0,
-                            "type": "integer",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    }
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 item_id_not_int = {
     "detail": [
@@ -145,3 +44,104 @@ def test_post_body(path, body, expected_status, expected_response):
     response = client.put(path, json=body)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Update Item",
+                    "operationId": "update_item_items__item_id__put",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "The ID of the item to get",
+                                "maximum": 1000.0,
+                                "minimum": 0.0,
+                                "type": "integer",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        },
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        }
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index cd378ec9cb982f389f043f38b18c9939d7091255..9c764b6d177fbf353d94136f9eb7595993393eb7 100644 (file)
@@ -3,101 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Update Item",
-                "operationId": "update_item_items__item_id__put",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "The ID of the item to get",
-                            "maximum": 1000.0,
-                            "minimum": 0.0,
-                            "type": "integer",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    }
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -107,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 item_id_not_int = {
     "detail": [
         {
@@ -153,3 +51,105 @@ def test_post_body(path, body, expected_status, expected_response, client: TestC
     response = client.put(path, json=body)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Update Item",
+                    "operationId": "update_item_items__item_id__put",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "The ID of the item to get",
+                                "maximum": 1000.0,
+                                "minimum": 0.0,
+                                "type": "integer",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        },
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        }
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index b8fe1baaf330e2f6adbff13f6fd314e34dc0a461..0cca294333b53557f0f7df967a7ca095badc3239 100644 (file)
@@ -3,101 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Update Item",
-                "operationId": "update_item_items__item_id__put",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "The ID of the item to get",
-                            "maximum": 1000.0,
-                            "minimum": 0.0,
-                            "type": "integer",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    }
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -107,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 item_id_not_int = {
     "detail": [
         {
@@ -153,3 +51,105 @@ def test_post_body(path, body, expected_status, expected_response, client: TestC
     response = client.put(path, json=body)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Update Item",
+                    "operationId": "update_item_items__item_id__put",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "The ID of the item to get",
+                                "maximum": 1000.0,
+                                "minimum": 0.0,
+                                "type": "integer",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        },
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        }
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 5114ccea29ff03f27bc188a648c9fed00bfde028..3b61e717ec399a4d34312c186fb88ca130779af7 100644 (file)
@@ -3,101 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Update Item",
-                "operationId": "update_item_items__item_id__put",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "The ID of the item to get",
-                            "maximum": 1000.0,
-                            "minimum": 0.0,
-                            "type": "integer",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    }
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -107,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 item_id_not_int = {
     "detail": [
         {
@@ -153,3 +51,105 @@ def test_post_body(path, body, expected_status, expected_response, client: TestC
     response = client.put(path, json=body)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Update Item",
+                    "operationId": "update_item_items__item_id__put",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "The ID of the item to get",
+                                "maximum": 1000.0,
+                                "minimum": 0.0,
+                                "type": "integer",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        },
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        }
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 64aa9c43bf3f3da7d631dd2ccd0c5b5b05b94b68..b34377a28c3577362af46d56360b2349457b58ee 100644 (file)
@@ -5,118 +5,6 @@ from docs_src.body_multiple_params.tutorial003 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "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/Body_update_item_items__item_id__put"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "User": {
-                "title": "User",
-                "required": ["username"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                },
-            },
-            "Body_update_item_items__item_id__put": {
-                "title": "Body_update_item_items__item_id__put",
-                "required": ["item", "user", "importance"],
-                "type": "object",
-                "properties": {
-                    "item": {"$ref": "#/components/schemas/Item"},
-                    "user": {"$ref": "#/components/schemas/User"},
-                    "importance": {"title": "Importance", "type": "integer"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 # Test required and embedded body parameters with no bodies sent
 @pytest.mark.parametrize(
@@ -196,3 +84,115 @@ def test_post_body(path, body, expected_status, expected_response):
     response = client.put(path, json=body)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "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/Body_update_item_items__item_id__put"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "User": {
+                    "title": "User",
+                    "required": ["username"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "full_name": {"title": "Full Name", "type": "string"},
+                    },
+                },
+                "Body_update_item_items__item_id__put": {
+                    "title": "Body_update_item_items__item_id__put",
+                    "required": ["item", "user", "importance"],
+                    "type": "object",
+                    "properties": {
+                        "item": {"$ref": "#/components/schemas/Item"},
+                        "user": {"$ref": "#/components/schemas/User"},
+                        "importance": {"title": "Importance", "type": "integer"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 788db8b30c6f0a74f0cfcf6a91e2eda93a3fb609..9b8d5e15baa28ce99c67217c79f694c189193a2b 100644 (file)
@@ -5,118 +5,6 @@ from docs_src.body_multiple_params.tutorial003_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "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/Body_update_item_items__item_id__put"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "User": {
-                "title": "User",
-                "required": ["username"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                },
-            },
-            "Body_update_item_items__item_id__put": {
-                "title": "Body_update_item_items__item_id__put",
-                "required": ["item", "user", "importance"],
-                "type": "object",
-                "properties": {
-                    "item": {"$ref": "#/components/schemas/Item"},
-                    "user": {"$ref": "#/components/schemas/User"},
-                    "importance": {"title": "Importance", "type": "integer"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 # Test required and embedded body parameters with no bodies sent
 @pytest.mark.parametrize(
@@ -196,3 +84,115 @@ def test_post_body(path, body, expected_status, expected_response):
     response = client.put(path, json=body)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "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/Body_update_item_items__item_id__put"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "User": {
+                    "title": "User",
+                    "required": ["username"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "full_name": {"title": "Full Name", "type": "string"},
+                    },
+                },
+                "Body_update_item_items__item_id__put": {
+                    "title": "Body_update_item_items__item_id__put",
+                    "required": ["item", "user", "importance"],
+                    "type": "object",
+                    "properties": {
+                        "item": {"$ref": "#/components/schemas/Item"},
+                        "user": {"$ref": "#/components/schemas/User"},
+                        "importance": {"title": "Importance", "type": "integer"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 9003016cdbae7ab56027de82c7cfb4082993642c..f8af555fcd791e0a122c99175a47195b9b647d33 100644 (file)
@@ -3,112 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "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/Body_update_item_items__item_id__put"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "User": {
-                "title": "User",
-                "required": ["username"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                },
-            },
-            "Body_update_item_items__item_id__put": {
-                "title": "Body_update_item_items__item_id__put",
-                "required": ["item", "user", "importance"],
-                "type": "object",
-                "properties": {
-                    "item": {"$ref": "#/components/schemas/Item"},
-                    "user": {"$ref": "#/components/schemas/User"},
-                    "importance": {"title": "Importance", "type": "integer"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -118,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 # Test required and embedded body parameters with no bodies sent
 @needs_py310
 @pytest.mark.parametrize(
@@ -204,3 +91,116 @@ def test_post_body(path, body, expected_status, expected_response, client: TestC
     response = client.put(path, json=body)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "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/Body_update_item_items__item_id__put"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "User": {
+                    "title": "User",
+                    "required": ["username"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "full_name": {"title": "Full Name", "type": "string"},
+                    },
+                },
+                "Body_update_item_items__item_id__put": {
+                    "title": "Body_update_item_items__item_id__put",
+                    "required": ["item", "user", "importance"],
+                    "type": "object",
+                    "properties": {
+                        "item": {"$ref": "#/components/schemas/Item"},
+                        "user": {"$ref": "#/components/schemas/User"},
+                        "importance": {"title": "Importance", "type": "integer"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index bc014a441835e6f8e0053588074c02924a72cd99..06e2c3146f69941ba6e464285fdfdc574230fbc2 100644 (file)
@@ -3,112 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "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/Body_update_item_items__item_id__put"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "User": {
-                "title": "User",
-                "required": ["username"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                },
-            },
-            "Body_update_item_items__item_id__put": {
-                "title": "Body_update_item_items__item_id__put",
-                "required": ["item", "user", "importance"],
-                "type": "object",
-                "properties": {
-                    "item": {"$ref": "#/components/schemas/Item"},
-                    "user": {"$ref": "#/components/schemas/User"},
-                    "importance": {"title": "Importance", "type": "integer"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -118,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 # Test required and embedded body parameters with no bodies sent
 @needs_py39
 @pytest.mark.parametrize(
@@ -204,3 +91,116 @@ def test_post_body(path, body, expected_status, expected_response, client: TestC
     response = client.put(path, json=body)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "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/Body_update_item_items__item_id__put"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "User": {
+                    "title": "User",
+                    "required": ["username"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "full_name": {"title": "Full Name", "type": "string"},
+                    },
+                },
+                "Body_update_item_items__item_id__put": {
+                    "title": "Body_update_item_items__item_id__put",
+                    "required": ["item", "user", "importance"],
+                    "type": "object",
+                    "properties": {
+                        "item": {"$ref": "#/components/schemas/Item"},
+                        "user": {"$ref": "#/components/schemas/User"},
+                        "importance": {"title": "Importance", "type": "integer"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index fc019d8bb4b1626a6194ef8893668ded13df9afb..82c5fb1013209b51115863b5a89cf79b4cf51e91 100644 (file)
@@ -3,112 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "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/Body_update_item_items__item_id__put"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "User": {
-                "title": "User",
-                "required": ["username"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                },
-            },
-            "Body_update_item_items__item_id__put": {
-                "title": "Body_update_item_items__item_id__put",
-                "required": ["item", "user", "importance"],
-                "type": "object",
-                "properties": {
-                    "item": {"$ref": "#/components/schemas/Item"},
-                    "user": {"$ref": "#/components/schemas/User"},
-                    "importance": {"title": "Importance", "type": "integer"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -118,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 # Test required and embedded body parameters with no bodies sent
 @needs_py310
 @pytest.mark.parametrize(
@@ -204,3 +91,116 @@ def test_post_body(path, body, expected_status, expected_response, client: TestC
     response = client.put(path, json=body)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "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/Body_update_item_items__item_id__put"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "User": {
+                    "title": "User",
+                    "required": ["username"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "full_name": {"title": "Full Name", "type": "string"},
+                    },
+                },
+                "Body_update_item_items__item_id__put": {
+                    "title": "Body_update_item_items__item_id__put",
+                    "required": ["item", "user", "importance"],
+                    "type": "object",
+                    "properties": {
+                        "item": {"$ref": "#/components/schemas/Item"},
+                        "user": {"$ref": "#/components/schemas/User"},
+                        "importance": {"title": "Importance", "type": "integer"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index c56d41b5bf795b5e20932fea8f6d79d492580386..378c241975258697502eec3565aee54e551e8764 100644 (file)
@@ -4,82 +4,6 @@ from docs_src.body_nested_models.tutorial009 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/index-weights/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Index Weights",
-                "operationId": "create_index_weights_index_weights__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {
-                                "title": "Weights",
-                                "type": "object",
-                                "additionalProperties": {"type": "number"},
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_post_body():
     data = {"2": 2.2, "3": 3.3}
@@ -101,3 +25,79 @@ def test_post_invalid_body():
             }
         ]
     }
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/index-weights/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Index Weights",
+                    "operationId": "create_index_weights_index_weights__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {
+                                    "title": "Weights",
+                                    "type": "object",
+                                    "additionalProperties": {"type": "number"},
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 5b8d8286120a0e15a1c5e88ca432a09d2021efd6..5ca63a92bd46748c4bafc2a1616e8ec39057d4b1 100644 (file)
@@ -3,76 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/index-weights/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Index Weights",
-                "operationId": "create_index_weights_index_weights__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {
-                                "title": "Weights",
-                                "type": "object",
-                                "additionalProperties": {"type": "number"},
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -82,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_post_body(client: TestClient):
     data = {"2": 2.2, "3": 3.3}
@@ -111,3 +34,80 @@ def test_post_invalid_body(client: TestClient):
             }
         ]
     }
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/index-weights/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Index Weights",
+                    "operationId": "create_index_weights_index_weights__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {
+                                    "title": "Weights",
+                                    "type": "object",
+                                    "additionalProperties": {"type": "number"},
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index efd0e46765369d0e2418581e606ad06d4b860fb3..939bf44e0a7740155618fbfe3ba280d8d977e957 100644 (file)
@@ -4,138 +4,6 @@ from docs_src.body_updates.tutorial001 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            },
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Update Item",
-                "operationId": "update_item_items__item_id__put",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    },
-                    "required": True,
-                },
-            },
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "tax": {"title": "Tax", "type": "number", "default": 10.5},
-                    "tags": {
-                        "title": "Tags",
-                        "type": "array",
-                        "items": {"type": "string"},
-                        "default": [],
-                    },
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get():
     response = client.get("/items/baz")
@@ -160,3 +28,135 @@ def test_put():
         "tax": 10.5,
         "tags": [],
     }
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                },
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Update Item",
+                    "operationId": "update_item_items__item_id__put",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        },
+                        "required": True,
+                    },
+                },
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "tax": {"title": "Tax", "type": "number", "default": 10.5},
+                        "tags": {
+                            "title": "Tags",
+                            "type": "array",
+                            "items": {"type": "string"},
+                            "default": [],
+                        },
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 49279b3206f8f2c34b27ea46acc9dff228b5102f..5f50f2071ae4351e550c94d1ae79b5a6baa476de 100644 (file)
@@ -3,132 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            },
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Update Item",
-                "operationId": "update_item_items__item_id__put",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    },
-                    "required": True,
-                },
-            },
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "tax": {"title": "Tax", "type": "number", "default": 10.5},
-                    "tags": {
-                        "title": "Tags",
-                        "type": "array",
-                        "items": {"type": "string"},
-                        "default": [],
-                    },
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -138,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_get(client: TestClient):
     response = client.get("/items/baz")
@@ -170,3 +37,136 @@ def test_put(client: TestClient):
         "tax": 10.5,
         "tags": [],
     }
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                },
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Update Item",
+                    "operationId": "update_item_items__item_id__put",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        },
+                        "required": True,
+                    },
+                },
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "tax": {"title": "Tax", "type": "number", "default": 10.5},
+                        "tags": {
+                            "title": "Tags",
+                            "type": "array",
+                            "items": {"type": "string"},
+                            "default": [],
+                        },
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 872530bcf92863227cf9e0bc9576ddd0b9c47288..d4fdabce66c75e3ad4a43ee14fbc63f1f3a17536 100644 (file)
@@ -3,132 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            },
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Update Item",
-                "operationId": "update_item_items__item_id__put",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    },
-                    "required": True,
-                },
-            },
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "tax": {"title": "Tax", "type": "number", "default": 10.5},
-                    "tags": {
-                        "title": "Tags",
-                        "type": "array",
-                        "items": {"type": "string"},
-                        "default": [],
-                    },
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -138,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_get(client: TestClient):
     response = client.get("/items/baz")
@@ -170,3 +37,136 @@ def test_put(client: TestClient):
         "tax": 10.5,
         "tags": [],
     }
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                },
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Update Item",
+                    "operationId": "update_item_items__item_id__put",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        },
+                        "required": True,
+                    },
+                },
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "tax": {"title": "Tax", "type": "number", "default": 10.5},
+                        "tags": {
+                            "title": "Tags",
+                            "type": "array",
+                            "items": {"type": "string"},
+                            "default": [],
+                        },
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 93c8775ce5f64034ffb86540daf8009a42b4dec1..c1d8fd8051e6d1b2c09b48468f8d8c30ee6a1e9d 100644 (file)
@@ -4,35 +4,6 @@ from fastapi.testclient import TestClient
 
 from docs_src.conditional_openapi import tutorial001
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/": {
-            "get": {
-                "summary": "Root",
-                "operationId": "root__get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        }
-    },
-}
-
-
-def test_default_openapi():
-    client = TestClient(tutorial001.app)
-    response = client.get("/openapi.json")
-    assert response.json() == openapi_schema
-    response = client.get("/docs")
-    assert response.status_code == 200, response.text
-    response = client.get("/redoc")
-    assert response.status_code == 200, response.text
-
 
 def test_disable_openapi(monkeypatch):
     monkeypatch.setenv("OPENAPI_URL", "")
@@ -51,3 +22,31 @@ def test_root():
     response = client.get("/")
     assert response.status_code == 200
     assert response.json() == {"message": "Hello World"}
+
+
+def test_default_openapi():
+    importlib.reload(tutorial001)
+    client = TestClient(tutorial001.app)
+    response = client.get("/docs")
+    assert response.status_code == 200, response.text
+    response = client.get("/redoc")
+    assert response.status_code == 200, response.text
+    response = client.get("/openapi.json")
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/": {
+                "get": {
+                    "summary": "Root",
+                    "operationId": "root__get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            }
+        },
+    }
index 38ae211db361d4d3df47d1821a0a69a02bd5444f..c3511d129efa92bc24110353681dbd36b7e9784b 100644 (file)
@@ -3,77 +3,10 @@ from fastapi.testclient import TestClient
 
 from docs_src.cookie_params.tutorial001 import app
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Ads Id", "type": "string"},
-                        "name": "ads_id",
-                        "in": "cookie",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.mark.parametrize(
     "path,cookies,expected_status,expected_response",
     [
-        ("/openapi.json", None, 200, openapi_schema),
         ("/items", None, 200, {"ads_id": None}),
         ("/items", {"ads_id": "ads_track"}, 200, {"ads_id": "ads_track"}),
         (
@@ -90,3 +23,76 @@ def test(path, cookies, expected_status, expected_response):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    client = TestClient(app)
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Ads Id", "type": "string"},
+                            "name": "ads_id",
+                            "in": "cookie",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index fb60ea9938f9028e74bee3c153a5e8e889526748..f4f94c09dcc594a5a01159e34d92f1cef63263c2 100644 (file)
@@ -3,77 +3,10 @@ from fastapi.testclient import TestClient
 
 from docs_src.cookie_params.tutorial001_an import app
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Ads Id", "type": "string"},
-                        "name": "ads_id",
-                        "in": "cookie",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.mark.parametrize(
     "path,cookies,expected_status,expected_response",
     [
-        ("/openapi.json", None, 200, openapi_schema),
         ("/items", None, 200, {"ads_id": None}),
         ("/items", {"ads_id": "ads_track"}, 200, {"ads_id": "ads_track"}),
         (
@@ -90,3 +23,76 @@ def test(path, cookies, expected_status, expected_response):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    client = TestClient(app)
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Ads Id", "type": "string"},
+                            "name": "ads_id",
+                            "in": "cookie",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 30888608565f582b8608d8947454b703be9cfcab..a80f10f810564743b3579306269342d676520bcf 100644 (file)
@@ -3,78 +3,11 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Ads Id", "type": "string"},
-                        "name": "ads_id",
-                        "in": "cookie",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @needs_py310
 @pytest.mark.parametrize(
     "path,cookies,expected_status,expected_response",
     [
-        ("/openapi.json", None, 200, openapi_schema),
         ("/items", None, 200, {"ads_id": None}),
         ("/items", {"ads_id": "ads_track"}, 200, {"ads_id": "ads_track"}),
         (
@@ -93,3 +26,79 @@ def test(path, cookies, expected_status, expected_response):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema():
+    from docs_src.cookie_params.tutorial001_an_py310 import app
+
+    client = TestClient(app)
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Ads Id", "type": "string"},
+                            "name": "ads_id",
+                            "in": "cookie",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index bbfe5ff9a9b9a77e60b51fdf5cfa2d0de492edbf..1be898c0922c0f58553d08a2b992aa826c4ca897 100644 (file)
@@ -3,78 +3,11 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Ads Id", "type": "string"},
-                        "name": "ads_id",
-                        "in": "cookie",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @needs_py39
 @pytest.mark.parametrize(
     "path,cookies,expected_status,expected_response",
     [
-        ("/openapi.json", None, 200, openapi_schema),
         ("/items", None, 200, {"ads_id": None}),
         ("/items", {"ads_id": "ads_track"}, 200, {"ads_id": "ads_track"}),
         (
@@ -93,3 +26,79 @@ def test(path, cookies, expected_status, expected_response):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py39
+def test_openapi_schema():
+    from docs_src.cookie_params.tutorial001_an_py39 import app
+
+    client = TestClient(app)
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Ads Id", "type": "string"},
+                            "name": "ads_id",
+                            "in": "cookie",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 5ad52fb5e125844fe21ce5bb906e82d96cd2a388..7ba542c9029908d7dd0d557b06f4f8cc382efc4a 100644 (file)
@@ -3,78 +3,11 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Ads Id", "type": "string"},
-                        "name": "ads_id",
-                        "in": "cookie",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @needs_py310
 @pytest.mark.parametrize(
     "path,cookies,expected_status,expected_response",
     [
-        ("/openapi.json", None, 200, openapi_schema),
         ("/items", None, 200, {"ads_id": None}),
         ("/items", {"ads_id": "ads_track"}, 200, {"ads_id": "ads_track"}),
         (
@@ -93,3 +26,79 @@ def test(path, cookies, expected_status, expected_response):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema():
+    from docs_src.cookie_params.tutorial001_py310 import app
+
+    client = TestClient(app)
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Ads Id", "type": "string"},
+                            "name": "ads_id",
+                            "in": "cookie",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 430076f88f0fd9377ca9520df27a76f46b61bad2..da2ca8d6203910b77383c490ffea0edc1dcfaa35 100644 (file)
@@ -4,33 +4,31 @@ from docs_src.custom_response.tutorial001 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_custom_response():
     response = client.get("/items/")
     assert response.status_code == 200, response.text
     assert response.json() == [{"item_id": "Foo"}]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                }
+            }
+        },
+    }
index 0f15d5f48c669611fefe622f57c33d28647e98b7..f681f5a9d0bd8f9d1982a3ed593ab83585316445 100644 (file)
@@ -4,33 +4,31 @@ from docs_src.custom_response.tutorial001b import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_custom_response():
     response = client.get("/items/")
     assert response.status_code == 200, response.text
     assert response.json() == [{"item_id": "Foo"}]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                }
+            }
+        },
+    }
index 5d75cce960931239f105e21426b736f8ef846c71..ef0ba34469acaf5a5998e5070b4af22a4ed392ab 100644 (file)
@@ -4,24 +4,6 @@ from docs_src.custom_response.tutorial004 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"text/html": {"schema": {"type": "string"}}},
-                    }
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-            }
-        }
-    },
-}
 
 html_contents = """
     <html>
@@ -35,13 +17,30 @@ html_contents = """
     """
 
 
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_get_custom_response():
     response = client.get("/items/")
     assert response.status_code == 200, response.text
     assert response.text == html_contents
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"text/html": {"schema": {"type": "string"}}},
+                        }
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                }
+            }
+        },
+    }
index ecf6ee2b98a86909a150701423372e7b4792f228..e4b5c154669496425d7b3cf4f6673836cd64c2fe 100644 (file)
@@ -4,33 +4,31 @@ from docs_src.custom_response.tutorial005 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/": {
-            "get": {
-                "summary": "Main",
-                "operationId": "main__get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"text/plain": {"schema": {"type": "string"}}},
-                    }
-                },
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get():
     response = client.get("/")
     assert response.status_code == 200, response.text
     assert response.text == "Hello World"
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/": {
+                "get": {
+                    "summary": "Main",
+                    "operationId": "main__get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"text/plain": {"schema": {"type": "string"}}},
+                        }
+                    },
+                }
+            }
+        },
+    }
index 9b10916e588a3aaf2dd28424c3526614ab0283bf..9f1b07bee96c95178db5a9d355aeab0f22df0d55 100644 (file)
@@ -5,33 +5,30 @@ from docs_src.custom_response.tutorial006 import app
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/typer": {
-            "get": {
-                "summary": "Redirect Typer",
-                "operationId": "redirect_typer_typer_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        }
-    },
-}
+def test_get():
+    response = client.get("/typer", follow_redirects=False)
+    assert response.status_code == 307, response.text
+    assert response.headers["location"] == "https://typer.tiangolo.com"
 
 
 def test_openapi_schema():
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
-def test_get():
-    response = client.get("/typer", follow_redirects=False)
-    assert response.status_code == 307, response.text
-    assert response.headers["location"] == "https://typer.tiangolo.com"
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/typer": {
+                "get": {
+                    "summary": "Redirect Typer",
+                    "operationId": "redirect_typer_typer_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            }
+        },
+    }
index b3e60e86a38b97aac5cfe4f1ad723751d60cffc7..cf204cbc054371ffb1f65bbaae3e67551dd0bf5b 100644 (file)
@@ -5,28 +5,25 @@ from docs_src.custom_response.tutorial006b import app
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/fastapi": {
-            "get": {
-                "summary": "Redirect Fastapi",
-                "operationId": "redirect_fastapi_fastapi_get",
-                "responses": {"307": {"description": "Successful Response"}},
-            }
-        }
-    },
-}
+def test_redirect_response_class():
+    response = client.get("/fastapi", follow_redirects=False)
+    assert response.status_code == 307
+    assert response.headers["location"] == "https://fastapi.tiangolo.com"
 
 
 def test_openapi_schema():
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
-def test_redirect_response_class():
-    response = client.get("/fastapi", follow_redirects=False)
-    assert response.status_code == 307
-    assert response.headers["location"] == "https://fastapi.tiangolo.com"
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/fastapi": {
+                "get": {
+                    "summary": "Redirect Fastapi",
+                    "operationId": "redirect_fastapi_fastapi_get",
+                    "responses": {"307": {"description": "Successful Response"}},
+                }
+            }
+        },
+    }
index 0cb6ddaa330ebad37aa6026c2085e2fff55216b3..f196899acaa28cc0ccd2e68c3905fa35c06db66b 100644 (file)
@@ -5,28 +5,25 @@ from docs_src.custom_response.tutorial006c import app
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/pydantic": {
-            "get": {
-                "summary": "Redirect Pydantic",
-                "operationId": "redirect_pydantic_pydantic_get",
-                "responses": {"302": {"description": "Successful Response"}},
-            }
-        }
-    },
-}
+def test_redirect_status_code():
+    response = client.get("/pydantic", follow_redirects=False)
+    assert response.status_code == 302
+    assert response.headers["location"] == "https://pydantic-docs.helpmanual.io/"
 
 
 def test_openapi_schema():
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
-def test_redirect_status_code():
-    response = client.get("/pydantic", follow_redirects=False)
-    assert response.status_code == 302
-    assert response.headers["location"] == "https://pydantic-docs.helpmanual.io/"
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/pydantic": {
+                "get": {
+                    "summary": "Redirect Pydantic",
+                    "operationId": "redirect_pydantic_pydantic_get",
+                    "responses": {"302": {"description": "Successful Response"}},
+                }
+            }
+        },
+    }
index bf156419492457b437dea735c1317a01eefa0d99..26ae04c515441098d206a2913e44eed6ae3404c1 100644 (file)
@@ -4,89 +4,6 @@ from docs_src.dataclasses.tutorial001 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "post": {
-                "summary": "Create Item",
-                "operationId": "create_item_items__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    },
-                    "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200
-    assert response.json() == openapi_schema
-
 
 def test_post_item():
     response = client.post("/items/", json={"name": "Foo", "price": 3})
@@ -111,3 +28,86 @@ def test_post_invalid_item():
             }
         ]
     }
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "post": {
+                    "summary": "Create Item",
+                    "operationId": "create_item_items__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        },
+                        "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 2d86f7b9abe89b9486f0b010e97045fd8dd5d73c..f3378fe6299786bb2bf198b93ba2513d4a3ad9de 100644 (file)
@@ -4,136 +4,6 @@ from docs_src.dataclasses.tutorial003 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/authors/{author_id}/items/": {
-            "post": {
-                "summary": "Create Author Items",
-                "operationId": "create_author_items_authors__author_id__items__post",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Author Id", "type": "string"},
-                        "name": "author_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {
-                                "title": "Items",
-                                "type": "array",
-                                "items": {"$ref": "#/components/schemas/Item"},
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Author"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/authors/": {
-            "get": {
-                "summary": "Get Authors",
-                "operationId": "get_authors_authors__get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Get Authors Authors  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/Author"},
-                                }
-                            }
-                        },
-                    }
-                },
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Author": {
-                "title": "Author",
-                "required": ["name"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "items": {
-                        "title": "Items",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/Item"},
-                    },
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["name"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200
-    assert response.json() == openapi_schema
-
 
 def test_post_authors_item():
     response = client.post(
@@ -179,3 +49,135 @@ def test_get_authors():
             ],
         },
     ]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/authors/{author_id}/items/": {
+                "post": {
+                    "summary": "Create Author Items",
+                    "operationId": "create_author_items_authors__author_id__items__post",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Author Id", "type": "string"},
+                            "name": "author_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {
+                                    "title": "Items",
+                                    "type": "array",
+                                    "items": {"$ref": "#/components/schemas/Item"},
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Author"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/authors/": {
+                "get": {
+                    "summary": "Get Authors",
+                    "operationId": "get_authors_authors__get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Get Authors Authors  Get",
+                                        "type": "array",
+                                        "items": {
+                                            "$ref": "#/components/schemas/Author"
+                                        },
+                                    }
+                                }
+                            },
+                        }
+                    },
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Author": {
+                    "title": "Author",
+                    "required": ["name"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "items": {
+                            "title": "Items",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/Item"},
+                        },
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "Item": {
+                    "title": "Item",
+                    "required": ["name"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index c3bca5d5b3b0c09d4c844112b9caeaf677b4252b..974b9304fdbf059c9e9ae7b595f6a06401d164e2 100644 (file)
@@ -5,132 +5,6 @@ from docs_src.dependencies.tutorial001 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        },
-        "/users/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 @pytest.mark.parametrize(
     "path,expected_status,expected_response",
@@ -140,10 +14,151 @@ def test_openapi_schema():
         ("/items?q=foo&skip=5", 200, {"q": "foo", "skip": 5, "limit": 100}),
         ("/items?q=foo&skip=5&limit=30", 200, {"q": "foo", "skip": 5, "limit": 30}),
         ("/users", 200, {"q": None, "skip": 0, "limit": 100}),
-        ("/openapi.json", 200, openapi_schema),
     ],
 )
 def test_get(path, expected_status, expected_response):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            },
+            "/users/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 13960addcf307fcb245944288d62a744cce6d865..b1ca27ff8b0f918eb53b3424d4676bc93a401e5b 100644 (file)
@@ -5,132 +5,6 @@ from docs_src.dependencies.tutorial001_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        },
-        "/users/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 @pytest.mark.parametrize(
     "path,expected_status,expected_response",
@@ -140,10 +14,151 @@ def test_openapi_schema():
         ("/items?q=foo&skip=5", 200, {"q": "foo", "skip": 5, "limit": 100}),
         ("/items?q=foo&skip=5&limit=30", 200, {"q": "foo", "skip": 5, "limit": 30}),
         ("/users", 200, {"q": None, "skip": 0, "limit": 100}),
-        ("/openapi.json", 200, openapi_schema),
     ],
 )
 def test_get(path, expected_status, expected_response):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            },
+            "/users/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 4b093af0dc2b73edd9547140d6e249b450095650..70bed03f628621f2cba80c552f0da6413c7772af 100644 (file)
@@ -3,126 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        },
-        "/users/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -132,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 @pytest.mark.parametrize(
     "path,expected_status,expected_response",
@@ -148,10 +21,152 @@ def test_openapi_schema(client: TestClient):
         ("/items?q=foo&skip=5", 200, {"q": "foo", "skip": 5, "limit": 100}),
         ("/items?q=foo&skip=5&limit=30", 200, {"q": "foo", "skip": 5, "limit": 30}),
         ("/users", 200, {"q": None, "skip": 0, "limit": 100}),
-        ("/openapi.json", 200, openapi_schema),
     ],
 )
 def test_get(path, expected_status, expected_response, client: TestClient):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            },
+            "/users/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 6059924ccc9e8a0c23b7075e9adb8f1b2306e942..9c5723be88570c8fef8e6ebd23c2a8d73cfcec1b 100644 (file)
@@ -3,126 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        },
-        "/users/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -132,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 @pytest.mark.parametrize(
     "path,expected_status,expected_response",
@@ -148,10 +21,152 @@ def test_openapi_schema(client: TestClient):
         ("/items?q=foo&skip=5", 200, {"q": "foo", "skip": 5, "limit": 100}),
         ("/items?q=foo&skip=5&limit=30", 200, {"q": "foo", "skip": 5, "limit": 30}),
         ("/users", 200, {"q": None, "skip": 0, "limit": 100}),
-        ("/openapi.json", 200, openapi_schema),
     ],
 )
 def test_get(path, expected_status, expected_response, client: TestClient):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            },
+            "/users/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 32a61c8219f8ed23f39c9b6d71a134517243b66c..1bcde4e9f47ec0b5743f62a53e00e5a22efb856e 100644 (file)
@@ -3,126 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        },
-        "/users/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -132,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 @pytest.mark.parametrize(
     "path,expected_status,expected_response",
@@ -148,10 +21,152 @@ def test_openapi_schema(client: TestClient):
         ("/items?q=foo&skip=5", 200, {"q": "foo", "skip": 5, "limit": 100}),
         ("/items?q=foo&skip=5&limit=30", 200, {"q": "foo", "skip": 5, "limit": 30}),
         ("/users", 200, {"q": None, "skip": 0, "limit": 100}),
-        ("/openapi.json", 200, openapi_schema),
     ],
 )
 def test_get(path, expected_status, expected_response, client: TestClient):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            },
+            "/users/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index f2b1878d5413fcd8a1f95241f862a44c71f74261..298bc290d291b7150bdcc7eaf185f485e5404ab6 100644 (file)
@@ -5,90 +5,6 @@ from docs_src.dependencies.tutorial004 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 @pytest.mark.parametrize(
     "path,expected_status,expected_response",
@@ -142,3 +58,95 @@ def test_get(path, expected_status, expected_response):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index ef6199b04aaa3571f40701e665f90ddcbf51a69d..f985be8df058e6c188e2179d8409e1f990a5f4ea 100644 (file)
@@ -5,90 +5,6 @@ from docs_src.dependencies.tutorial004_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 @pytest.mark.parametrize(
     "path,expected_status,expected_response",
@@ -142,3 +58,95 @@ def test_get(path, expected_status, expected_response):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index e9736780c9833516ff5c0eec329eeaae3c2a9394..fc028670285c5fe423160354a3e79a686a6c12be 100644 (file)
@@ -3,84 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -90,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 @pytest.mark.parametrize(
     "path,expected_status,expected_response",
@@ -150,3 +65,96 @@ def test_get(path, expected_status, expected_response, client: TestClient):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 2b346f3b2105cb3293273d546d5e7b5836d04b82..1e37673ed8b0ef2c4b568c4043dfcbe891e69b4d 100644 (file)
@@ -3,84 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -90,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 @pytest.mark.parametrize(
     "path,expected_status,expected_response",
@@ -150,3 +65,96 @@ def test_get(path, expected_status, expected_response, client: TestClient):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index e3ae0c7418166ab42f8b4c0c8fb399efab34e353..ab936ccdc0b303ab7a8ff590179ed1931665bb95 100644 (file)
@@ -3,84 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Q", "type": "string"},
-                        "name": "q",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -90,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 @pytest.mark.parametrize(
     "path,expected_status,expected_response",
@@ -150,3 +65,96 @@ def test_get(path, expected_status, expected_response, client: TestClient):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Q", "type": "string"},
+                            "name": "q",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 2916577a2acb2a573367dbe82a2da60e0dea9343..2e9c82d711208c074cd93854049ee3a01ad2518a 100644 (file)
@@ -4,84 +4,6 @@ from docs_src.dependencies.tutorial006 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Key", "type": "string"},
-                        "name": "x-key",
-                        "in": "header",
-                    },
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_no_headers():
     response = client.get("/items/")
@@ -126,3 +48,81 @@ def test_get_valid_headers():
     )
     assert response.status_code == 200, response.text
     assert response.json() == [{"item": "Foo"}, {"item": "Bar"}]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Key", "type": "string"},
+                            "name": "x-key",
+                            "in": "header",
+                        },
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index f33b67d58d1fe7945cbb7eb3f6347453b7ff91e8..919066dcad779f0f8ac5737fb303d73b3df08173 100644 (file)
@@ -4,84 +4,6 @@ from docs_src.dependencies.tutorial006_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Key", "type": "string"},
-                        "name": "x-key",
-                        "in": "header",
-                    },
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_no_headers():
     response = client.get("/items/")
@@ -126,3 +48,81 @@ def test_get_valid_headers():
     )
     assert response.status_code == 200, response.text
     assert response.json() == [{"item": "Foo"}, {"item": "Bar"}]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Key", "type": "string"},
+                            "name": "x-key",
+                            "in": "header",
+                        },
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 171e39a96a9ab771934ff95ad455f7bec54cfee9..c237184796ca87510d66cba04473ecf463512d9f 100644 (file)
@@ -3,78 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Key", "type": "string"},
-                        "name": "x-key",
-                        "in": "header",
-                    },
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -84,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_get_no_headers(client: TestClient):
     response = client.get("/items/")
@@ -138,3 +59,82 @@ def test_get_valid_headers(client: TestClient):
     )
     assert response.status_code == 200, response.text
     assert response.json() == [{"item": "Foo"}, {"item": "Bar"}]
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Key", "type": "string"},
+                            "name": "x-key",
+                            "in": "header",
+                        },
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index e4e07395dff4b85e8371805d83258e6c0cb415a9..b92b96c0194e93d4818b14883a34b59f9b5ddd15 100644 (file)
@@ -4,120 +4,6 @@ from docs_src.dependencies.tutorial012 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Key", "type": "string"},
-                        "name": "x-key",
-                        "in": "header",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/users/": {
-            "get": {
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Key", "type": "string"},
-                        "name": "x-key",
-                        "in": "header",
-                    },
-                ],
-                "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_no_headers_items():
     response = client.get("/items/")
@@ -207,3 +93,117 @@ def test_get_valid_headers_users():
     )
     assert response.status_code == 200, response.text
     assert response.json() == [{"username": "Rick"}, {"username": "Morty"}]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Key", "type": "string"},
+                            "name": "x-key",
+                            "in": "header",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/users/": {
+                "get": {
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Key", "type": "string"},
+                            "name": "x-key",
+                            "in": "header",
+                        },
+                    ],
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 0a6908f72429931e952942f26540c2c24a9ef48a..2ddb7bb53285ed12a61386d18e3cfa4e455b8982 100644 (file)
@@ -4,120 +4,6 @@ from docs_src.dependencies.tutorial012_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Key", "type": "string"},
-                        "name": "x-key",
-                        "in": "header",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/users/": {
-            "get": {
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Key", "type": "string"},
-                        "name": "x-key",
-                        "in": "header",
-                    },
-                ],
-                "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_no_headers_items():
     response = client.get("/items/")
@@ -207,3 +93,117 @@ def test_get_valid_headers_users():
     )
     assert response.status_code == 200, response.text
     assert response.json() == [{"username": "Rick"}, {"username": "Morty"}]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Key", "type": "string"},
+                            "name": "x-key",
+                            "in": "header",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/users/": {
+                "get": {
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Key", "type": "string"},
+                            "name": "x-key",
+                            "in": "header",
+                        },
+                    ],
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 25f54f4c937bfa6c37653440dd247320d346352e..595c83a5310ea99c9bceedf094d1fac957d6b0cd 100644 (file)
@@ -3,114 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Key", "type": "string"},
-                        "name": "x-key",
-                        "in": "header",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/users/": {
-            "get": {
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Token", "type": "string"},
-                        "name": "x-token",
-                        "in": "header",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "X-Key", "type": "string"},
-                        "name": "x-key",
-                        "in": "header",
-                    },
-                ],
-                "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -120,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_get_no_headers_items(client: TestClient):
     response = client.get("/items/")
@@ -223,3 +108,118 @@ def test_get_valid_headers_users(client: TestClient):
     )
     assert response.status_code == 200, response.text
     assert response.json() == [{"username": "Rick"}, {"username": "Morty"}]
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Key", "type": "string"},
+                            "name": "x-key",
+                            "in": "header",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/users/": {
+                "get": {
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Token", "type": "string"},
+                            "name": "x-token",
+                            "in": "header",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "X-Key", "type": "string"},
+                            "name": "x-key",
+                            "in": "header",
+                        },
+                    ],
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index d52dd1a047123687bf52e4c1cf9c1e1bf9de0c4d..52f9beed5daa35aadfa64164dc7b7c9225950469 100644 (file)
@@ -2,78 +2,84 @@ from fastapi.testclient import TestClient
 
 from docs_src.events.tutorial001 import app
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 def test_events():
     with TestClient(app) as client:
-        response = client.get("/openapi.json")
-        assert response.status_code == 200, response.text
-        assert response.json() == openapi_schema
         response = client.get("/items/foo")
         assert response.status_code == 200, response.text
         assert response.json() == {"name": "Fighters"}
+
+
+def test_openapi_schema():
+    with TestClient(app) as client:
+        response = client.get("/openapi.json")
+        assert response.status_code == 200, response.text
+        assert response.json() == {
+            "openapi": "3.0.2",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "paths": {
+                "/items/{item_id}": {
+                    "get": {
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {"application/json": {"schema": {}}},
+                            },
+                            "422": {
+                                "description": "Validation Error",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                        }
+                                    }
+                                },
+                            },
+                        },
+                        "summary": "Read Items",
+                        "operationId": "read_items_items__item_id__get",
+                        "parameters": [
+                            {
+                                "required": True,
+                                "schema": {"title": "Item Id", "type": "string"},
+                                "name": "item_id",
+                                "in": "path",
+                            }
+                        ],
+                    }
+                }
+            },
+            "components": {
+                "schemas": {
+                    "ValidationError": {
+                        "title": "ValidationError",
+                        "required": ["loc", "msg", "type"],
+                        "type": "object",
+                        "properties": {
+                            "loc": {
+                                "title": "Location",
+                                "type": "array",
+                                "items": {
+                                    "anyOf": [{"type": "string"}, {"type": "integer"}]
+                                },
+                            },
+                            "msg": {"title": "Message", "type": "string"},
+                            "type": {"title": "Error Type", "type": "string"},
+                        },
+                    },
+                    "HTTPValidationError": {
+                        "title": "HTTPValidationError",
+                        "type": "object",
+                        "properties": {
+                            "detail": {
+                                "title": "Detail",
+                                "type": "array",
+                                "items": {
+                                    "$ref": "#/components/schemas/ValidationError"
+                                },
+                            }
+                        },
+                    },
+                }
+            },
+        }
index f6ac1e07bf5b675874e5c7d1098cb6cadc998451..882d41aa517be2f8d4366ea8bb1b683f0a6b17a0 100644 (file)
@@ -2,33 +2,35 @@ from fastapi.testclient import TestClient
 
 from docs_src.events.tutorial002 import app
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-            }
-        }
-    },
-}
-
 
 def test_events():
     with TestClient(app) as client:
-        response = client.get("/openapi.json")
-        assert response.status_code == 200, response.text
-        assert response.json() == openapi_schema
         response = client.get("/items/")
         assert response.status_code == 200, response.text
         assert response.json() == [{"name": "Foo"}]
     with open("log.txt") as log:
         assert "Application shutdown" in log.read()
+
+
+def test_openapi_schema():
+    with TestClient(app) as client:
+        response = client.get("/openapi.json")
+        assert response.status_code == 200, response.text
+        assert response.json() == {
+            "openapi": "3.0.2",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "paths": {
+                "/items/": {
+                    "get": {
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {"application/json": {"schema": {}}},
+                            }
+                        },
+                        "summary": "Read Items",
+                        "operationId": "read_items_items__get",
+                    }
+                }
+            },
+        }
index 56b49395466176bf7b40888657f726ce36ce4342..b2820b63c68657721f25ecced33813c06f41c584 100644 (file)
@@ -6,81 +6,87 @@ from docs_src.events.tutorial003 import (
     ml_models,
 )
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/predict": {
-            "get": {
-                "summary": "Predict",
-                "operationId": "predict_predict_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "X", "type": "number"},
-                        "name": "x",
-                        "in": "query",
-                    }
-                ],
-                "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 def test_events():
     assert not ml_models, "ml_models should be empty"
     with TestClient(app) as client:
         assert ml_models["answer_to_everything"] == fake_answer_to_everything_ml_model
-        response = client.get("/openapi.json")
-        assert response.status_code == 200, response.text
-        assert response.json() == openapi_schema
         response = client.get("/predict", params={"x": 2})
         assert response.status_code == 200, response.text
         assert response.json() == {"result": 84.0}
     assert not ml_models, "ml_models should be empty"
+
+
+def test_openapi_schema():
+    with TestClient(app) as client:
+        response = client.get("/openapi.json")
+        assert response.status_code == 200, response.text
+        assert response.json() == {
+            "openapi": "3.0.2",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "paths": {
+                "/predict": {
+                    "get": {
+                        "summary": "Predict",
+                        "operationId": "predict_predict_get",
+                        "parameters": [
+                            {
+                                "required": True,
+                                "schema": {"title": "X", "type": "number"},
+                                "name": "x",
+                                "in": "query",
+                            }
+                        ],
+                        "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": {
+                                    "$ref": "#/components/schemas/ValidationError"
+                                },
+                            }
+                        },
+                    },
+                    "ValidationError": {
+                        "title": "ValidationError",
+                        "required": ["loc", "msg", "type"],
+                        "type": "object",
+                        "properties": {
+                            "loc": {
+                                "title": "Location",
+                                "type": "array",
+                                "items": {
+                                    "anyOf": [{"type": "string"}, {"type": "integer"}]
+                                },
+                            },
+                            "msg": {"title": "Message", "type": "string"},
+                            "type": {"title": "Error Type", "type": "string"},
+                        },
+                    },
+                }
+            },
+        }
index ec56e9ca6a9bcb6fa0654e15079a014dd1b3d764..6e71bb2debc7e6fde1f3bd044e85525e8ec9b4be 100644 (file)
@@ -4,41 +4,43 @@ from docs_src.extending_openapi.tutorial001 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {
-        "title": "Custom title",
-        "version": "2.5.0",
-        "description": "This is a very custom OpenAPI schema",
-        "x-logo": {"url": "https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png"},
-    },
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-            }
-        }
-    },
-}
+
+def test():
+    response = client.get("/items/")
+    assert response.status_code == 200, response.text
+    assert response.json() == [{"name": "Foo"}]
 
 
 def test_openapi_schema():
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {
+            "title": "Custom title",
+            "version": "2.5.0",
+            "description": "This is a very custom OpenAPI schema",
+            "x-logo": {
+                "url": "https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png"
+            },
+        },
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                }
+            }
+        },
+    }
+    openapi_schema = response.json()
+    # Request again to test the custom cache
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
     assert response.json() == openapi_schema
-
-
-def test():
-    response = client.get("/items/")
-    assert response.status_code == 200, response.text
-    assert response.json() == [{"name": "Foo"}]
index 8522d7b9d7d5a2d99274211ce62196fe01725742..07a83499038525cbf6708d21b71da1776457dedf 100644 (file)
@@ -5,118 +5,6 @@ from docs_src.extra_data_types.tutorial001 import app
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__item_id__put",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "type": "string",
-                            "format": "uuid",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_read_items_items__item_id__put"
-                            }
-                        }
-                    }
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Body_read_items_items__item_id__put": {
-                "title": "Body_read_items_items__item_id__put",
-                "type": "object",
-                "properties": {
-                    "start_datetime": {
-                        "title": "Start Datetime",
-                        "type": "string",
-                        "format": "date-time",
-                    },
-                    "end_datetime": {
-                        "title": "End Datetime",
-                        "type": "string",
-                        "format": "date-time",
-                    },
-                    "repeat_at": {
-                        "title": "Repeat At",
-                        "type": "string",
-                        "format": "time",
-                    },
-                    "process_after": {
-                        "title": "Process After",
-                        "type": "number",
-                        "format": "time-delta",
-                    },
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_extra_types():
     item_id = "ff97dd87-a4a5-4a12-b412-cde99f33e00e"
     data = {
@@ -136,3 +24,114 @@ def test_extra_types():
     response = client.put(f"/items/{item_id}", json=data)
     assert response.status_code == 200, response.text
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__item_id__put",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "type": "string",
+                                "format": "uuid",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_read_items_items__item_id__put"
+                                }
+                            }
+                        }
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Body_read_items_items__item_id__put": {
+                    "title": "Body_read_items_items__item_id__put",
+                    "type": "object",
+                    "properties": {
+                        "start_datetime": {
+                            "title": "Start Datetime",
+                            "type": "string",
+                            "format": "date-time",
+                        },
+                        "end_datetime": {
+                            "title": "End Datetime",
+                            "type": "string",
+                            "format": "date-time",
+                        },
+                        "repeat_at": {
+                            "title": "Repeat At",
+                            "type": "string",
+                            "format": "time",
+                        },
+                        "process_after": {
+                            "title": "Process After",
+                            "type": "number",
+                            "format": "time-delta",
+                        },
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index d5be16dfb9b76ada6c8f5dbdbb0470b4a5ac1a1c..76836d447d89114f902e0ebd15405488b178a07d 100644 (file)
@@ -5,118 +5,6 @@ from docs_src.extra_data_types.tutorial001_an import app
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__item_id__put",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "type": "string",
-                            "format": "uuid",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_read_items_items__item_id__put"
-                            }
-                        }
-                    }
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Body_read_items_items__item_id__put": {
-                "title": "Body_read_items_items__item_id__put",
-                "type": "object",
-                "properties": {
-                    "start_datetime": {
-                        "title": "Start Datetime",
-                        "type": "string",
-                        "format": "date-time",
-                    },
-                    "end_datetime": {
-                        "title": "End Datetime",
-                        "type": "string",
-                        "format": "date-time",
-                    },
-                    "repeat_at": {
-                        "title": "Repeat At",
-                        "type": "string",
-                        "format": "time",
-                    },
-                    "process_after": {
-                        "title": "Process After",
-                        "type": "number",
-                        "format": "time-delta",
-                    },
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_extra_types():
     item_id = "ff97dd87-a4a5-4a12-b412-cde99f33e00e"
     data = {
@@ -136,3 +24,114 @@ def test_extra_types():
     response = client.put(f"/items/{item_id}", json=data)
     assert response.status_code == 200, response.text
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__item_id__put",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "type": "string",
+                                "format": "uuid",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_read_items_items__item_id__put"
+                                }
+                            }
+                        }
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Body_read_items_items__item_id__put": {
+                    "title": "Body_read_items_items__item_id__put",
+                    "type": "object",
+                    "properties": {
+                        "start_datetime": {
+                            "title": "Start Datetime",
+                            "type": "string",
+                            "format": "date-time",
+                        },
+                        "end_datetime": {
+                            "title": "End Datetime",
+                            "type": "string",
+                            "format": "date-time",
+                        },
+                        "repeat_at": {
+                            "title": "Repeat At",
+                            "type": "string",
+                            "format": "time",
+                        },
+                        "process_after": {
+                            "title": "Process After",
+                            "type": "number",
+                            "format": "time-delta",
+                        },
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 80806b694dafe4833f8dc15d02aa48670053dd5b..158ee01b389a339e003a87adccd66051fdb4ea37 100644 (file)
@@ -3,111 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__item_id__put",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "type": "string",
-                            "format": "uuid",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_read_items_items__item_id__put"
-                            }
-                        }
-                    }
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Body_read_items_items__item_id__put": {
-                "title": "Body_read_items_items__item_id__put",
-                "type": "object",
-                "properties": {
-                    "start_datetime": {
-                        "title": "Start Datetime",
-                        "type": "string",
-                        "format": "date-time",
-                    },
-                    "end_datetime": {
-                        "title": "End Datetime",
-                        "type": "string",
-                        "format": "date-time",
-                    },
-                    "repeat_at": {
-                        "title": "Repeat At",
-                        "type": "string",
-                        "format": "time",
-                    },
-                    "process_after": {
-                        "title": "Process After",
-                        "type": "number",
-                        "format": "time-delta",
-                    },
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -117,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_extra_types(client: TestClient):
     item_id = "ff97dd87-a4a5-4a12-b412-cde99f33e00e"
@@ -144,3 +32,115 @@ def test_extra_types(client: TestClient):
     response = client.put(f"/items/{item_id}", json=data)
     assert response.status_code == 200, response.text
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__item_id__put",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "type": "string",
+                                "format": "uuid",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_read_items_items__item_id__put"
+                                }
+                            }
+                        }
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Body_read_items_items__item_id__put": {
+                    "title": "Body_read_items_items__item_id__put",
+                    "type": "object",
+                    "properties": {
+                        "start_datetime": {
+                            "title": "Start Datetime",
+                            "type": "string",
+                            "format": "date-time",
+                        },
+                        "end_datetime": {
+                            "title": "End Datetime",
+                            "type": "string",
+                            "format": "date-time",
+                        },
+                        "repeat_at": {
+                            "title": "Repeat At",
+                            "type": "string",
+                            "format": "time",
+                        },
+                        "process_after": {
+                            "title": "Process After",
+                            "type": "number",
+                            "format": "time-delta",
+                        },
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 5c7d43394e6f3af7d739400e4670777b0d7bf0fc..5be6452ee56caa47e3d447f246e99c6c7063bbba 100644 (file)
@@ -3,111 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__item_id__put",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "type": "string",
-                            "format": "uuid",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_read_items_items__item_id__put"
-                            }
-                        }
-                    }
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Body_read_items_items__item_id__put": {
-                "title": "Body_read_items_items__item_id__put",
-                "type": "object",
-                "properties": {
-                    "start_datetime": {
-                        "title": "Start Datetime",
-                        "type": "string",
-                        "format": "date-time",
-                    },
-                    "end_datetime": {
-                        "title": "End Datetime",
-                        "type": "string",
-                        "format": "date-time",
-                    },
-                    "repeat_at": {
-                        "title": "Repeat At",
-                        "type": "string",
-                        "format": "time",
-                    },
-                    "process_after": {
-                        "title": "Process After",
-                        "type": "number",
-                        "format": "time-delta",
-                    },
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -117,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_extra_types(client: TestClient):
     item_id = "ff97dd87-a4a5-4a12-b412-cde99f33e00e"
@@ -144,3 +32,115 @@ def test_extra_types(client: TestClient):
     response = client.put(f"/items/{item_id}", json=data)
     assert response.status_code == 200, response.text
     assert response.json() == expected_response
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__item_id__put",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "type": "string",
+                                "format": "uuid",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_read_items_items__item_id__put"
+                                }
+                            }
+                        }
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Body_read_items_items__item_id__put": {
+                    "title": "Body_read_items_items__item_id__put",
+                    "type": "object",
+                    "properties": {
+                        "start_datetime": {
+                            "title": "Start Datetime",
+                            "type": "string",
+                            "format": "date-time",
+                        },
+                        "end_datetime": {
+                            "title": "End Datetime",
+                            "type": "string",
+                            "format": "date-time",
+                        },
+                        "repeat_at": {
+                            "title": "Repeat At",
+                            "type": "string",
+                            "format": "time",
+                        },
+                        "process_after": {
+                            "title": "Process After",
+                            "type": "number",
+                            "format": "time-delta",
+                        },
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 4efdecc53ad2e1309c28c5785968d8eafa856fbc..5413fe428b72fc957bfdcf11d08d5ad2e0f68c63 100644 (file)
@@ -3,111 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "put": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__item_id__put",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Item Id",
-                            "type": "string",
-                            "format": "uuid",
-                        },
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_read_items_items__item_id__put"
-                            }
-                        }
-                    }
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Body_read_items_items__item_id__put": {
-                "title": "Body_read_items_items__item_id__put",
-                "type": "object",
-                "properties": {
-                    "start_datetime": {
-                        "title": "Start Datetime",
-                        "type": "string",
-                        "format": "date-time",
-                    },
-                    "end_datetime": {
-                        "title": "End Datetime",
-                        "type": "string",
-                        "format": "date-time",
-                    },
-                    "repeat_at": {
-                        "title": "Repeat At",
-                        "type": "string",
-                        "format": "time",
-                    },
-                    "process_after": {
-                        "title": "Process After",
-                        "type": "number",
-                        "format": "time-delta",
-                    },
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -117,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_extra_types(client: TestClient):
     item_id = "ff97dd87-a4a5-4a12-b412-cde99f33e00e"
@@ -144,3 +32,115 @@ def test_extra_types(client: TestClient):
     response = client.put(f"/items/{item_id}", json=data)
     assert response.status_code == 200, response.text
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "put": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__item_id__put",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {
+                                "title": "Item Id",
+                                "type": "string",
+                                "format": "uuid",
+                            },
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_read_items_items__item_id__put"
+                                }
+                            }
+                        }
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Body_read_items_items__item_id__put": {
+                    "title": "Body_read_items_items__item_id__put",
+                    "type": "object",
+                    "properties": {
+                        "start_datetime": {
+                            "title": "Start Datetime",
+                            "type": "string",
+                            "format": "date-time",
+                        },
+                        "end_datetime": {
+                            "title": "End Datetime",
+                            "type": "string",
+                            "format": "date-time",
+                        },
+                        "repeat_at": {
+                            "title": "Repeat At",
+                            "type": "string",
+                            "format": "time",
+                        },
+                        "process_after": {
+                            "title": "Process After",
+                            "type": "number",
+                            "format": "time-delta",
+                        },
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index f1433470c1ad9d2d9349704a1609acbd2ea0e101..f08bf4c50970872ec898da7d00c1448197440c4e 100644 (file)
@@ -4,107 +4,6 @@ from docs_src.extra_models.tutorial003 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Item Items  Item Id  Get",
-                                    "anyOf": [
-                                        {"$ref": "#/components/schemas/PlaneItem"},
-                                        {"$ref": "#/components/schemas/CarItem"},
-                                    ],
-                                }
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "PlaneItem": {
-                "title": "PlaneItem",
-                "required": ["description", "size"],
-                "type": "object",
-                "properties": {
-                    "description": {"title": "Description", "type": "string"},
-                    "type": {"title": "Type", "type": "string", "default": "plane"},
-                    "size": {"title": "Size", "type": "integer"},
-                },
-            },
-            "CarItem": {
-                "title": "CarItem",
-                "required": ["description"],
-                "type": "object",
-                "properties": {
-                    "description": {"title": "Description", "type": "string"},
-                    "type": {"title": "Type", "type": "string", "default": "car"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_car():
     response = client.get("/items/item1")
@@ -123,3 +22,104 @@ def test_get_plane():
         "type": "plane",
         "size": 5,
     }
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Item Items  Item Id  Get",
+                                        "anyOf": [
+                                            {"$ref": "#/components/schemas/PlaneItem"},
+                                            {"$ref": "#/components/schemas/CarItem"},
+                                        ],
+                                    }
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "PlaneItem": {
+                    "title": "PlaneItem",
+                    "required": ["description", "size"],
+                    "type": "object",
+                    "properties": {
+                        "description": {"title": "Description", "type": "string"},
+                        "type": {"title": "Type", "type": "string", "default": "plane"},
+                        "size": {"title": "Size", "type": "integer"},
+                    },
+                },
+                "CarItem": {
+                    "title": "CarItem",
+                    "required": ["description"],
+                    "type": "object",
+                    "properties": {
+                        "description": {"title": "Description", "type": "string"},
+                        "type": {"title": "Type", "type": "string", "default": "car"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 56fd83ad3a24d12c090e54c1b938f2de868d3206..407c717873a839204c3c597368e35b455c735a24 100644 (file)
@@ -3,101 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Item Items  Item Id  Get",
-                                    "anyOf": [
-                                        {"$ref": "#/components/schemas/PlaneItem"},
-                                        {"$ref": "#/components/schemas/CarItem"},
-                                    ],
-                                }
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "PlaneItem": {
-                "title": "PlaneItem",
-                "required": ["description", "size"],
-                "type": "object",
-                "properties": {
-                    "description": {"title": "Description", "type": "string"},
-                    "type": {"title": "Type", "type": "string", "default": "plane"},
-                    "size": {"title": "Size", "type": "integer"},
-                },
-            },
-            "CarItem": {
-                "title": "CarItem",
-                "required": ["description"],
-                "type": "object",
-                "properties": {
-                    "description": {"title": "Description", "type": "string"},
-                    "type": {"title": "Type", "type": "string", "default": "car"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -107,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_get_car(client: TestClient):
     response = client.get("/items/item1")
@@ -133,3 +31,105 @@ def test_get_plane(client: TestClient):
         "type": "plane",
         "size": 5,
     }
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Item Items  Item Id  Get",
+                                        "anyOf": [
+                                            {"$ref": "#/components/schemas/PlaneItem"},
+                                            {"$ref": "#/components/schemas/CarItem"},
+                                        ],
+                                    }
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "PlaneItem": {
+                    "title": "PlaneItem",
+                    "required": ["description", "size"],
+                    "type": "object",
+                    "properties": {
+                        "description": {"title": "Description", "type": "string"},
+                        "type": {"title": "Type", "type": "string", "default": "plane"},
+                        "size": {"title": "Size", "type": "integer"},
+                    },
+                },
+                "CarItem": {
+                    "title": "CarItem",
+                    "required": ["description"],
+                    "type": "object",
+                    "properties": {
+                        "description": {"title": "Description", "type": "string"},
+                        "type": {"title": "Type", "type": "string", "default": "car"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 548fb88340b409b57071b18f29759b80d393b927..47790ba8f94dded5d5d77974368d0c7c7bd778f3 100644 (file)
@@ -4,52 +4,6 @@ from docs_src.extra_models.tutorial004 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Items Items  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/Item"},
-                                }
-                            }
-                        },
-                    }
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "description"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                },
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_items():
     response = client.get("/items/")
@@ -58,3 +12,47 @@ def test_get_items():
         {"name": "Foo", "description": "There comes my hero"},
         {"name": "Red", "description": "It's my aeroplane"},
     ]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Items Items  Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/Item"},
+                                    }
+                                }
+                            },
+                        }
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "description"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                    },
+                }
+            }
+        },
+    }
index 7f4f5b9bebf23825406664d8fca0674f0eaa1c82..a98700172a1b6522a132b236dcb1e6a374bf903c 100644 (file)
@@ -3,46 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Items Items  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/Item"},
-                                }
-                            }
-                        },
-                    }
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "description"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                },
-            }
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -52,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_get_items(client: TestClient):
     response = client.get("/items/")
@@ -67,3 +20,48 @@ def test_get_items(client: TestClient):
         {"name": "Foo", "description": "There comes my hero"},
         {"name": "Red", "description": "It's my aeroplane"},
     ]
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Items Items  Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/Item"},
+                                    }
+                                }
+                            },
+                        }
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "description"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                    },
+                }
+            }
+        },
+    }
index c3dfaa42f772030244d97764b4500dc236c46327..7c094b2538365220ae5def48c005f2e62f743d7e 100644 (file)
@@ -4,41 +4,39 @@ from docs_src.extra_models.tutorial005 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/keyword-weights/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Keyword Weights Keyword Weights  Get",
-                                    "type": "object",
-                                    "additionalProperties": {"type": "number"},
-                                }
-                            }
-                        },
-                    }
-                },
-                "summary": "Read Keyword Weights",
-                "operationId": "read_keyword_weights_keyword_weights__get",
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_items():
     response = client.get("/keyword-weights/")
     assert response.status_code == 200, response.text
     assert response.json() == {"foo": 2.3, "bar": 3.4}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/keyword-weights/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Keyword Weights Keyword Weights  Get",
+                                        "type": "object",
+                                        "additionalProperties": {"type": "number"},
+                                    }
+                                }
+                            },
+                        }
+                    },
+                    "summary": "Read Keyword Weights",
+                    "operationId": "read_keyword_weights_keyword_weights__get",
+                }
+            }
+        },
+    }
index 3bb5a99f105844dfd3d4be56e9e3e325492dc077..b403864501ee11d60f748613ea7d7a9026d99919 100644 (file)
@@ -3,33 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/keyword-weights/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Keyword Weights Keyword Weights  Get",
-                                    "type": "object",
-                                    "additionalProperties": {"type": "number"},
-                                }
-                            }
-                        },
-                    }
-                },
-                "summary": "Read Keyword Weights",
-                "operationId": "read_keyword_weights_keyword_weights__get",
-            }
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -40,14 +13,39 @@ def get_client():
 
 
 @needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
+def test_get_items(client: TestClient):
+    response = client.get("/keyword-weights/")
     assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
+    assert response.json() == {"foo": 2.3, "bar": 3.4}
 
 
 @needs_py39
-def test_get_items(client: TestClient):
-    response = client.get("/keyword-weights/")
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == {"foo": 2.3, "bar": 3.4}
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/keyword-weights/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Keyword Weights Keyword Weights  Get",
+                                        "type": "object",
+                                        "additionalProperties": {"type": "number"},
+                                    }
+                                }
+                            },
+                        }
+                    },
+                    "summary": "Read Keyword Weights",
+                    "operationId": "read_keyword_weights_keyword_weights__get",
+                }
+            }
+        },
+    }
index 48d42285c8e704c7870ab756d52f3849809e6312..ea37aec53a95f3126eb724f612b573c052b95a0f 100644 (file)
@@ -5,35 +5,38 @@ from docs_src.first_steps.tutorial001 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Root",
-                "operationId": "root__get",
-            }
-        }
-    },
-}
-
 
 @pytest.mark.parametrize(
     "path,expected_status,expected_response",
     [
         ("/", 200, {"message": "Hello World"}),
         ("/nonexistent", 404, {"detail": "Not Found"}),
-        ("/openapi.json", 200, openapi_schema),
     ],
 )
 def test_get_path(path, expected_status, expected_response):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Root",
+                    "operationId": "root__get",
+                }
+            }
+        },
+    }
index 128fcea3094dd8ae8f27a1d7b5ceb4b3828eb776..8b22eab9eec38850928a9a7ed0472aa277a70ed1 100644 (file)
@@ -4,185 +4,184 @@ from docs_src.generate_clients.tutorial003 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "tags": ["items"],
-                "summary": "Get Items",
-                "operationId": "items-get_items",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Items-Get Items",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/Item"},
+
+def test_post_items():
+    response = client.post("/items/", json={"name": "Foo", "price": 5})
+    assert response.status_code == 200, response.text
+    assert response.json() == {"message": "Item received"}
+
+
+def test_post_users():
+    response = client.post(
+        "/users/", json={"username": "Foo", "email": "foo@example.com"}
+    )
+    assert response.status_code == 200, response.text
+    assert response.json() == {"message": "User received"}
+
+
+def test_get_items():
+    response = client.get("/items/")
+    assert response.status_code == 200, response.text
+    assert response.json() == [
+        {"name": "Plumbus", "price": 3},
+        {"name": "Portal Gun", "price": 9001},
+    ]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "tags": ["items"],
+                    "summary": "Get Items",
+                    "operationId": "items-get_items",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Items-Get Items",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/Item"},
+                                    }
                                 }
-                            }
-                        },
-                    }
-                },
-            },
-            "post": {
-                "tags": ["items"],
-                "summary": "Create Item",
-                "operationId": "items-create_item",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
+                            },
                         }
                     },
-                    "required": True,
                 },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
+                "post": {
+                    "tags": ["items"],
+                    "summary": "Create Item",
+                    "operationId": "items-create_item",
+                    "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/ResponseMessage"
-                                }
+                                "schema": {"$ref": "#/components/schemas/Item"}
                             }
                         },
+                        "required": True,
                     },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/ResponseMessage"
+                                    }
                                 }
-                            }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
                         },
                     },
                 },
             },
-        },
-        "/users/": {
-            "post": {
-                "tags": ["users"],
-                "summary": "Create User",
-                "operationId": "users-create_user",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/User"}
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
+            "/users/": {
+                "post": {
+                    "tags": ["users"],
+                    "summary": "Create User",
+                    "operationId": "users-create_user",
+                    "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/ResponseMessage"
-                                }
+                                "schema": {"$ref": "#/components/schemas/User"}
                             }
                         },
+                        "required": True,
                     },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/ResponseMessage"
+                                    }
                                 }
-                            }
+                            },
+                        },
+                        "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
+        "components": {
+            "schemas": {
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
                 },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                    },
                 },
-            },
-            "ResponseMessage": {
-                "title": "ResponseMessage",
-                "required": ["message"],
-                "type": "object",
-                "properties": {"message": {"title": "Message", "type": "string"}},
-            },
-            "User": {
-                "title": "User",
-                "required": ["username", "email"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "email": {"title": "Email", "type": "string"},
+                "ResponseMessage": {
+                    "title": "ResponseMessage",
+                    "required": ["message"],
+                    "type": "object",
+                    "properties": {"message": {"title": "Message", "type": "string"}},
                 },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
+                "User": {
+                    "title": "User",
+                    "required": ["username", "email"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "email": {"title": "Email", "type": "string"},
                     },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
                 },
-            },
-        }
-    },
-}
-
-
-def test_openapi():
-    with client:
-        response = client.get("/openapi.json")
-
-        assert response.json() == openapi_schema
-
-
-def test_post_items():
-    response = client.post("/items/", json={"name": "Foo", "price": 5})
-    assert response.status_code == 200, response.text
-    assert response.json() == {"message": "Item received"}
-
-
-def test_post_users():
-    response = client.post(
-        "/users/", json={"username": "Foo", "email": "foo@example.com"}
-    )
-    assert response.status_code == 200, response.text
-    assert response.json() == {"message": "User received"}
-
-
-def test_get_items():
-    response = client.get("/items/")
-    assert response.status_code == 200, response.text
-    assert response.json() == [
-        {"name": "Plumbus", "price": 3},
-        {"name": "Portal Gun", "price": 9001},
-    ]
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index ffd79ccff3a6c02fb20c8426fbb6277c4763cf03..99a1053caba2844545dc40d51e0685b07aff1487 100644 (file)
@@ -4,78 +4,6 @@ from docs_src.handling_errors.tutorial001 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_item():
     response = client.get("/items/foo")
@@ -88,3 +16,75 @@ def test_get_item_not_found():
     assert response.status_code == 404, response.text
     assert response.headers.get("x-error") is None
     assert response.json() == {"detail": "Item not found"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index e678499c63a2b26bdcb42018d211df94a04dba40..091c74f4de9a047e5ad6672a7c3cc3e280d8d60a 100644 (file)
@@ -4,78 +4,6 @@ from docs_src.handling_errors.tutorial002 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items-header/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item Header",
-                "operationId": "read_item_header_items_header__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_item_header():
     response = client.get("/items-header/foo")
@@ -88,3 +16,75 @@ def test_get_item_not_found_header():
     assert response.status_code == 404, response.text
     assert response.headers.get("x-error") == "There goes my error"
     assert response.json() == {"detail": "Item not found"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items-header/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item Header",
+                    "operationId": "read_item_header_items_header__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index a01726dc2d39950606eb25c1098e7cc348fd7d53..1639cb1d8b67b95a3f54c3d4a48e1922b87ec753 100644 (file)
@@ -4,78 +4,6 @@ from docs_src.handling_errors.tutorial003 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/unicorns/{name}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Unicorn",
-                "operationId": "read_unicorn_unicorns__name__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Name", "type": "string"},
-                        "name": "name",
-                        "in": "path",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get():
     response = client.get("/unicorns/shinny")
@@ -89,3 +17,75 @@ def test_get_exception():
     assert response.json() == {
         "message": "Oops! yolo did something. There goes a rainbow..."
     }
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/unicorns/{name}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Unicorn",
+                    "operationId": "read_unicorn_unicorns__name__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Name", "type": "string"},
+                            "name": "name",
+                            "in": "path",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 0b5f747986cf79d46072195de3d3813c490db7a2..246f3b94c18f315a760a07b15f1cbff7b63b0a62 100644 (file)
@@ -4,78 +4,6 @@ from docs_src.handling_errors.tutorial004 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "integer"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_validation_error():
     response = client.get("/items/foo")
@@ -98,3 +26,75 @@ def test_get():
     response = client.get("/items/2")
     assert response.status_code == 200, response.text
     assert response.json() == {"item_id": 2}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "integer"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 253f3d006a7c5526cad3287211d334c723802db3..af47fd1a4f52c9c58ea5ba96d6f975a64eae32c6 100644 (file)
@@ -4,87 +4,6 @@ from docs_src.handling_errors.tutorial005 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "post": {
-                "summary": "Create Item",
-                "operationId": "create_item_items__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    },
-                    "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["title", "size"],
-                "type": "object",
-                "properties": {
-                    "title": {"title": "Title", "type": "string"},
-                    "size": {"title": "Size", "type": "integer"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_post_validation_error():
     response = client.post("/items/", json={"title": "towel", "size": "XL"})
@@ -106,3 +25,84 @@ def test_post():
     response = client.post("/items/", json=data)
     assert response.status_code == 200, response.text
     assert response.json() == data
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "post": {
+                    "summary": "Create Item",
+                    "operationId": "create_item_items__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        },
+                        "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "Item": {
+                    "title": "Item",
+                    "required": ["title", "size"],
+                    "type": "object",
+                    "properties": {
+                        "title": {"title": "Title", "type": "string"},
+                        "size": {"title": "Size", "type": "integer"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 21233d7bbf41555acd3e5a8cc785295f1096272c..4a39bd102268a956aec934842f432cd128f5918b 100644 (file)
@@ -4,78 +4,6 @@ from docs_src.handling_errors.tutorial006 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "integer"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_validation_error():
     response = client.get("/items/foo")
@@ -101,3 +29,75 @@ def test_get():
     response = client.get("/items/2")
     assert response.status_code == 200, response.text
     assert response.json() == {"item_id": 2}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "integer"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 273cf3249ee44db85edf9539c9306fe830485751..80f502d6a8cc2f82e998eed69c7c36290911490a 100644 (file)
@@ -6,77 +6,9 @@ from docs_src.header_params.tutorial001 import app
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "User-Agent", "type": "string"},
-                        "name": "user-agent",
-                        "in": "header",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
 @pytest.mark.parametrize(
     "path,headers,expected_status,expected_response",
     [
-        ("/openapi.json", None, 200, openapi_schema),
         ("/items", None, 200, {"User-Agent": "testclient"}),
         ("/items", {"X-Header": "notvalid"}, 200, {"User-Agent": "testclient"}),
         ("/items", {"User-Agent": "FastAPI test"}, 200, {"User-Agent": "FastAPI test"}),
@@ -86,3 +18,75 @@ def test(path, headers, expected_status, expected_response):
     response = client.get(path, headers=headers)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "User-Agent", "type": "string"},
+                            "name": "user-agent",
+                            "in": "header",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 3c155f786d8b69f064a7fd225e19062621220e6a..f0ad7b81600818ec00861d9ca73442f8a1dda186 100644 (file)
@@ -6,77 +6,9 @@ from docs_src.header_params.tutorial001_an import app
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "User-Agent", "type": "string"},
-                        "name": "user-agent",
-                        "in": "header",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
 @pytest.mark.parametrize(
     "path,headers,expected_status,expected_response",
     [
-        ("/openapi.json", None, 200, openapi_schema),
         ("/items", None, 200, {"User-Agent": "testclient"}),
         ("/items", {"X-Header": "notvalid"}, 200, {"User-Agent": "testclient"}),
         ("/items", {"User-Agent": "FastAPI test"}, 200, {"User-Agent": "FastAPI test"}),
@@ -86,3 +18,75 @@ def test(path, headers, expected_status, expected_response):
     response = client.get(path, headers=headers)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "User-Agent", "type": "string"},
+                            "name": "user-agent",
+                            "in": "header",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 1f86f2a5d059c0c8e27ecf71891e327e72721621..d095c71233037fdfd3f07cb17631aad55cc860c5 100644 (file)
@@ -3,72 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "User-Agent", "type": "string"},
-                        "name": "user-agent",
-                        "in": "header",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -82,7 +16,6 @@ def get_client():
 @pytest.mark.parametrize(
     "path,headers,expected_status,expected_response",
     [
-        ("/openapi.json", None, 200, openapi_schema),
         ("/items", None, 200, {"User-Agent": "testclient"}),
         ("/items", {"X-Header": "notvalid"}, 200, {"User-Agent": "testclient"}),
         ("/items", {"User-Agent": "FastAPI test"}, 200, {"User-Agent": "FastAPI test"}),
@@ -92,3 +25,76 @@ def test(path, headers, expected_status, expected_response, client: TestClient):
     response = client.get(path, headers=headers)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "User-Agent", "type": "string"},
+                            "name": "user-agent",
+                            "in": "header",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 77a60eb9db976415f5b432a5fa6aef6e4d027d34..bf176bba27694bc67c757329992254e871d10ba7 100644 (file)
@@ -3,72 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "User-Agent", "type": "string"},
-                        "name": "user-agent",
-                        "in": "header",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -82,7 +16,6 @@ def get_client():
 @pytest.mark.parametrize(
     "path,headers,expected_status,expected_response",
     [
-        ("/openapi.json", None, 200, openapi_schema),
         ("/items", None, 200, {"User-Agent": "testclient"}),
         ("/items", {"X-Header": "notvalid"}, 200, {"User-Agent": "testclient"}),
         ("/items", {"User-Agent": "FastAPI test"}, 200, {"User-Agent": "FastAPI test"}),
@@ -92,3 +25,76 @@ def test(path, headers, expected_status, expected_response, client: TestClient):
     response = client.get(path, headers=headers)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "User-Agent", "type": "string"},
+                            "name": "user-agent",
+                            "in": "header",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index b233982873339dee4b061c7a9b48ab3f78561fae..516abda8bf45f001a6f28fb511d4580c3a1bf707 100644 (file)
@@ -6,77 +6,9 @@ from docs_src.header_params.tutorial002 import app
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Strange Header", "type": "string"},
-                        "name": "strange_header",
-                        "in": "header",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
 @pytest.mark.parametrize(
     "path,headers,expected_status,expected_response",
     [
-        ("/openapi.json", None, 200, openapi_schema),
         ("/items", None, 200, {"strange_header": None}),
         ("/items", {"X-Header": "notvalid"}, 200, {"strange_header": None}),
         (
@@ -97,3 +29,75 @@ def test(path, headers, expected_status, expected_response):
     response = client.get(path, headers=headers)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Strange Header", "type": "string"},
+                            "name": "strange_header",
+                            "in": "header",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 77d236e09ff629fb515b75523a0e4aa532ffaf34..97493e60402cc2ab205b446fc978efc437efe934 100644 (file)
@@ -6,77 +6,9 @@ from docs_src.header_params.tutorial002_an import app
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Strange Header", "type": "string"},
-                        "name": "strange_header",
-                        "in": "header",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
 @pytest.mark.parametrize(
     "path,headers,expected_status,expected_response",
     [
-        ("/openapi.json", None, 200, openapi_schema),
         ("/items", None, 200, {"strange_header": None}),
         ("/items", {"X-Header": "notvalid"}, 200, {"strange_header": None}),
         (
@@ -97,3 +29,75 @@ def test(path, headers, expected_status, expected_response):
     response = client.get(path, headers=headers)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Strange Header", "type": "string"},
+                            "name": "strange_header",
+                            "in": "header",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 49b0ef462f447eb867c35df43e6e9c9b3269d42c..e0c60342a79be80230f35d9abf0bca8937e4b90e 100644 (file)
@@ -3,72 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Strange Header", "type": "string"},
-                        "name": "strange_header",
-                        "in": "header",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -82,7 +16,6 @@ def get_client():
 @pytest.mark.parametrize(
     "path,headers,expected_status,expected_response",
     [
-        ("/openapi.json", None, 200, openapi_schema),
         ("/items", None, 200, {"strange_header": None}),
         ("/items", {"X-Header": "notvalid"}, 200, {"strange_header": None}),
         (
@@ -103,3 +36,76 @@ def test(path, headers, expected_status, expected_response, client: TestClient):
     response = client.get(path, headers=headers)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Strange Header", "type": "string"},
+                            "name": "strange_header",
+                            "in": "header",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 13aaabeb87b4cf10e41b76517803d5d244e8acae..c1bc5faf8a7d96acdac861ad0d0410b7a053870a 100644 (file)
@@ -3,72 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Strange Header", "type": "string"},
-                        "name": "strange_header",
-                        "in": "header",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -82,7 +16,6 @@ def get_client():
 @pytest.mark.parametrize(
     "path,headers,expected_status,expected_response",
     [
-        ("/openapi.json", None, 200, openapi_schema),
         ("/items", None, 200, {"strange_header": None}),
         ("/items", {"X-Header": "notvalid"}, 200, {"strange_header": None}),
         (
@@ -103,3 +36,79 @@ def test(path, headers, expected_status, expected_response, client: TestClient):
     response = client.get(path, headers=headers)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py39
+def test_openapi_schema():
+    from docs_src.header_params.tutorial002_an_py39 import app
+
+    client = TestClient(app)
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Strange Header", "type": "string"},
+                            "name": "strange_header",
+                            "in": "header",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 6cae3d338106031edd419380821433d4deb6577a..81871b8c6d85756ded978f05dedcfca9f79d9f79 100644 (file)
@@ -3,72 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Strange Header", "type": "string"},
-                        "name": "strange_header",
-                        "in": "header",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -82,7 +16,6 @@ def get_client():
 @pytest.mark.parametrize(
     "path,headers,expected_status,expected_response",
     [
-        ("/openapi.json", None, 200, openapi_schema),
         ("/items", None, 200, {"strange_header": None}),
         ("/items", {"X-Header": "notvalid"}, 200, {"strange_header": None}),
         (
@@ -103,3 +36,79 @@ def test(path, headers, expected_status, expected_response, client: TestClient):
     response = client.get(path, headers=headers)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema():
+    from docs_src.header_params.tutorial002_py310 import app
+
+    client = TestClient(app)
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {"title": "Strange Header", "type": "string"},
+                            "name": "strange_header",
+                            "in": "header",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index b7281e29350a6de151394dc8236e741588de1ea5..f1ddc32595225c736cf78cc08eb5f1e88bb347b9 100644 (file)
@@ -4,47 +4,45 @@ from docs_src.metadata.tutorial001 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {
-        "title": "ChimichangApp",
-        "description": "\nChimichangApp API helps you do awesome stuff. 🚀\n\n## Items\n\nYou can **read items**.\n\n## Users\n\nYou will be able to:\n\n* **Create users** (_not implemented_).\n* **Read users** (_not implemented_).\n",
-        "termsOfService": "http://example.com/terms/",
-        "contact": {
-            "name": "Deadpoolio the Amazing",
-            "url": "http://x-force.example.com/contact/",
-            "email": "dp@x-force.example.com",
-        },
-        "license": {
-            "name": "Apache 2.0",
-            "url": "https://www.apache.org/licenses/LICENSE-2.0.html",
-        },
-        "version": "0.0.1",
-    },
-    "paths": {
-        "/items/": {
-            "get": {
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_items():
     response = client.get("/items/")
     assert response.status_code == 200, response.text
     assert response.json() == [{"name": "Katana"}]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {
+            "title": "ChimichangApp",
+            "description": "\nChimichangApp API helps you do awesome stuff. 🚀\n\n## Items\n\nYou can **read items**.\n\n## Users\n\nYou will be able to:\n\n* **Create users** (_not implemented_).\n* **Read users** (_not implemented_).\n",
+            "termsOfService": "http://example.com/terms/",
+            "contact": {
+                "name": "Deadpoolio the Amazing",
+                "url": "http://x-force.example.com/contact/",
+                "email": "dp@x-force.example.com",
+            },
+            "license": {
+                "name": "Apache 2.0",
+                "url": "https://www.apache.org/licenses/LICENSE-2.0.html",
+            },
+            "version": "0.0.1",
+        },
+        "paths": {
+            "/items/": {
+                "get": {
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            }
+        },
+    }
index 2d255b8b0da4bd79bf45947299490860452c3da2..f7f47a558eab2755ae4bf62442abbbaa12f74536 100644 (file)
@@ -4,62 +4,60 @@ from docs_src.metadata.tutorial004 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/": {
-            "get": {
-                "tags": ["users"],
-                "summary": "Get Users",
-                "operationId": "get_users_users__get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-        "/items/": {
-            "get": {
-                "tags": ["items"],
-                "summary": "Get Items",
-                "operationId": "get_items_items__get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-    },
-    "tags": [
-        {
-            "name": "users",
-            "description": "Operations with users. The **login** logic is also here.",
-        },
-        {
-            "name": "items",
-            "description": "Manage items. So _fancy_ they have their own docs.",
-            "externalDocs": {
-                "description": "Items external docs",
-                "url": "https://fastapi.tiangolo.com/",
-            },
-        },
-    ],
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_path_operations():
     response = client.get("/items/")
     assert response.status_code == 200, response.text
     response = client.get("/users/")
     assert response.status_code == 200, response.text
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/": {
+                "get": {
+                    "tags": ["users"],
+                    "summary": "Get Users",
+                    "operationId": "get_users_users__get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+            "/items/": {
+                "get": {
+                    "tags": ["items"],
+                    "summary": "Get Items",
+                    "operationId": "get_items_items__get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+        },
+        "tags": [
+            {
+                "name": "users",
+                "description": "Operations with users. The **login** logic is also here.",
+            },
+            {
+                "name": "items",
+                "description": "Manage items. So _fancy_ they have their own docs.",
+                "externalDocs": {
+                    "description": "Items external docs",
+                    "url": "https://fastapi.tiangolo.com/",
+                },
+            },
+        ],
+    }
index e773e7f8f550f5e2a2030015d228490ea01f0141..c6cdc60648c00feb8b2fd7edfa840fabe7ab62f2 100644 (file)
@@ -4,171 +4,170 @@ from docs_src.openapi_callbacks.tutorial001 import app, invoice_notification
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/invoices/": {
-            "post": {
-                "summary": "Create Invoice",
-                "description": 'Create an invoice.\n\nThis will (let\'s imagine) let the API user (some external developer) create an\ninvoice.\n\nAnd this path operation will:\n\n* Send the invoice to the client.\n* Collect the money from the client.\n* Send a notification back to the API user (the external developer), as a callback.\n    * At this point is that the API will somehow send a POST request to the\n        external API with the notification of the invoice event\n        (e.g. "payment successful").',
-                "operationId": "create_invoice_invoices__post",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Callback Url",
-                            "maxLength": 2083,
-                            "minLength": 1,
-                            "type": "string",
-                            "format": "uri",
-                        },
-                        "name": "callback_url",
-                        "in": "query",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Invoice"}
+
+def test_get():
+    response = client.post(
+        "/invoices/", json={"id": "fooinvoice", "customer": "John", "total": 5.3}
+    )
+    assert response.status_code == 200, response.text
+    assert response.json() == {"msg": "Invoice received"}
+
+
+def test_dummy_callback():
+    # Just for coverage
+    invoice_notification({})
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/invoices/": {
+                "post": {
+                    "summary": "Create Invoice",
+                    "description": 'Create an invoice.\n\nThis will (let\'s imagine) let the API user (some external developer) create an\ninvoice.\n\nAnd this path operation will:\n\n* Send the invoice to the client.\n* Collect the money from the client.\n* Send a notification back to the API user (the external developer), as a callback.\n    * At this point is that the API will somehow send a POST request to the\n        external API with the notification of the invoice event\n        (e.g. "payment successful").',
+                    "operationId": "create_invoice_invoices__post",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Callback Url",
+                                "maxLength": 2083,
+                                "minLength": 1,
+                                "type": "string",
+                                "format": "uri",
+                            },
+                            "name": "callback_url",
+                            "in": "query",
                         }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
+                    ],
+                    "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
+                                "schema": {"$ref": "#/components/schemas/Invoice"}
                             }
                         },
+                        "required": True,
                     },
-                },
-                "callbacks": {
-                    "invoice_notification": {
-                        "{$callback_url}/invoices/{$request.body.id}": {
-                            "post": {
-                                "summary": "Invoice Notification",
-                                "operationId": "invoice_notification__callback_url__invoices___request_body_id__post",
-                                "requestBody": {
-                                    "required": True,
-                                    "content": {
-                                        "application/json": {
-                                            "schema": {
-                                                "$ref": "#/components/schemas/InvoiceEvent"
-                                            }
-                                        }
-                                    },
-                                },
-                                "responses": {
-                                    "200": {
-                                        "description": "Successful Response",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "callbacks": {
+                        "invoice_notification": {
+                            "{$callback_url}/invoices/{$request.body.id}": {
+                                "post": {
+                                    "summary": "Invoice Notification",
+                                    "operationId": "invoice_notification__callback_url__invoices___request_body_id__post",
+                                    "requestBody": {
+                                        "required": True,
                                         "content": {
                                             "application/json": {
                                                 "schema": {
-                                                    "$ref": "#/components/schemas/InvoiceEventReceived"
+                                                    "$ref": "#/components/schemas/InvoiceEvent"
                                                 }
                                             }
                                         },
                                     },
-                                    "422": {
-                                        "description": "Validation Error",
-                                        "content": {
-                                            "application/json": {
-                                                "schema": {
-                                                    "$ref": "#/components/schemas/HTTPValidationError"
+                                    "responses": {
+                                        "200": {
+                                            "description": "Successful Response",
+                                            "content": {
+                                                "application/json": {
+                                                    "schema": {
+                                                        "$ref": "#/components/schemas/InvoiceEventReceived"
+                                                    }
                                                 }
-                                            }
+                                            },
+                                        },
+                                        "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
+        },
+        "components": {
+            "schemas": {
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
                 },
-            },
-            "Invoice": {
-                "title": "Invoice",
-                "required": ["id", "customer", "total"],
-                "type": "object",
-                "properties": {
-                    "id": {"title": "Id", "type": "string"},
-                    "title": {"title": "Title", "type": "string"},
-                    "customer": {"title": "Customer", "type": "string"},
-                    "total": {"title": "Total", "type": "number"},
+                "Invoice": {
+                    "title": "Invoice",
+                    "required": ["id", "customer", "total"],
+                    "type": "object",
+                    "properties": {
+                        "id": {"title": "Id", "type": "string"},
+                        "title": {"title": "Title", "type": "string"},
+                        "customer": {"title": "Customer", "type": "string"},
+                        "total": {"title": "Total", "type": "number"},
+                    },
+                },
+                "InvoiceEvent": {
+                    "title": "InvoiceEvent",
+                    "required": ["description", "paid"],
+                    "type": "object",
+                    "properties": {
+                        "description": {"title": "Description", "type": "string"},
+                        "paid": {"title": "Paid", "type": "boolean"},
+                    },
                 },
-            },
-            "InvoiceEvent": {
-                "title": "InvoiceEvent",
-                "required": ["description", "paid"],
-                "type": "object",
-                "properties": {
-                    "description": {"title": "Description", "type": "string"},
-                    "paid": {"title": "Paid", "type": "boolean"},
+                "InvoiceEventReceived": {
+                    "title": "InvoiceEventReceived",
+                    "required": ["ok"],
+                    "type": "object",
+                    "properties": {"ok": {"title": "Ok", "type": "boolean"}},
                 },
-            },
-            "InvoiceEventReceived": {
-                "title": "InvoiceEventReceived",
-                "required": ["ok"],
-                "type": "object",
-                "properties": {"ok": {"title": "Ok", "type": "boolean"}},
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
                     },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
                 },
-            },
-        }
-    },
-}
-
-
-def test_openapi():
-    with client:
-        response = client.get("/openapi.json")
-
-        assert response.json() == openapi_schema
-
-
-def test_get():
-    response = client.post(
-        "/invoices/", json={"id": "fooinvoice", "customer": "John", "total": 5.3}
-    )
-    assert response.status_code == 200, response.text
-    assert response.json() == {"msg": "Invoice received"}
-
-
-def test_dummy_callback():
-    # Just for coverage
-    invoice_notification({})
+            }
+        },
+    }
index 3b5301348f7a6e921cd092c77c41a77024c22dce..c1cdbee2411dc6a5c09fac5e6ce4754d9437dea4 100644 (file)
@@ -4,33 +4,31 @@ from docs_src.path_operation_advanced_configuration.tutorial001 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Items",
-                "operationId": "some_specific_id_you_define",
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get():
     response = client.get("/items/")
     assert response.status_code == 200, response.text
     assert response.json() == [{"item_id": "Foo"}]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Items",
+                    "operationId": "some_specific_id_you_define",
+                }
+            }
+        },
+    }
index 01acb664c77dd26c5106a53979d4c914d91f4c4b..fdaddd01878ebe48c28ad30dde1f36240b1636b7 100644 (file)
@@ -4,33 +4,31 @@ from docs_src.path_operation_advanced_configuration.tutorial002 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Items",
-                "operationId": "read_items",
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get():
     response = client.get("/items/")
     assert response.status_code == 200, response.text
     assert response.json() == [{"item_id": "Foo"}]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items",
+                }
+            }
+        },
+    }
index 4a23db7bc1b9d39aa878375dec74d1f334c2e818..782c64a845ad81aaa73330bf223a4ab009bca881 100644 (file)
@@ -4,20 +4,18 @@ from docs_src.path_operation_advanced_configuration.tutorial003 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {},
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get():
     response = client.get("/items/")
     assert response.status_code == 200, response.text
     assert response.json() == [{"item_id": "Foo"}]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {},
+    }
index 3de19833beb2310b24b696ddfad1305bea3673ef..f5fd868eb7ce8dcf56bbf7740d3cfa28920441f0 100644 (file)
@@ -4,109 +4,109 @@ from docs_src.path_operation_advanced_configuration.tutorial004 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
+
+def test_query_params_str_validations():
+    response = client.post("/items/", json={"name": "Foo", "price": 42})
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "name": "Foo",
+        "price": 42,
+        "description": None,
+        "tax": None,
+        "tags": [],
+    }
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
                         },
                     },
-                    "422": {
-                        "description": "Validation Error",
+                    "summary": "Create an item",
+                    "description": "Create an item with all the information:\n\n- **name**: each item must have a name\n- **description**: a long description\n- **price**: required\n- **tax**: if the item doesn't have tax, you can omit this\n- **tags**: a set of unique tag strings for this item",
+                    "operationId": "create_item_items__post",
+                    "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
+                                "schema": {"$ref": "#/components/schemas/Item"}
                             }
                         },
+                        "required": True,
                     },
-                },
-                "summary": "Create an item",
-                "description": "Create an item with all the information:\n\n- **name**: each item must have a name\n- **description**: a long description\n- **price**: required\n- **tax**: if the item doesn't have tax, you can omit this\n- **tags**: a set of unique tag strings for this item",
-                "operationId": "create_item_items__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    },
-                    "required": True,
-                },
+                }
             }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number"},
-                    "tags": {
-                        "title": "Tags",
-                        "uniqueItems": True,
-                        "type": "array",
-                        "items": {"type": "string"},
-                        "default": [],
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number"},
+                        "tags": {
+                            "title": "Tags",
+                            "uniqueItems": True,
+                            "type": "array",
+                            "items": {"type": "string"},
+                            "default": [],
+                        },
                     },
                 },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
                     },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
                 },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
                 },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
-def test_query_params_str_validations():
-    response = client.post("/items/", json={"name": "Foo", "price": 42})
-    assert response.status_code == 200, response.text
-    assert response.json() == {
-        "name": "Foo",
-        "price": 42,
-        "description": None,
-        "tax": None,
-        "tags": [],
+            }
+        },
     }
index 5042d18375e6bf777ad1b5dff4bbf9ab151bbc82..52379c01e151118f7e7e43fde12bc3482fe6bd92 100644 (file)
@@ -4,33 +4,31 @@ from docs_src.path_operation_advanced_configuration.tutorial005 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "x-aperture-labs-portal": "blue",
-            }
-        }
-    },
-}
-
 
-def test_openapi_schema():
-    response = client.get("/openapi.json")
+def test_get():
+    response = client.get("/items/")
     assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
 
 
-def test_get():
-    response = client.get("/items/")
+def test_openapi_schema():
+    response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "x-aperture-labs-portal": "blue",
+                }
+            }
+        },
+    }
index 330b4e2c791babcb4545afcd78a8014c15662ebf..deb6b09101702b04ffdd0ffddc08de86b56f5201 100644 (file)
@@ -4,47 +4,6 @@ from docs_src.path_operation_advanced_configuration.tutorial006 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "post": {
-                "summary": "Create Item",
-                "operationId": "create_item_items__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {
-                                "required": ["name", "price"],
-                                "type": "object",
-                                "properties": {
-                                    "name": {"type": "string"},
-                                    "price": {"type": "number"},
-                                    "description": {"type": "string"},
-                                },
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_post():
     response = client.post("/items/", content=b"this is actually not validated")
@@ -57,3 +16,42 @@ def test_post():
             "description": "Just kiddin', no magic here. ✨",
         },
     }
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "post": {
+                    "summary": "Create Item",
+                    "operationId": "create_item_items__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {
+                                    "required": ["name", "price"],
+                                    "type": "object",
+                                    "properties": {
+                                        "name": {"type": "string"},
+                                        "price": {"type": "number"},
+                                        "description": {"type": "string"},
+                                    },
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            }
+        },
+    }
index 076f60b2f079d441b90e5bc363d150262f6ccedf..470956a77df7aae0b73a94e8a881acf45f946e80 100644 (file)
@@ -4,51 +4,6 @@ from docs_src.path_operation_advanced_configuration.tutorial007 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "post": {
-                "summary": "Create Item",
-                "operationId": "create_item_items__post",
-                "requestBody": {
-                    "content": {
-                        "application/x-yaml": {
-                            "schema": {
-                                "title": "Item",
-                                "required": ["name", "tags"],
-                                "type": "object",
-                                "properties": {
-                                    "name": {"title": "Name", "type": "string"},
-                                    "tags": {
-                                        "title": "Tags",
-                                        "type": "array",
-                                        "items": {"type": "string"},
-                                    },
-                                },
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_post():
     yaml_data = """
@@ -95,3 +50,46 @@ def test_post_invalid():
             {"loc": ["tags", 3], "msg": "str type expected", "type": "type_error.str"}
         ]
     }
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "post": {
+                    "summary": "Create Item",
+                    "operationId": "create_item_items__post",
+                    "requestBody": {
+                        "content": {
+                            "application/x-yaml": {
+                                "schema": {
+                                    "title": "Item",
+                                    "required": ["name", "tags"],
+                                    "type": "object",
+                                    "properties": {
+                                        "name": {"title": "Name", "type": "string"},
+                                        "tags": {
+                                            "title": "Tags",
+                                            "type": "array",
+                                            "items": {"type": "string"},
+                                        },
+                                    },
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            }
+        },
+    }
index be9f2afecf4ceb640ebfccb3b3edb5a4787deb66..76e44b5e59c3ab2208b3be45bd0f422baab6bad4 100644 (file)
@@ -4,45 +4,6 @@ from docs_src.path_operation_configuration.tutorial002b import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "tags": ["items"],
-                "summary": "Get Items",
-                "operationId": "get_items_items__get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-        "/users/": {
-            "get": {
-                "tags": ["users"],
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_items():
     response = client.get("/items/")
@@ -54,3 +15,40 @@ def test_get_users():
     response = client.get("/users/")
     assert response.status_code == 200, response.text
     assert response.json() == ["Rick", "Morty"]
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "tags": ["items"],
+                    "summary": "Get Items",
+                    "operationId": "get_items_items__get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+            "/users/": {
+                "get": {
+                    "tags": ["users"],
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+        },
+    }
index e587519a005344b5f509f1078254a0db7f37fcd2..cf8e203a0e1589f1aea151fcfbe7050e36be4372 100644 (file)
@@ -4,109 +4,109 @@ from docs_src.path_operation_configuration.tutorial005 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "The created item",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
+
+def test_query_params_str_validations():
+    response = client.post("/items/", json={"name": "Foo", "price": 42})
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "name": "Foo",
+        "price": 42,
+        "description": None,
+        "tax": None,
+        "tags": [],
+    }
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "The created item",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
                         },
                     },
-                    "422": {
-                        "description": "Validation Error",
+                    "summary": "Create an item",
+                    "description": "Create an item with all the information:\n\n- **name**: each item must have a name\n- **description**: a long description\n- **price**: required\n- **tax**: if the item doesn't have tax, you can omit this\n- **tags**: a set of unique tag strings for this item",
+                    "operationId": "create_item_items__post",
+                    "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
+                                "schema": {"$ref": "#/components/schemas/Item"}
                             }
                         },
+                        "required": True,
                     },
-                },
-                "summary": "Create an item",
-                "description": "Create an item with all the information:\n\n- **name**: each item must have a name\n- **description**: a long description\n- **price**: required\n- **tax**: if the item doesn't have tax, you can omit this\n- **tags**: a set of unique tag strings for this item",
-                "operationId": "create_item_items__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    },
-                    "required": True,
-                },
+                }
             }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number"},
-                    "tags": {
-                        "title": "Tags",
-                        "uniqueItems": True,
-                        "type": "array",
-                        "items": {"type": "string"},
-                        "default": [],
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number"},
+                        "tags": {
+                            "title": "Tags",
+                            "uniqueItems": True,
+                            "type": "array",
+                            "items": {"type": "string"},
+                            "default": [],
+                        },
                     },
                 },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
                     },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
                 },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
                 },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
-def test_query_params_str_validations():
-    response = client.post("/items/", json={"name": "Foo", "price": 42})
-    assert response.status_code == 200, response.text
-    assert response.json() == {
-        "name": "Foo",
-        "price": 42,
-        "description": None,
-        "tax": None,
-        "tags": [],
+            }
+        },
     }
index 43a7a610de8444988ef65873e7e32db5d5ab6a32..497fc90242715a04277a7c5c5305b54821a35dd1 100644 (file)
@@ -3,95 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "The created item",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create an item",
-                "description": "Create an item with all the information:\n\n- **name**: each item must have a name\n- **description**: a long description\n- **price**: required\n- **tax**: if the item doesn't have tax, you can omit this\n- **tags**: a set of unique tag strings for this item",
-                "operationId": "create_item_items__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number"},
-                    "tags": {
-                        "title": "Tags",
-                        "uniqueItems": True,
-                        "type": "array",
-                        "items": {"type": "string"},
-                        "default": [],
-                    },
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -101,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_query_params_str_validations(client: TestClient):
     response = client.post("/items/", json={"name": "Foo", "price": 42})
@@ -119,3 +23,99 @@ def test_query_params_str_validations(client: TestClient):
         "tax": None,
         "tags": [],
     }
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "The created item",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create an item",
+                    "description": "Create an item with all the information:\n\n- **name**: each item must have a name\n- **description**: a long description\n- **price**: required\n- **tax**: if the item doesn't have tax, you can omit this\n- **tags**: a set of unique tag strings for this item",
+                    "operationId": "create_item_items__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number"},
+                        "tags": {
+                            "title": "Tags",
+                            "uniqueItems": True,
+                            "type": "array",
+                            "items": {"type": "string"},
+                            "default": [],
+                        },
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 62aa73ac528c7b144a8f887d718d07a8484fce2b..09fac44c4d9ddc5eaaa70430773036838a78ce07 100644 (file)
@@ -3,95 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "The created item",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create an item",
-                "description": "Create an item with all the information:\n\n- **name**: each item must have a name\n- **description**: a long description\n- **price**: required\n- **tax**: if the item doesn't have tax, you can omit this\n- **tags**: a set of unique tag strings for this item",
-                "operationId": "create_item_items__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/Item"}
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number"},
-                    "tags": {
-                        "title": "Tags",
-                        "uniqueItems": True,
-                        "type": "array",
-                        "items": {"type": "string"},
-                        "default": [],
-                    },
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -101,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_query_params_str_validations(client: TestClient):
     response = client.post("/items/", json={"name": "Foo", "price": 42})
@@ -119,3 +23,99 @@ def test_query_params_str_validations(client: TestClient):
         "tax": None,
         "tags": [],
     }
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "The created item",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create an item",
+                    "description": "Create an item with all the information:\n\n- **name**: each item must have a name\n- **description**: a long description\n- **price**: required\n- **tax**: if the item doesn't have tax, you can omit this\n- **tags**: a set of unique tag strings for this item",
+                    "operationId": "create_item_items__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/Item"}
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number"},
+                        "tags": {
+                            "title": "Tags",
+                            "uniqueItems": True,
+                            "type": "array",
+                            "items": {"type": "string"},
+                            "default": [],
+                        },
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 582caed44a680bcde7e009af89b2efd22e22d521..e90771f24b6d8c8edc0ccd36ce46f9bd6b5e4f64 100644 (file)
@@ -5,59 +5,6 @@ from docs_src.path_operation_configuration.tutorial006 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "tags": ["items"],
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-            }
-        },
-        "/users/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "tags": ["users"],
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-            }
-        },
-        "/elements/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "tags": ["items"],
-                "summary": "Read Elements",
-                "operationId": "read_elements_elements__get",
-                "deprecated": True,
-            }
-        },
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 @pytest.mark.parametrize(
     "path,expected_status,expected_response",
@@ -71,3 +18,54 @@ def test_query_params_str_validations(path, expected_status, expected_response):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "tags": ["items"],
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                }
+            },
+            "/users/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "tags": ["users"],
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                }
+            },
+            "/elements/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "tags": ["items"],
+                    "summary": "Read Elements",
+                    "operationId": "read_elements_elements__get",
+                    "deprecated": True,
+                }
+            },
+        },
+    }
index 7f0227ecfb5472bb7b911ea8142a7c28e97d33bd..ab0455bf5d3592e86a8d41e640d4b3dc0441f666 100644 (file)
@@ -4,78 +4,6 @@ from docs_src.path_params.tutorial004 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/{file_path}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read File",
-                "operationId": "read_file_files__file_path__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "File Path", "type": "string"},
-                        "name": "file_path",
-                        "in": "path",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_file_path():
     response = client.get("/files/home/johndoe/myfile.txt")
@@ -89,3 +17,75 @@ def test_root_file_path():
     print(response.content)
     assert response.status_code == 200, response.text
     assert response.json() == {"file_path": "/home/johndoe/myfile.txt"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/{file_path}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read File",
+                    "operationId": "read_file_files__file_path__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "File Path", "type": "string"},
+                            "name": "file_path",
+                            "in": "path",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index eae3637bed587504a0ff1adc6265be8f98d49211..3401f2253410614ecf204f232b49f71e78821352 100644 (file)
@@ -5,156 +5,6 @@ from docs_src.path_params.tutorial005 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/models/{model_name}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Get Model",
-                "operationId": "get_model_models__model_name__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {
-                            "title": "Model Name",
-                            "enum": ["alexnet", "resnet", "lenet"],
-                            "type": "string",
-                        },
-                        "name": "model_name",
-                        "in": "path",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-openapi_schema2 = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/models/{model_name}": {
-            "get": {
-                "summary": "Get Model",
-                "operationId": "get_model_models__model_name__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"$ref": "#/components/schemas/ModelName"},
-                        "name": "model_name",
-                        "in": "path",
-                    }
-                ],
-                "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ModelName": {
-                "title": "ModelName",
-                "enum": ["alexnet", "resnet", "lenet"],
-                "type": "string",
-                "description": "An enumeration.",
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    data = response.json()
-    assert data == openapi_schema or data == openapi_schema2
-
 
 @pytest.mark.parametrize(
     "url,status_code,expected",
@@ -194,3 +44,82 @@ def test_get_enums(url, status_code, expected):
     response = client.get(url)
     assert response.status_code == status_code
     assert response.json() == expected
+
+
+def test_openapi():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    data = response.json()
+    assert data == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/models/{model_name}": {
+                "get": {
+                    "summary": "Get Model",
+                    "operationId": "get_model_models__model_name__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"$ref": "#/components/schemas/ModelName"},
+                            "name": "model_name",
+                            "in": "path",
+                        }
+                    ],
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ModelName": {
+                    "title": "ModelName",
+                    "enum": ["alexnet", "resnet", "lenet"],
+                    "type": "string",
+                    "description": "An enumeration.",
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 07178f8a6e814ca9db7b73cbed494c6c97f98cb7..3c408449b81162433ae0289dc7febb03cc5728bf 100644 (file)
@@ -5,78 +5,6 @@ from docs_src.query_params.tutorial005 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read User Item",
-                "operationId": "read_user_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "Needy", "type": "string"},
-                        "name": "needy",
-                        "in": "query",
-                    },
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 query_required = {
     "detail": [
@@ -92,7 +20,6 @@ query_required = {
 @pytest.mark.parametrize(
     "path,expected_status,expected_response",
     [
-        ("/openapi.json", 200, openapi_schema),
         ("/items/foo?needy=very", 200, {"item_id": "foo", "needy": "very"}),
         ("/items/foo", 422, query_required),
         ("/items/foo", 422, query_required),
@@ -102,3 +29,81 @@ def test(path, expected_status, expected_response):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read User Item",
+                    "operationId": "read_user_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "Needy", "type": "string"},
+                            "name": "needy",
+                            "in": "query",
+                        },
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 73c5302e7c7e51ea19252a740e05cb89db58dd77..7fe58a99008eece9acbab692ed98629718c169cd 100644 (file)
@@ -5,90 +5,6 @@ from docs_src.query_params.tutorial006 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read User Item",
-                "operationId": "read_user_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "Needy", "type": "string"},
-                        "name": "needy",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer"},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 query_required = {
     "detail": [
@@ -104,7 +20,6 @@ query_required = {
 @pytest.mark.parametrize(
     "path,expected_status,expected_response",
     [
-        ("/openapi.json", 200, openapi_schema),
         (
             "/items/foo?needy=very",
             200,
@@ -139,3 +54,97 @@ def test(path, expected_status, expected_response):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read User Item",
+                    "operationId": "read_user_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "Needy", "type": "string"},
+                            "name": "needy",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {"title": "Limit", "type": "integer"},
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 141525f15ff79a013422ee473f83e7db0bbe4d09..b90c0a6c8ea9b81bd84de80b51c38a33639ee10c 100644 (file)
@@ -3,91 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read User Item",
-                "operationId": "read_user_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    },
-                    {
-                        "required": True,
-                        "schema": {"title": "Needy", "type": "string"},
-                        "name": "needy",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer"},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
 query_required = {
     "detail": [
         {
@@ -111,7 +26,6 @@ def get_client():
 @pytest.mark.parametrize(
     "path,expected_status,expected_response",
     [
-        ("/openapi.json", 200, openapi_schema),
         (
             "/items/foo?needy=very",
             200,
@@ -146,3 +60,98 @@ def test(path, expected_status, expected_response, client: TestClient):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read User Item",
+                    "operationId": "read_user_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        },
+                        {
+                            "required": True,
+                            "schema": {"title": "Needy", "type": "string"},
+                            "name": "needy",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {"title": "Limit", "type": "integer"},
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index f8d7f85c8e6cb20df11949b4d64d93d58ec8348a..c41f554ba374bbc6a3af27a70a18600a0448ef8e 100644 (file)
@@ -5,87 +5,6 @@ from docs_src.query_params_str_validations.tutorial010 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "description": "Query string for the items to search in the database that have a good match",
-                        "required": False,
-                        "deprecated": True,
-                        "schema": {
-                            "title": "Query string",
-                            "maxLength": 50,
-                            "minLength": 3,
-                            "pattern": "^fixedquery$",
-                            "type": "string",
-                            "description": "Query string for the items to search in the database that have a good match",
-                        },
-                        "name": "item-query",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 regex_error = {
     "detail": [
@@ -120,3 +39,84 @@ def test_query_params_str_validations(q_name, q, expected_status, expected_respo
     response = client.get(url)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "description": "Query string for the items to search in the database that have a good match",
+                            "required": False,
+                            "deprecated": True,
+                            "schema": {
+                                "title": "Query string",
+                                "maxLength": 50,
+                                "minLength": 3,
+                                "pattern": "^fixedquery$",
+                                "type": "string",
+                                "description": "Query string for the items to search in the database that have a good match",
+                            },
+                            "name": "item-query",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index b2b9b501826922390268634e7d9ed73e0f4d5998..dc8028f81199e17d678af00fc7d569a4b24098b2 100644 (file)
@@ -5,87 +5,6 @@ from docs_src.query_params_str_validations.tutorial010_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "description": "Query string for the items to search in the database that have a good match",
-                        "required": False,
-                        "deprecated": True,
-                        "schema": {
-                            "title": "Query string",
-                            "maxLength": 50,
-                            "minLength": 3,
-                            "pattern": "^fixedquery$",
-                            "type": "string",
-                            "description": "Query string for the items to search in the database that have a good match",
-                        },
-                        "name": "item-query",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 regex_error = {
     "detail": [
@@ -120,3 +39,84 @@ def test_query_params_str_validations(q_name, q, expected_status, expected_respo
     response = client.get(url)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "description": "Query string for the items to search in the database that have a good match",
+                            "required": False,
+                            "deprecated": True,
+                            "schema": {
+                                "title": "Query string",
+                                "maxLength": 50,
+                                "minLength": 3,
+                                "pattern": "^fixedquery$",
+                                "type": "string",
+                                "description": "Query string for the items to search in the database that have a good match",
+                            },
+                            "name": "item-query",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index edbe4d009eaf362ec0606954d8c92b5e06696683..496b95b797a2adb2689c3f5217930f800e78ae99 100644 (file)
@@ -3,81 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "description": "Query string for the items to search in the database that have a good match",
-                        "required": False,
-                        "deprecated": True,
-                        "schema": {
-                            "title": "Query string",
-                            "maxLength": 50,
-                            "minLength": 3,
-                            "pattern": "^fixedquery$",
-                            "type": "string",
-                            "description": "Query string for the items to search in the database that have a good match",
-                        },
-                        "name": "item-query",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -87,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 regex_error = {
     "detail": [
         {
@@ -130,3 +48,85 @@ def test_query_params_str_validations(
     response = client.get(url)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "description": "Query string for the items to search in the database that have a good match",
+                            "required": False,
+                            "deprecated": True,
+                            "schema": {
+                                "title": "Query string",
+                                "maxLength": 50,
+                                "minLength": 3,
+                                "pattern": "^fixedquery$",
+                                "type": "string",
+                                "description": "Query string for the items to search in the database that have a good match",
+                            },
+                            "name": "item-query",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index f51e902477698d34b2808edce887b0e582cc53fc..2005e50433731dcc78f6495ff8e3bf58dce1cb50 100644 (file)
@@ -3,81 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "description": "Query string for the items to search in the database that have a good match",
-                        "required": False,
-                        "deprecated": True,
-                        "schema": {
-                            "title": "Query string",
-                            "maxLength": 50,
-                            "minLength": 3,
-                            "pattern": "^fixedquery$",
-                            "type": "string",
-                            "description": "Query string for the items to search in the database that have a good match",
-                        },
-                        "name": "item-query",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -87,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 regex_error = {
     "detail": [
         {
@@ -130,3 +48,85 @@ def test_query_params_str_validations(
     response = client.get(url)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "description": "Query string for the items to search in the database that have a good match",
+                            "required": False,
+                            "deprecated": True,
+                            "schema": {
+                                "title": "Query string",
+                                "maxLength": 50,
+                                "minLength": 3,
+                                "pattern": "^fixedquery$",
+                                "type": "string",
+                                "description": "Query string for the items to search in the database that have a good match",
+                            },
+                            "name": "item-query",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 298b5d616ccec2a6b0a5d28586f5100dddeee981..8147d768e0f399a52b516d949ce065b19ba34d78 100644 (file)
@@ -3,81 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "description": "Query string for the items to search in the database that have a good match",
-                        "required": False,
-                        "deprecated": True,
-                        "schema": {
-                            "title": "Query string",
-                            "maxLength": 50,
-                            "minLength": 3,
-                            "pattern": "^fixedquery$",
-                            "type": "string",
-                            "description": "Query string for the items to search in the database that have a good match",
-                        },
-                        "name": "item-query",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -87,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 regex_error = {
     "detail": [
         {
@@ -130,3 +48,85 @@ def test_query_params_str_validations(
     response = client.get(url)
     assert response.status_code == expected_status
     assert response.json() == expected_response
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "description": "Query string for the items to search in the database that have a good match",
+                            "required": False,
+                            "deprecated": True,
+                            "schema": {
+                                "title": "Query string",
+                                "maxLength": 50,
+                                "minLength": 3,
+                                "pattern": "^fixedquery$",
+                                "type": "string",
+                                "description": "Query string for the items to search in the database that have a good match",
+                            },
+                            "name": "item-query",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index ad3645f314eadedbde2c84446047d4f7506b501b..d6d69c1691232780a1b9712359c4a02d942e263f 100644 (file)
@@ -4,82 +4,6 @@ from docs_src.query_params_str_validations.tutorial011 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Q",
-                            "type": "array",
-                            "items": {"type": "string"},
-                        },
-                        "name": "q",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_multi_query_values():
     url = "/items/?q=foo&q=bar"
@@ -93,3 +17,79 @@ def test_query_no_values():
     response = client.get(url)
     assert response.status_code == 200, response.text
     assert response.json() == {"q": None}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Q",
+                                "type": "array",
+                                "items": {"type": "string"},
+                            },
+                            "name": "q",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 25a11f2caa864456e92d152a7050e05c0d106110..3a53d422e0f1dc3a89e9029f96c0644e255c9426 100644 (file)
@@ -4,82 +4,6 @@ from docs_src.query_params_str_validations.tutorial011_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Q",
-                            "type": "array",
-                            "items": {"type": "string"},
-                        },
-                        "name": "q",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_multi_query_values():
     url = "/items/?q=foo&q=bar"
@@ -93,3 +17,79 @@ def test_query_no_values():
     response = client.get(url)
     assert response.status_code == 200, response.text
     assert response.json() == {"q": None}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Q",
+                                "type": "array",
+                                "items": {"type": "string"},
+                            },
+                            "name": "q",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 99aaf3948c706ed0db816adee78b0a83ba1c669c..f00df28791810483aa153216efc6903537c2839b 100644 (file)
@@ -3,76 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Q",
-                            "type": "array",
-                            "items": {"type": "string"},
-                        },
-                        "name": "q",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -82,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_multi_query_values(client: TestClient):
     url = "/items/?q=foo&q=bar"
@@ -103,3 +26,80 @@ def test_query_no_values(client: TestClient):
     response = client.get(url)
     assert response.status_code == 200, response.text
     assert response.json() == {"q": None}
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Q",
+                                "type": "array",
+                                "items": {"type": "string"},
+                            },
+                            "name": "q",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 902add8512e983f57609db39d722dab1a7d3ee68..895fb8e9f4e17ed851bbce8c30d3f46fede91df3 100644 (file)
@@ -3,76 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Q",
-                            "type": "array",
-                            "items": {"type": "string"},
-                        },
-                        "name": "q",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -82,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_multi_query_values(client: TestClient):
     url = "/items/?q=foo&q=bar"
@@ -103,3 +26,80 @@ def test_query_no_values(client: TestClient):
     response = client.get(url)
     assert response.status_code == 200, response.text
     assert response.json() == {"q": None}
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Q",
+                                "type": "array",
+                                "items": {"type": "string"},
+                            },
+                            "name": "q",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 9330037eddf07f26b6e3ecf33d09af9793d44e8d..4f4b1fd558b655331748be047b1a06ea818eb5dd 100644 (file)
@@ -3,76 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Q",
-                            "type": "array",
-                            "items": {"type": "string"},
-                        },
-                        "name": "q",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -82,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_multi_query_values(client: TestClient):
     url = "/items/?q=foo&q=bar"
@@ -103,3 +26,80 @@ def test_query_no_values(client: TestClient):
     response = client.get(url)
     assert response.status_code == 200, response.text
     assert response.json() == {"q": None}
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Q",
+                                "type": "array",
+                                "items": {"type": "string"},
+                            },
+                            "name": "q",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 11f23be27c80f8ff531254c5096de420507171e6..d85bb623123e387a883ceb4adab292a5d050e677 100644 (file)
@@ -3,76 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Q",
-                            "type": "array",
-                            "items": {"type": "string"},
-                        },
-                        "name": "q",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -82,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_multi_query_values(client: TestClient):
     url = "/items/?q=foo&q=bar"
@@ -103,3 +26,80 @@ def test_query_no_values(client: TestClient):
     response = client.get(url)
     assert response.status_code == 200, response.text
     assert response.json() == {"q": None}
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Q",
+                                "type": "array",
+                                "items": {"type": "string"},
+                            },
+                            "name": "q",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index d69139dda52034ac2115936430bf6b25a3e5e933..7bc020540ab247652e53f210f8c48f9d9f2c70c9 100644 (file)
@@ -4,83 +4,6 @@ from docs_src.query_params_str_validations.tutorial012 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Q",
-                            "type": "array",
-                            "items": {"type": "string"},
-                            "default": ["foo", "bar"],
-                        },
-                        "name": "q",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_default_query_values():
     url = "/items/"
@@ -94,3 +17,80 @@ def test_multi_query_values():
     response = client.get(url)
     assert response.status_code == 200, response.text
     assert response.json() == {"q": ["baz", "foobar"]}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Q",
+                                "type": "array",
+                                "items": {"type": "string"},
+                                "default": ["foo", "bar"],
+                            },
+                            "name": "q",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index e57a2178f08749814bf2988ed799c46c576dd435..be5557f6ad3c6ec69936e194d3ee73b919791a7b 100644 (file)
@@ -4,83 +4,6 @@ from docs_src.query_params_str_validations.tutorial012_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Q",
-                            "type": "array",
-                            "items": {"type": "string"},
-                            "default": ["foo", "bar"],
-                        },
-                        "name": "q",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_default_query_values():
     url = "/items/"
@@ -94,3 +17,80 @@ def test_multi_query_values():
     response = client.get(url)
     assert response.status_code == 200, response.text
     assert response.json() == {"q": ["baz", "foobar"]}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Q",
+                                "type": "array",
+                                "items": {"type": "string"},
+                                "default": ["foo", "bar"],
+                            },
+                            "name": "q",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 140b7479052091e0677e4051eff9ccb1bcbdf69c..d9512e193f91fcafd6ad6ed46b276b41327dafd2 100644 (file)
@@ -3,77 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Q",
-                            "type": "array",
-                            "items": {"type": "string"},
-                            "default": ["foo", "bar"],
-                        },
-                        "name": "q",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -83,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_default_query_values(client: TestClient):
     url = "/items/"
@@ -104,3 +26,81 @@ def test_multi_query_values(client: TestClient):
     response = client.get(url)
     assert response.status_code == 200, response.text
     assert response.json() == {"q": ["baz", "foobar"]}
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Q",
+                                "type": "array",
+                                "items": {"type": "string"},
+                                "default": ["foo", "bar"],
+                            },
+                            "name": "q",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index b25bb2847fabfa71a494065dbe7b0194aa87775b..b2a2c8d1d190df34970fae7ccff8648e76769bf1 100644 (file)
@@ -3,77 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Q",
-                            "type": "array",
-                            "items": {"type": "string"},
-                            "default": ["foo", "bar"],
-                        },
-                        "name": "q",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -83,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_default_query_values(client: TestClient):
     url = "/items/"
@@ -104,3 +26,81 @@ def test_multi_query_values(client: TestClient):
     response = client.get(url)
     assert response.status_code == 200, response.text
     assert response.json() == {"q": ["baz", "foobar"]}
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Q",
+                                "type": "array",
+                                "items": {"type": "string"},
+                                "default": ["foo", "bar"],
+                            },
+                            "name": "q",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 1b2e363540a12786f5b2b2b875b8ea565e1b48eb..4a0b9e8b5fcee620b36d84e93a6e051807387acc 100644 (file)
@@ -4,83 +4,6 @@ from docs_src.query_params_str_validations.tutorial013 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Q",
-                            "type": "array",
-                            "items": {},
-                            "default": [],
-                        },
-                        "name": "q",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_multi_query_values():
     url = "/items/?q=foo&q=bar"
@@ -94,3 +17,80 @@ def test_query_no_values():
     response = client.get(url)
     assert response.status_code == 200, response.text
     assert response.json() == {"q": []}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Q",
+                                "type": "array",
+                                "items": {},
+                                "default": [],
+                            },
+                            "name": "q",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index fc684b5571a303a9bb35b021a3ba42b806094784..71e4638ae4f5a4144ab103e6517a6fb6982d6e57 100644 (file)
@@ -4,83 +4,6 @@ from docs_src.query_params_str_validations.tutorial013_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Q",
-                            "type": "array",
-                            "items": {},
-                            "default": [],
-                        },
-                        "name": "q",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_multi_query_values():
     url = "/items/?q=foo&q=bar"
@@ -94,3 +17,80 @@ def test_query_no_values():
     response = client.get(url)
     assert response.status_code == 200, response.text
     assert response.json() == {"q": []}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Q",
+                                "type": "array",
+                                "items": {},
+                                "default": [],
+                            },
+                            "name": "q",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 9d3f255e00b38df537d16cc3de2d79aa27be7fcc..4e90db358b4b693d7d2657435a23b1c6eee8f950 100644 (file)
@@ -3,77 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Q",
-                            "type": "array",
-                            "items": {},
-                            "default": [],
-                        },
-                        "name": "q",
-                        "in": "query",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -83,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_multi_query_values(client: TestClient):
     url = "/items/?q=foo&q=bar"
@@ -104,3 +26,81 @@ def test_query_no_values(client: TestClient):
     response = client.get(url)
     assert response.status_code == 200, response.text
     assert response.json() == {"q": []}
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Q",
+                                "type": "array",
+                                "items": {},
+                                "default": [],
+                            },
+                            "name": "q",
+                            "in": "query",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 57b8b9d946abc462db896cd1e9049c9f6d2fc5f7..7686c07b39f42180a0bfaf8feae48ead23e14711 100644 (file)
@@ -5,71 +5,6 @@ from docs_src.query_params_str_validations.tutorial014 import app
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_hidden_query():
     response = client.get("/items?hidden_query=somevalue")
     assert response.status_code == 200, response.text
@@ -80,3 +15,67 @@ def test_no_hidden_query():
     response = client.get("/items")
     assert response.status_code == 200, response.text
     assert response.json() == {"hidden_query": "Not found"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index ba5bf7c50edb167ee9721d6f77b2080bc52bae71..e739044a83fadb35127e36cd8bf3948dc680ecfa 100644 (file)
@@ -5,71 +5,6 @@ from docs_src.query_params_str_validations.tutorial014_an import app
 client = TestClient(app)
 
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_hidden_query():
     response = client.get("/items?hidden_query=somevalue")
     assert response.status_code == 200, response.text
@@ -80,3 +15,67 @@ def test_no_hidden_query():
     response = client.get("/items")
     assert response.status_code == 200, response.text
     assert response.json() == {"hidden_query": "Not found"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 69e176babeeaad605c2e733a79928632bef2fe07..73f0ba78b80fadbce0859e1f0733d1884105c4c5 100644 (file)
@@ -3,64 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -70,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_hidden_query(client: TestClient):
     response = client.get("/items?hidden_query=somevalue")
@@ -89,3 +24,68 @@ def test_no_hidden_query(client: TestClient):
     response = client.get("/items")
     assert response.status_code == 200, response.text
     assert response.json() == {"hidden_query": "Not found"}
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 2adfddfef9ffaca85c5820db7d7da1ef34da7a49..e2c14999212bc4175922a6f694c4a3debe204659 100644 (file)
@@ -3,64 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -70,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_hidden_query(client: TestClient):
     response = client.get("/items?hidden_query=somevalue")
@@ -89,3 +24,68 @@ def test_no_hidden_query(client: TestClient):
     response = client.get("/items")
     assert response.status_code == 200, response.text
     assert response.json() == {"hidden_query": "Not found"}
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index fe54fc080bb677fce7dfde4ae5db5d5741bccfd2..07f30b7395b2af4c5f604d336b331e4f8fdca5bc 100644 (file)
@@ -3,64 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -70,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_hidden_query(client: TestClient):
     response = client.get("/items?hidden_query=somevalue")
@@ -89,3 +24,68 @@ def test_no_hidden_query(client: TestClient):
     response = client.get("/items")
     assert response.status_code == 200, response.text
     assert response.json() == {"hidden_query": "Not found"}
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 166014c71fc780d5c2161e815495b49d221ba773..3269801efcd7bab714a3f436f655c119767e8fba 100644 (file)
@@ -4,128 +4,6 @@ from docs_src.request_files.tutorial001 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create File",
-                "operationId": "create_file_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_file_files__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/uploadfile/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Upload File",
-                "operationId": "create_upload_file_uploadfile__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Body_create_upload_file_uploadfile__post": {
-                "title": "Body_create_upload_file_uploadfile__post",
-                "required": ["file"],
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"}
-                },
-            },
-            "Body_create_file_files__post": {
-                "title": "Body_create_file_files__post",
-                "required": ["file"],
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"}
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 file_required = {
     "detail": [
@@ -182,3 +60,125 @@ def test_post_upload_file(tmp_path):
         response = client.post("/uploadfile/", files={"file": file})
     assert response.status_code == 200, response.text
     assert response.json() == {"filename": "test.txt"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create File",
+                    "operationId": "create_file_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_file_files__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/uploadfile/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Upload File",
+                    "operationId": "create_upload_file_uploadfile__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Body_create_upload_file_uploadfile__post": {
+                    "title": "Body_create_upload_file_uploadfile__post",
+                    "required": ["file"],
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"}
+                    },
+                },
+                "Body_create_file_files__post": {
+                    "title": "Body_create_file_files__post",
+                    "required": ["file"],
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"}
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index a254bf3e8fcd9900d2280fef0c2e5217969bf476..4b6edfa066699c9bb82910bea985276d5c173b01 100644 (file)
@@ -4,124 +4,6 @@ from docs_src.request_files.tutorial001_02 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "summary": "Create File",
-                "operationId": "create_file_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_file_files__post"
-                            }
-                        }
-                    }
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/uploadfile/": {
-            "post": {
-                "summary": "Create Upload File",
-                "operationId": "create_upload_file_uploadfile__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
-                            }
-                        }
-                    }
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Body_create_file_files__post": {
-                "title": "Body_create_file_files__post",
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"}
-                },
-            },
-            "Body_create_upload_file_uploadfile__post": {
-                "title": "Body_create_upload_file_uploadfile__post",
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"}
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_post_form_no_body():
     response = client.post("/files/")
@@ -155,3 +37,121 @@ def test_post_upload_file(tmp_path):
         response = client.post("/uploadfile/", files={"file": file})
     assert response.status_code == 200, response.text
     assert response.json() == {"filename": "test.txt"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "summary": "Create File",
+                    "operationId": "create_file_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_file_files__post"
+                                }
+                            }
+                        }
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/uploadfile/": {
+                "post": {
+                    "summary": "Create Upload File",
+                    "operationId": "create_upload_file_uploadfile__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
+                                }
+                            }
+                        }
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Body_create_file_files__post": {
+                    "title": "Body_create_file_files__post",
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"}
+                    },
+                },
+                "Body_create_upload_file_uploadfile__post": {
+                    "title": "Body_create_upload_file_uploadfile__post",
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"}
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 50b05fa4b64ccbafe215faba191fca49cf216aa2..0c34620e38d84138be7dca6143e11b60e2795e73 100644 (file)
@@ -4,124 +4,6 @@ from docs_src.request_files.tutorial001_02_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "summary": "Create File",
-                "operationId": "create_file_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_file_files__post"
-                            }
-                        }
-                    }
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/uploadfile/": {
-            "post": {
-                "summary": "Create Upload File",
-                "operationId": "create_upload_file_uploadfile__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
-                            }
-                        }
-                    }
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Body_create_file_files__post": {
-                "title": "Body_create_file_files__post",
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"}
-                },
-            },
-            "Body_create_upload_file_uploadfile__post": {
-                "title": "Body_create_upload_file_uploadfile__post",
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"}
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_post_form_no_body():
     response = client.post("/files/")
@@ -155,3 +37,121 @@ def test_post_upload_file(tmp_path):
         response = client.post("/uploadfile/", files={"file": file})
     assert response.status_code == 200, response.text
     assert response.json() == {"filename": "test.txt"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "summary": "Create File",
+                    "operationId": "create_file_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_file_files__post"
+                                }
+                            }
+                        }
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/uploadfile/": {
+                "post": {
+                    "summary": "Create Upload File",
+                    "operationId": "create_upload_file_uploadfile__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
+                                }
+                            }
+                        }
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Body_create_file_files__post": {
+                    "title": "Body_create_file_files__post",
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"}
+                    },
+                },
+                "Body_create_upload_file_uploadfile__post": {
+                    "title": "Body_create_upload_file_uploadfile__post",
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"}
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index a5796b74c5deb20c703a9534c075472d1d1bd954..04442c76f451d4ef4925d8518e4df64c76862b0f 100644 (file)
@@ -5,118 +5,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "summary": "Create File",
-                "operationId": "create_file_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_file_files__post"
-                            }
-                        }
-                    }
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/uploadfile/": {
-            "post": {
-                "summary": "Create Upload File",
-                "operationId": "create_upload_file_uploadfile__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
-                            }
-                        }
-                    }
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Body_create_file_files__post": {
-                "title": "Body_create_file_files__post",
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"}
-                },
-            },
-            "Body_create_upload_file_uploadfile__post": {
-                "title": "Body_create_upload_file_uploadfile__post",
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"}
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -126,13 +14,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_post_form_no_body(client: TestClient):
     response = client.post("/files/")
@@ -167,3 +48,122 @@ def test_post_upload_file(tmp_path: Path, client: TestClient):
         response = client.post("/uploadfile/", files={"file": file})
     assert response.status_code == 200, response.text
     assert response.json() == {"filename": "test.txt"}
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "summary": "Create File",
+                    "operationId": "create_file_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_file_files__post"
+                                }
+                            }
+                        }
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/uploadfile/": {
+                "post": {
+                    "summary": "Create Upload File",
+                    "operationId": "create_upload_file_uploadfile__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
+                                }
+                            }
+                        }
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Body_create_file_files__post": {
+                    "title": "Body_create_file_files__post",
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"}
+                    },
+                },
+                "Body_create_upload_file_uploadfile__post": {
+                    "title": "Body_create_upload_file_uploadfile__post",
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"}
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 57175f736dccaa311e1c9a30ba507b54575db771..f5249ef5bf3240b1ba38f9e75679c51e377a8e98 100644 (file)
@@ -5,118 +5,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "summary": "Create File",
-                "operationId": "create_file_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_file_files__post"
-                            }
-                        }
-                    }
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/uploadfile/": {
-            "post": {
-                "summary": "Create Upload File",
-                "operationId": "create_upload_file_uploadfile__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
-                            }
-                        }
-                    }
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Body_create_file_files__post": {
-                "title": "Body_create_file_files__post",
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"}
-                },
-            },
-            "Body_create_upload_file_uploadfile__post": {
-                "title": "Body_create_upload_file_uploadfile__post",
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"}
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -126,13 +14,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_post_form_no_body(client: TestClient):
     response = client.post("/files/")
@@ -167,3 +48,122 @@ def test_post_upload_file(tmp_path: Path, client: TestClient):
         response = client.post("/uploadfile/", files={"file": file})
     assert response.status_code == 200, response.text
     assert response.json() == {"filename": "test.txt"}
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "summary": "Create File",
+                    "operationId": "create_file_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_file_files__post"
+                                }
+                            }
+                        }
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/uploadfile/": {
+                "post": {
+                    "summary": "Create Upload File",
+                    "operationId": "create_upload_file_uploadfile__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
+                                }
+                            }
+                        }
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Body_create_file_files__post": {
+                    "title": "Body_create_file_files__post",
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"}
+                    },
+                },
+                "Body_create_upload_file_uploadfile__post": {
+                    "title": "Body_create_upload_file_uploadfile__post",
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"}
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 15b6a8d53833a7180a1249deb27c71e7974c3afd..f690d107bae36e928171e8d04eb4ae301901a98a 100644 (file)
@@ -5,118 +5,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "summary": "Create File",
-                "operationId": "create_file_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_file_files__post"
-                            }
-                        }
-                    }
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/uploadfile/": {
-            "post": {
-                "summary": "Create Upload File",
-                "operationId": "create_upload_file_uploadfile__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
-                            }
-                        }
-                    }
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Body_create_file_files__post": {
-                "title": "Body_create_file_files__post",
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"}
-                },
-            },
-            "Body_create_upload_file_uploadfile__post": {
-                "title": "Body_create_upload_file_uploadfile__post",
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"}
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -126,13 +14,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_post_form_no_body(client: TestClient):
     response = client.post("/files/")
@@ -167,3 +48,122 @@ def test_post_upload_file(tmp_path: Path, client: TestClient):
         response = client.post("/uploadfile/", files={"file": file})
     assert response.status_code == 200, response.text
     assert response.json() == {"filename": "test.txt"}
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "summary": "Create File",
+                    "operationId": "create_file_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_file_files__post"
+                                }
+                            }
+                        }
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/uploadfile/": {
+                "post": {
+                    "summary": "Create Upload File",
+                    "operationId": "create_upload_file_uploadfile__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
+                                }
+                            }
+                        }
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Body_create_file_files__post": {
+                    "title": "Body_create_file_files__post",
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"}
+                    },
+                },
+                "Body_create_upload_file_uploadfile__post": {
+                    "title": "Body_create_upload_file_uploadfile__post",
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"}
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index c34165f18e76d0f6b2efa9e66bec6eb4dad70786..4af659a1113a1b23cd26aca2b73b4ab2a04f6abe 100644 (file)
@@ -4,138 +4,6 @@ from docs_src.request_files.tutorial001_03 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "summary": "Create File",
-                "operationId": "create_file_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_file_files__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/uploadfile/": {
-            "post": {
-                "summary": "Create Upload File",
-                "operationId": "create_upload_file_uploadfile__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
-                            }
-                        }
-                    },
-                    "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": {
-            "Body_create_file_files__post": {
-                "title": "Body_create_file_files__post",
-                "required": ["file"],
-                "type": "object",
-                "properties": {
-                    "file": {
-                        "title": "File",
-                        "type": "string",
-                        "description": "A file read as bytes",
-                        "format": "binary",
-                    }
-                },
-            },
-            "Body_create_upload_file_uploadfile__post": {
-                "title": "Body_create_upload_file_uploadfile__post",
-                "required": ["file"],
-                "type": "object",
-                "properties": {
-                    "file": {
-                        "title": "File",
-                        "type": "string",
-                        "description": "A file read as UploadFile",
-                        "format": "binary",
-                    }
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_post_file(tmp_path):
     path = tmp_path / "test.txt"
@@ -157,3 +25,135 @@ def test_post_upload_file(tmp_path):
         response = client.post("/uploadfile/", files={"file": file})
     assert response.status_code == 200, response.text
     assert response.json() == {"filename": "test.txt"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "summary": "Create File",
+                    "operationId": "create_file_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_file_files__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/uploadfile/": {
+                "post": {
+                    "summary": "Create Upload File",
+                    "operationId": "create_upload_file_uploadfile__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
+                                }
+                            }
+                        },
+                        "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": {
+                "Body_create_file_files__post": {
+                    "title": "Body_create_file_files__post",
+                    "required": ["file"],
+                    "type": "object",
+                    "properties": {
+                        "file": {
+                            "title": "File",
+                            "type": "string",
+                            "description": "A file read as bytes",
+                            "format": "binary",
+                        }
+                    },
+                },
+                "Body_create_upload_file_uploadfile__post": {
+                    "title": "Body_create_upload_file_uploadfile__post",
+                    "required": ["file"],
+                    "type": "object",
+                    "properties": {
+                        "file": {
+                            "title": "File",
+                            "type": "string",
+                            "description": "A file read as UploadFile",
+                            "format": "binary",
+                        }
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index e83fc68bb8bb8cc314458d9a7b3cf07ddfbc3a00..91dbc60b909a5f6898e12891b45a3500ad7c8172 100644 (file)
@@ -4,138 +4,6 @@ from docs_src.request_files.tutorial001_03_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "summary": "Create File",
-                "operationId": "create_file_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_file_files__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/uploadfile/": {
-            "post": {
-                "summary": "Create Upload File",
-                "operationId": "create_upload_file_uploadfile__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
-                            }
-                        }
-                    },
-                    "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": {
-            "Body_create_file_files__post": {
-                "title": "Body_create_file_files__post",
-                "required": ["file"],
-                "type": "object",
-                "properties": {
-                    "file": {
-                        "title": "File",
-                        "type": "string",
-                        "description": "A file read as bytes",
-                        "format": "binary",
-                    }
-                },
-            },
-            "Body_create_upload_file_uploadfile__post": {
-                "title": "Body_create_upload_file_uploadfile__post",
-                "required": ["file"],
-                "type": "object",
-                "properties": {
-                    "file": {
-                        "title": "File",
-                        "type": "string",
-                        "description": "A file read as UploadFile",
-                        "format": "binary",
-                    }
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_post_file(tmp_path):
     path = tmp_path / "test.txt"
@@ -157,3 +25,135 @@ def test_post_upload_file(tmp_path):
         response = client.post("/uploadfile/", files={"file": file})
     assert response.status_code == 200, response.text
     assert response.json() == {"filename": "test.txt"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "summary": "Create File",
+                    "operationId": "create_file_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_file_files__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/uploadfile/": {
+                "post": {
+                    "summary": "Create Upload File",
+                    "operationId": "create_upload_file_uploadfile__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
+                                }
+                            }
+                        },
+                        "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": {
+                "Body_create_file_files__post": {
+                    "title": "Body_create_file_files__post",
+                    "required": ["file"],
+                    "type": "object",
+                    "properties": {
+                        "file": {
+                            "title": "File",
+                            "type": "string",
+                            "description": "A file read as bytes",
+                            "format": "binary",
+                        }
+                    },
+                },
+                "Body_create_upload_file_uploadfile__post": {
+                    "title": "Body_create_upload_file_uploadfile__post",
+                    "required": ["file"],
+                    "type": "object",
+                    "properties": {
+                        "file": {
+                            "title": "File",
+                            "type": "string",
+                            "description": "A file read as UploadFile",
+                            "format": "binary",
+                        }
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 7808262a7757f33ca04b1f6c83f7d2d9e36ed758..7c4ad326c4659bebecd63f73725b2b8c63667df6 100644 (file)
@@ -3,132 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "summary": "Create File",
-                "operationId": "create_file_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_file_files__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/uploadfile/": {
-            "post": {
-                "summary": "Create Upload File",
-                "operationId": "create_upload_file_uploadfile__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
-                            }
-                        }
-                    },
-                    "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": {
-            "Body_create_file_files__post": {
-                "title": "Body_create_file_files__post",
-                "required": ["file"],
-                "type": "object",
-                "properties": {
-                    "file": {
-                        "title": "File",
-                        "type": "string",
-                        "description": "A file read as bytes",
-                        "format": "binary",
-                    }
-                },
-            },
-            "Body_create_upload_file_uploadfile__post": {
-                "title": "Body_create_upload_file_uploadfile__post",
-                "required": ["file"],
-                "type": "object",
-                "properties": {
-                    "file": {
-                        "title": "File",
-                        "type": "string",
-                        "description": "A file read as UploadFile",
-                        "format": "binary",
-                    }
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -138,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_post_file(tmp_path, client: TestClient):
     path = tmp_path / "test.txt"
@@ -165,3 +32,136 @@ def test_post_upload_file(tmp_path, client: TestClient):
         response = client.post("/uploadfile/", files={"file": file})
     assert response.status_code == 200, response.text
     assert response.json() == {"filename": "test.txt"}
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "summary": "Create File",
+                    "operationId": "create_file_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_file_files__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/uploadfile/": {
+                "post": {
+                    "summary": "Create Upload File",
+                    "operationId": "create_upload_file_uploadfile__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
+                                }
+                            }
+                        },
+                        "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": {
+                "Body_create_file_files__post": {
+                    "title": "Body_create_file_files__post",
+                    "required": ["file"],
+                    "type": "object",
+                    "properties": {
+                        "file": {
+                            "title": "File",
+                            "type": "string",
+                            "description": "A file read as bytes",
+                            "format": "binary",
+                        }
+                    },
+                },
+                "Body_create_upload_file_uploadfile__post": {
+                    "title": "Body_create_upload_file_uploadfile__post",
+                    "required": ["file"],
+                    "type": "object",
+                    "properties": {
+                        "file": {
+                            "title": "File",
+                            "type": "string",
+                            "description": "A file read as UploadFile",
+                            "format": "binary",
+                        }
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 739f04b432dd970da0878c022e65d71041125ded..80c288ed6e3557645a81f611d99b4ecccdc82e0d 100644 (file)
@@ -4,128 +4,6 @@ from docs_src.request_files.tutorial001_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create File",
-                "operationId": "create_file_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_file_files__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/uploadfile/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Upload File",
-                "operationId": "create_upload_file_uploadfile__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Body_create_upload_file_uploadfile__post": {
-                "title": "Body_create_upload_file_uploadfile__post",
-                "required": ["file"],
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"}
-                },
-            },
-            "Body_create_file_files__post": {
-                "title": "Body_create_file_files__post",
-                "required": ["file"],
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"}
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 file_required = {
     "detail": [
@@ -182,3 +60,125 @@ def test_post_upload_file(tmp_path):
         response = client.post("/uploadfile/", files={"file": file})
     assert response.status_code == 200, response.text
     assert response.json() == {"filename": "test.txt"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create File",
+                    "operationId": "create_file_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_file_files__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/uploadfile/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Upload File",
+                    "operationId": "create_upload_file_uploadfile__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Body_create_upload_file_uploadfile__post": {
+                    "title": "Body_create_upload_file_uploadfile__post",
+                    "required": ["file"],
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"}
+                    },
+                },
+                "Body_create_file_files__post": {
+                    "title": "Body_create_file_files__post",
+                    "required": ["file"],
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"}
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 091a9362b1b1842bfa76461659ce37467f3c27c4..4dc1f752ce697460dc960f02a810f9f02f311b1d 100644 (file)
@@ -3,122 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create File",
-                "operationId": "create_file_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_file_files__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/uploadfile/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Upload File",
-                "operationId": "create_upload_file_uploadfile__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Body_create_upload_file_uploadfile__post": {
-                "title": "Body_create_upload_file_uploadfile__post",
-                "required": ["file"],
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"}
-                },
-            },
-            "Body_create_file_files__post": {
-                "title": "Body_create_file_files__post",
-                "required": ["file"],
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"}
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -128,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 file_required = {
     "detail": [
         {
@@ -192,3 +69,126 @@ def test_post_upload_file(tmp_path, client: TestClient):
         response = client.post("/uploadfile/", files={"file": file})
     assert response.status_code == 200, response.text
     assert response.json() == {"filename": "test.txt"}
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create File",
+                    "operationId": "create_file_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_file_files__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/uploadfile/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Upload File",
+                    "operationId": "create_upload_file_uploadfile__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Body_create_upload_file_uploadfile__post": {
+                    "title": "Body_create_upload_file_uploadfile__post",
+                    "required": ["file"],
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"}
+                    },
+                },
+                "Body_create_file_files__post": {
+                    "title": "Body_create_file_files__post",
+                    "required": ["file"],
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"}
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 73d1179a1c2cfe04eb767c3d0fbd64772adf3d05..6868be32847a2604d768b97c8caa0f18c5bc5cd1 100644 (file)
@@ -4,148 +4,6 @@ from docs_src.request_files.tutorial002 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Files",
-                "operationId": "create_files_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_files_files__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/uploadfiles/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Upload Files",
-                "operationId": "create_upload_files_uploadfiles__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Main",
-                "operationId": "main__get",
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Body_create_upload_files_uploadfiles__post": {
-                "title": "Body_create_upload_files_uploadfiles__post",
-                "required": ["files"],
-                "type": "object",
-                "properties": {
-                    "files": {
-                        "title": "Files",
-                        "type": "array",
-                        "items": {"type": "string", "format": "binary"},
-                    }
-                },
-            },
-            "Body_create_files_files__post": {
-                "title": "Body_create_files_files__post",
-                "required": ["files"],
-                "type": "object",
-                "properties": {
-                    "files": {
-                        "title": "Files",
-                        "type": "array",
-                        "items": {"type": "string", "format": "binary"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 file_required = {
     "detail": [
@@ -213,3 +71,145 @@ def test_get_root():
     response = client.get("/")
     assert response.status_code == 200, response.text
     assert b"<form" in response.content
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Files",
+                    "operationId": "create_files_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_files_files__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/uploadfiles/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Upload Files",
+                    "operationId": "create_upload_files_uploadfiles__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Main",
+                    "operationId": "main__get",
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Body_create_upload_files_uploadfiles__post": {
+                    "title": "Body_create_upload_files_uploadfiles__post",
+                    "required": ["files"],
+                    "type": "object",
+                    "properties": {
+                        "files": {
+                            "title": "Files",
+                            "type": "array",
+                            "items": {"type": "string", "format": "binary"},
+                        }
+                    },
+                },
+                "Body_create_files_files__post": {
+                    "title": "Body_create_files_files__post",
+                    "required": ["files"],
+                    "type": "object",
+                    "properties": {
+                        "files": {
+                            "title": "Files",
+                            "type": "array",
+                            "items": {"type": "string", "format": "binary"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 8a99c657c36d64d0437ddee5177c3e633191fe7c..ca1f62ea395216eb3b726866068ae0552d746254 100644 (file)
@@ -4,148 +4,6 @@ from docs_src.request_files.tutorial002_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Files",
-                "operationId": "create_files_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_files_files__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/uploadfiles/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Upload Files",
-                "operationId": "create_upload_files_uploadfiles__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Main",
-                "operationId": "main__get",
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Body_create_upload_files_uploadfiles__post": {
-                "title": "Body_create_upload_files_uploadfiles__post",
-                "required": ["files"],
-                "type": "object",
-                "properties": {
-                    "files": {
-                        "title": "Files",
-                        "type": "array",
-                        "items": {"type": "string", "format": "binary"},
-                    }
-                },
-            },
-            "Body_create_files_files__post": {
-                "title": "Body_create_files_files__post",
-                "required": ["files"],
-                "type": "object",
-                "properties": {
-                    "files": {
-                        "title": "Files",
-                        "type": "array",
-                        "items": {"type": "string", "format": "binary"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 file_required = {
     "detail": [
@@ -213,3 +71,145 @@ def test_get_root():
     response = client.get("/")
     assert response.status_code == 200, response.text
     assert b"<form" in response.content
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Files",
+                    "operationId": "create_files_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_files_files__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/uploadfiles/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Upload Files",
+                    "operationId": "create_upload_files_uploadfiles__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Main",
+                    "operationId": "main__get",
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Body_create_upload_files_uploadfiles__post": {
+                    "title": "Body_create_upload_files_uploadfiles__post",
+                    "required": ["files"],
+                    "type": "object",
+                    "properties": {
+                        "files": {
+                            "title": "Files",
+                            "type": "array",
+                            "items": {"type": "string", "format": "binary"},
+                        }
+                    },
+                },
+                "Body_create_files_files__post": {
+                    "title": "Body_create_files_files__post",
+                    "required": ["files"],
+                    "type": "object",
+                    "properties": {
+                        "files": {
+                            "title": "Files",
+                            "type": "array",
+                            "items": {"type": "string", "format": "binary"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index ebfc1dfa1ba7d8e2ded1589654b6aba728f0b132..e593ae75de43bc01d0ce7d17617dda80770da3de 100644 (file)
@@ -4,142 +4,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Files",
-                "operationId": "create_files_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_files_files__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/uploadfiles/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Upload Files",
-                "operationId": "create_upload_files_uploadfiles__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Main",
-                "operationId": "main__get",
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Body_create_upload_files_uploadfiles__post": {
-                "title": "Body_create_upload_files_uploadfiles__post",
-                "required": ["files"],
-                "type": "object",
-                "properties": {
-                    "files": {
-                        "title": "Files",
-                        "type": "array",
-                        "items": {"type": "string", "format": "binary"},
-                    }
-                },
-            },
-            "Body_create_files_files__post": {
-                "title": "Body_create_files_files__post",
-                "required": ["files"],
-                "type": "object",
-                "properties": {
-                    "files": {
-                        "title": "Files",
-                        "type": "array",
-                        "items": {"type": "string", "format": "binary"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="app")
 def get_app():
@@ -154,13 +18,6 @@ def get_client(app: FastAPI):
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 file_required = {
     "detail": [
         {
@@ -232,3 +89,146 @@ def test_get_root(app: FastAPI):
     response = client.get("/")
     assert response.status_code == 200, response.text
     assert b"<form" in response.content
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Files",
+                    "operationId": "create_files_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_files_files__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/uploadfiles/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Upload Files",
+                    "operationId": "create_upload_files_uploadfiles__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Main",
+                    "operationId": "main__get",
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Body_create_upload_files_uploadfiles__post": {
+                    "title": "Body_create_upload_files_uploadfiles__post",
+                    "required": ["files"],
+                    "type": "object",
+                    "properties": {
+                        "files": {
+                            "title": "Files",
+                            "type": "array",
+                            "items": {"type": "string", "format": "binary"},
+                        }
+                    },
+                },
+                "Body_create_files_files__post": {
+                    "title": "Body_create_files_files__post",
+                    "required": ["files"],
+                    "type": "object",
+                    "properties": {
+                        "files": {
+                            "title": "Files",
+                            "type": "array",
+                            "items": {"type": "string", "format": "binary"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 633795dee2d697bcf6e4a8bcfaa5cbc3df79b04d..bacd25b97e4801cfbcb3bdf80d6c0c6d8ab282ec 100644 (file)
@@ -4,142 +4,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Files",
-                "operationId": "create_files_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_files_files__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/uploadfiles/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Upload Files",
-                "operationId": "create_upload_files_uploadfiles__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Main",
-                "operationId": "main__get",
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Body_create_upload_files_uploadfiles__post": {
-                "title": "Body_create_upload_files_uploadfiles__post",
-                "required": ["files"],
-                "type": "object",
-                "properties": {
-                    "files": {
-                        "title": "Files",
-                        "type": "array",
-                        "items": {"type": "string", "format": "binary"},
-                    }
-                },
-            },
-            "Body_create_files_files__post": {
-                "title": "Body_create_files_files__post",
-                "required": ["files"],
-                "type": "object",
-                "properties": {
-                    "files": {
-                        "title": "Files",
-                        "type": "array",
-                        "items": {"type": "string", "format": "binary"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="app")
 def get_app():
@@ -154,13 +18,6 @@ def get_client(app: FastAPI):
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 file_required = {
     "detail": [
         {
@@ -232,3 +89,146 @@ def test_get_root(app: FastAPI):
     response = client.get("/")
     assert response.status_code == 200, response.text
     assert b"<form" in response.content
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Files",
+                    "operationId": "create_files_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_files_files__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/uploadfiles/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Upload Files",
+                    "operationId": "create_upload_files_uploadfiles__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Main",
+                    "operationId": "main__get",
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Body_create_upload_files_uploadfiles__post": {
+                    "title": "Body_create_upload_files_uploadfiles__post",
+                    "required": ["files"],
+                    "type": "object",
+                    "properties": {
+                        "files": {
+                            "title": "Files",
+                            "type": "array",
+                            "items": {"type": "string", "format": "binary"},
+                        }
+                    },
+                },
+                "Body_create_files_files__post": {
+                    "title": "Body_create_files_files__post",
+                    "required": ["files"],
+                    "type": "object",
+                    "properties": {
+                        "files": {
+                            "title": "Files",
+                            "type": "array",
+                            "items": {"type": "string", "format": "binary"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 83aea66cddb639533325a7570cdf99e2dbda34ee..e2d69184b9d68412322e336aa1b7dbc8997f5ac8 100644 (file)
@@ -4,150 +4,6 @@ from docs_src.request_files.tutorial003 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "summary": "Create Files",
-                "operationId": "create_files_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_files_files__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/uploadfiles/": {
-            "post": {
-                "summary": "Create Upload Files",
-                "operationId": "create_upload_files_uploadfiles__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/": {
-            "get": {
-                "summary": "Main",
-                "operationId": "main__get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Body_create_files_files__post": {
-                "title": "Body_create_files_files__post",
-                "required": ["files"],
-                "type": "object",
-                "properties": {
-                    "files": {
-                        "title": "Files",
-                        "type": "array",
-                        "items": {"type": "string", "format": "binary"},
-                        "description": "Multiple files as bytes",
-                    }
-                },
-            },
-            "Body_create_upload_files_uploadfiles__post": {
-                "title": "Body_create_upload_files_uploadfiles__post",
-                "required": ["files"],
-                "type": "object",
-                "properties": {
-                    "files": {
-                        "title": "Files",
-                        "type": "array",
-                        "items": {"type": "string", "format": "binary"},
-                        "description": "Multiple files as UploadFile",
-                    }
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_post_files(tmp_path):
     path = tmp_path / "test.txt"
@@ -192,3 +48,147 @@ def test_get_root():
     response = client.get("/")
     assert response.status_code == 200, response.text
     assert b"<form" in response.content
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "summary": "Create Files",
+                    "operationId": "create_files_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_files_files__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/uploadfiles/": {
+                "post": {
+                    "summary": "Create Upload Files",
+                    "operationId": "create_upload_files_uploadfiles__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/": {
+                "get": {
+                    "summary": "Main",
+                    "operationId": "main__get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Body_create_files_files__post": {
+                    "title": "Body_create_files_files__post",
+                    "required": ["files"],
+                    "type": "object",
+                    "properties": {
+                        "files": {
+                            "title": "Files",
+                            "type": "array",
+                            "items": {"type": "string", "format": "binary"},
+                            "description": "Multiple files as bytes",
+                        }
+                    },
+                },
+                "Body_create_upload_files_uploadfiles__post": {
+                    "title": "Body_create_upload_files_uploadfiles__post",
+                    "required": ["files"],
+                    "type": "object",
+                    "properties": {
+                        "files": {
+                            "title": "Files",
+                            "type": "array",
+                            "items": {"type": "string", "format": "binary"},
+                            "description": "Multiple files as UploadFile",
+                        }
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 2a6d52411a830478372fb9d3cefa31cd1c4fc566..f199d4d2fd674a92d3946200d2f8e698a63bb4d3 100644 (file)
@@ -4,150 +4,6 @@ from docs_src.request_files.tutorial003_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "summary": "Create Files",
-                "operationId": "create_files_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_files_files__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/uploadfiles/": {
-            "post": {
-                "summary": "Create Upload Files",
-                "operationId": "create_upload_files_uploadfiles__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/": {
-            "get": {
-                "summary": "Main",
-                "operationId": "main__get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Body_create_files_files__post": {
-                "title": "Body_create_files_files__post",
-                "required": ["files"],
-                "type": "object",
-                "properties": {
-                    "files": {
-                        "title": "Files",
-                        "type": "array",
-                        "items": {"type": "string", "format": "binary"},
-                        "description": "Multiple files as bytes",
-                    }
-                },
-            },
-            "Body_create_upload_files_uploadfiles__post": {
-                "title": "Body_create_upload_files_uploadfiles__post",
-                "required": ["files"],
-                "type": "object",
-                "properties": {
-                    "files": {
-                        "title": "Files",
-                        "type": "array",
-                        "items": {"type": "string", "format": "binary"},
-                        "description": "Multiple files as UploadFile",
-                    }
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_post_files(tmp_path):
     path = tmp_path / "test.txt"
@@ -192,3 +48,147 @@ def test_get_root():
     response = client.get("/")
     assert response.status_code == 200, response.text
     assert b"<form" in response.content
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "summary": "Create Files",
+                    "operationId": "create_files_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_files_files__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/uploadfiles/": {
+                "post": {
+                    "summary": "Create Upload Files",
+                    "operationId": "create_upload_files_uploadfiles__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/": {
+                "get": {
+                    "summary": "Main",
+                    "operationId": "main__get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Body_create_files_files__post": {
+                    "title": "Body_create_files_files__post",
+                    "required": ["files"],
+                    "type": "object",
+                    "properties": {
+                        "files": {
+                            "title": "Files",
+                            "type": "array",
+                            "items": {"type": "string", "format": "binary"},
+                            "description": "Multiple files as bytes",
+                        }
+                    },
+                },
+                "Body_create_upload_files_uploadfiles__post": {
+                    "title": "Body_create_upload_files_uploadfiles__post",
+                    "required": ["files"],
+                    "type": "object",
+                    "properties": {
+                        "files": {
+                            "title": "Files",
+                            "type": "array",
+                            "items": {"type": "string", "format": "binary"},
+                            "description": "Multiple files as UploadFile",
+                        }
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 86e7d7a8832cfafa12f4275e9dac01dded9ed068..51fa8347057ae8750bb671e465dc3c069a6cc0cb 100644 (file)
@@ -4,144 +4,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "summary": "Create Files",
-                "operationId": "create_files_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_files_files__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/uploadfiles/": {
-            "post": {
-                "summary": "Create Upload Files",
-                "operationId": "create_upload_files_uploadfiles__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/": {
-            "get": {
-                "summary": "Main",
-                "operationId": "main__get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Body_create_files_files__post": {
-                "title": "Body_create_files_files__post",
-                "required": ["files"],
-                "type": "object",
-                "properties": {
-                    "files": {
-                        "title": "Files",
-                        "type": "array",
-                        "items": {"type": "string", "format": "binary"},
-                        "description": "Multiple files as bytes",
-                    }
-                },
-            },
-            "Body_create_upload_files_uploadfiles__post": {
-                "title": "Body_create_upload_files_uploadfiles__post",
-                "required": ["files"],
-                "type": "object",
-                "properties": {
-                    "files": {
-                        "title": "Files",
-                        "type": "array",
-                        "items": {"type": "string", "format": "binary"},
-                        "description": "Multiple files as UploadFile",
-                    }
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="app")
 def get_app():
@@ -156,13 +18,6 @@ def get_client(app: FastAPI):
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 file_required = {
     "detail": [
         {
@@ -220,3 +75,148 @@ def test_get_root(app: FastAPI):
     response = client.get("/")
     assert response.status_code == 200, response.text
     assert b"<form" in response.content
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "summary": "Create Files",
+                    "operationId": "create_files_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_files_files__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/uploadfiles/": {
+                "post": {
+                    "summary": "Create Upload Files",
+                    "operationId": "create_upload_files_uploadfiles__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/": {
+                "get": {
+                    "summary": "Main",
+                    "operationId": "main__get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Body_create_files_files__post": {
+                    "title": "Body_create_files_files__post",
+                    "required": ["files"],
+                    "type": "object",
+                    "properties": {
+                        "files": {
+                            "title": "Files",
+                            "type": "array",
+                            "items": {"type": "string", "format": "binary"},
+                            "description": "Multiple files as bytes",
+                        }
+                    },
+                },
+                "Body_create_upload_files_uploadfiles__post": {
+                    "title": "Body_create_upload_files_uploadfiles__post",
+                    "required": ["files"],
+                    "type": "object",
+                    "properties": {
+                        "files": {
+                            "title": "Files",
+                            "type": "array",
+                            "items": {"type": "string", "format": "binary"},
+                            "description": "Multiple files as UploadFile",
+                        }
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 474da8ba0fb20cc0f221f61734c9b6c823cfee47..32b0289096ff5083d769687fb91fcbb813256c15 100644 (file)
@@ -4,144 +4,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "summary": "Create Files",
-                "operationId": "create_files_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_files_files__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/uploadfiles/": {
-            "post": {
-                "summary": "Create Upload Files",
-                "operationId": "create_upload_files_uploadfiles__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/": {
-            "get": {
-                "summary": "Main",
-                "operationId": "main__get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Body_create_files_files__post": {
-                "title": "Body_create_files_files__post",
-                "required": ["files"],
-                "type": "object",
-                "properties": {
-                    "files": {
-                        "title": "Files",
-                        "type": "array",
-                        "items": {"type": "string", "format": "binary"},
-                        "description": "Multiple files as bytes",
-                    }
-                },
-            },
-            "Body_create_upload_files_uploadfiles__post": {
-                "title": "Body_create_upload_files_uploadfiles__post",
-                "required": ["files"],
-                "type": "object",
-                "properties": {
-                    "files": {
-                        "title": "Files",
-                        "type": "array",
-                        "items": {"type": "string", "format": "binary"},
-                        "description": "Multiple files as UploadFile",
-                    }
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="app")
 def get_app():
@@ -156,13 +18,6 @@ def get_client(app: FastAPI):
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 file_required = {
     "detail": [
         {
@@ -220,3 +75,148 @@ def test_get_root(app: FastAPI):
     response = client.get("/")
     assert response.status_code == 200, response.text
     assert b"<form" in response.content
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "summary": "Create Files",
+                    "operationId": "create_files_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_files_files__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/uploadfiles/": {
+                "post": {
+                    "summary": "Create Upload Files",
+                    "operationId": "create_upload_files_uploadfiles__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/": {
+                "get": {
+                    "summary": "Main",
+                    "operationId": "main__get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Body_create_files_files__post": {
+                    "title": "Body_create_files_files__post",
+                    "required": ["files"],
+                    "type": "object",
+                    "properties": {
+                        "files": {
+                            "title": "Files",
+                            "type": "array",
+                            "items": {"type": "string", "format": "binary"},
+                            "description": "Multiple files as bytes",
+                        }
+                    },
+                },
+                "Body_create_upload_files_uploadfiles__post": {
+                    "title": "Body_create_upload_files_uploadfiles__post",
+                    "required": ["files"],
+                    "type": "object",
+                    "properties": {
+                        "files": {
+                            "title": "Files",
+                            "type": "array",
+                            "items": {"type": "string", "format": "binary"},
+                            "description": "Multiple files as UploadFile",
+                        }
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 215260ffa98948dd3c534e1990c4430a0e9db561..721c97fb181e4c7b89cb36b6294df8abe97c4ebf 100644 (file)
@@ -5,89 +5,6 @@ from docs_src.request_forms.tutorial001 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "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,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Body_login_login__post": {
-                "title": "Body_login_login__post",
-                "required": ["username", "password"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "password": {"title": "Password", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 password_required = {
     "detail": [
@@ -147,3 +64,86 @@ def test_post_body_json():
     response = client.post("/login/", json={"username": "Foo", "password": "secret"})
     assert response.status_code == 422, response.text
     assert response.json() == username_and_password_required
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "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,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Body_login_login__post": {
+                    "title": "Body_login_login__post",
+                    "required": ["username", "password"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "password": {"title": "Password", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 27babe1a356104c24ccf5e506c09e64ed0c8479d..6b8abab1934eb02a2a22b23efbb5ab4667832ba4 100644 (file)
@@ -5,89 +5,6 @@ from docs_src.request_forms.tutorial001_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "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,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Body_login_login__post": {
-                "title": "Body_login_login__post",
-                "required": ["username", "password"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "password": {"title": "Password", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 password_required = {
     "detail": [
@@ -147,3 +64,86 @@ def test_post_body_json():
     response = client.post("/login/", json={"username": "Foo", "password": "secret"})
     assert response.status_code == 422, response.text
     assert response.json() == username_and_password_required
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "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,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Body_login_login__post": {
+                    "title": "Body_login_login__post",
+                    "required": ["username", "password"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "password": {"title": "Password", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index a8d08d7f23a49125e58c647c6b210cd81a397962..5862524add5f2c03e835cc00058e75b9ca2e02cb 100644 (file)
@@ -3,83 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "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,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Body_login_login__post": {
-                "title": "Body_login_login__post",
-                "required": ["username", "password"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "password": {"title": "Password", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -89,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 password_required = {
     "detail": [
         {
@@ -158,3 +74,87 @@ def test_post_body_json(client: TestClient):
     response = client.post("/login/", json={"username": "Foo", "password": "secret"})
     assert response.status_code == 422, response.text
     assert response.json() == username_and_password_required
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "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,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Body_login_login__post": {
+                    "title": "Body_login_login__post",
+                    "required": ["username", "password"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "password": {"title": "Password", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 09e232b8e5cba650216fb5eb583c5e505a035df6..dcc44cf092e84f7bf845fa6254e59c98f384ed7a 100644 (file)
@@ -4,90 +4,6 @@ from docs_src.request_forms_and_files.tutorial001 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create File",
-                "operationId": "create_file_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_file_files__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Body_create_file_files__post": {
-                "title": "Body_create_file_files__post",
-                "required": ["file", "fileb", "token"],
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"},
-                    "fileb": {"title": "Fileb", "type": "string", "format": "binary"},
-                    "token": {"title": "Token", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 file_required = {
     "detail": [
@@ -190,3 +106,91 @@ def test_post_files_and_token(tmp_path):
         "token": "foo",
         "fileb_content_type": "text/plain",
     }
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create File",
+                    "operationId": "create_file_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_file_files__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Body_create_file_files__post": {
+                    "title": "Body_create_file_files__post",
+                    "required": ["file", "fileb", "token"],
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"},
+                        "fileb": {
+                            "title": "Fileb",
+                            "type": "string",
+                            "format": "binary",
+                        },
+                        "token": {"title": "Token", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 4fcd272c369561345847db849505a17badc7bd30..f11e3698448dbe87fbf48b1f854b4ef4bc6eecf2 100644 (file)
@@ -4,90 +4,6 @@ from docs_src.request_forms_and_files.tutorial001_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create File",
-                "operationId": "create_file_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_file_files__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Body_create_file_files__post": {
-                "title": "Body_create_file_files__post",
-                "required": ["file", "fileb", "token"],
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"},
-                    "fileb": {"title": "Fileb", "type": "string", "format": "binary"},
-                    "token": {"title": "Token", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 file_required = {
     "detail": [
@@ -190,3 +106,91 @@ def test_post_files_and_token(tmp_path):
         "token": "foo",
         "fileb_content_type": "text/plain",
     }
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create File",
+                    "operationId": "create_file_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_file_files__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Body_create_file_files__post": {
+                    "title": "Body_create_file_files__post",
+                    "required": ["file", "fileb", "token"],
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"},
+                        "fileb": {
+                            "title": "Fileb",
+                            "type": "string",
+                            "format": "binary",
+                        },
+                        "token": {"title": "Token", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index fa2ebc77d5f596ffb39c5ffa1f928550faa088bf..9b5e8681c61c19fa210d10418070ac28bb861b1f 100644 (file)
@@ -4,84 +4,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/files/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create File",
-                "operationId": "create_file_files__post",
-                "requestBody": {
-                    "content": {
-                        "multipart/form-data": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_create_file_files__post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Body_create_file_files__post": {
-                "title": "Body_create_file_files__post",
-                "required": ["file", "fileb", "token"],
-                "type": "object",
-                "properties": {
-                    "file": {"title": "File", "type": "string", "format": "binary"},
-                    "fileb": {"title": "Fileb", "type": "string", "format": "binary"},
-                    "token": {"title": "Token", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="app")
 def get_app():
@@ -96,13 +18,6 @@ def get_client(app: FastAPI):
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 file_required = {
     "detail": [
         {
@@ -209,3 +124,92 @@ def test_post_files_and_token(tmp_path, app: FastAPI):
         "token": "foo",
         "fileb_content_type": "text/plain",
     }
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/files/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create File",
+                    "operationId": "create_file_files__post",
+                    "requestBody": {
+                        "content": {
+                            "multipart/form-data": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_create_file_files__post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Body_create_file_files__post": {
+                    "title": "Body_create_file_files__post",
+                    "required": ["file", "fileb", "token"],
+                    "type": "object",
+                    "properties": {
+                        "file": {"title": "File", "type": "string", "format": "binary"},
+                        "fileb": {
+                            "title": "Fileb",
+                            "type": "string",
+                            "format": "binary",
+                        },
+                        "token": {"title": "Token", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index e1bde5d1335f3778bba22aea1d97df4e7196ea31..4a95cb2b5628f25be1d5671aeb9d1bfa4c7fbf6c 100644 (file)
@@ -4,103 +4,6 @@ from docs_src.response_model.tutorial003 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/user/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/UserOut"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create User",
-                "operationId": "create_user_user__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/UserIn"}
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "UserOut": {
-                "title": "UserOut",
-                "required": ["username", "email"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "email": {"title": "Email", "type": "string", "format": "email"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                },
-            },
-            "UserIn": {
-                "title": "UserIn",
-                "required": ["username", "password", "email"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "password": {"title": "Password", "type": "string"},
-                    "email": {"title": "Email", "type": "string", "format": "email"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_post_user():
     response = client.post(
@@ -118,3 +21,108 @@ def test_post_user():
         "email": "foo@example.com",
         "full_name": "Grave Dohl",
     }
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/user/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/UserOut"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create User",
+                    "operationId": "create_user_user__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/UserIn"}
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "UserOut": {
+                    "title": "UserOut",
+                    "required": ["username", "email"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "email": {
+                            "title": "Email",
+                            "type": "string",
+                            "format": "email",
+                        },
+                        "full_name": {"title": "Full Name", "type": "string"},
+                    },
+                },
+                "UserIn": {
+                    "title": "UserIn",
+                    "required": ["username", "password", "email"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "password": {"title": "Password", "type": "string"},
+                        "email": {
+                            "title": "Email",
+                            "type": "string",
+                            "format": "email",
+                        },
+                        "full_name": {"title": "Full Name", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 39a4734edaff16f330e7ec2c636977a5eba8e14d..a055bc6885841d4d5966a5f6852eea585c39f971 100644 (file)
@@ -4,103 +4,6 @@ from docs_src.response_model.tutorial003_01 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/user/": {
-            "post": {
-                "summary": "Create User",
-                "operationId": "create_user_user__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/UserIn"}
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/BaseUser"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "BaseUser": {
-                "title": "BaseUser",
-                "required": ["username", "email"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "email": {"title": "Email", "type": "string", "format": "email"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "UserIn": {
-                "title": "UserIn",
-                "required": ["username", "email", "password"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "email": {"title": "Email", "type": "string", "format": "email"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                    "password": {"title": "Password", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_post_user():
     response = client.post(
@@ -118,3 +21,108 @@ def test_post_user():
         "email": "foo@example.com",
         "full_name": "Grave Dohl",
     }
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/user/": {
+                "post": {
+                    "summary": "Create User",
+                    "operationId": "create_user_user__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/UserIn"}
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/BaseUser"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "BaseUser": {
+                    "title": "BaseUser",
+                    "required": ["username", "email"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "email": {
+                            "title": "Email",
+                            "type": "string",
+                            "format": "email",
+                        },
+                        "full_name": {"title": "Full Name", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "UserIn": {
+                    "title": "UserIn",
+                    "required": ["username", "email", "password"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "email": {
+                            "title": "Email",
+                            "type": "string",
+                            "format": "email",
+                        },
+                        "full_name": {"title": "Full Name", "type": "string"},
+                        "password": {"title": "Password", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 3a04db6bc657785dc68701364e7b0e4506e4a88a..8cb4ac208e9474d13fe25711dbfad1a4d7368178 100644 (file)
@@ -3,97 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/user/": {
-            "post": {
-                "summary": "Create User",
-                "operationId": "create_user_user__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/UserIn"}
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/BaseUser"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "BaseUser": {
-                "title": "BaseUser",
-                "required": ["username", "email"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "email": {"title": "Email", "type": "string", "format": "email"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "UserIn": {
-                "title": "UserIn",
-                "required": ["username", "email", "password"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "email": {"title": "Email", "type": "string", "format": "email"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                    "password": {"title": "Password", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -103,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_post_user(client: TestClient):
     response = client.post(
@@ -127,3 +29,109 @@ def test_post_user(client: TestClient):
         "email": "foo@example.com",
         "full_name": "Grave Dohl",
     }
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/user/": {
+                "post": {
+                    "summary": "Create User",
+                    "operationId": "create_user_user__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/UserIn"}
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/BaseUser"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "BaseUser": {
+                    "title": "BaseUser",
+                    "required": ["username", "email"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "email": {
+                            "title": "Email",
+                            "type": "string",
+                            "format": "email",
+                        },
+                        "full_name": {"title": "Full Name", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "UserIn": {
+                    "title": "UserIn",
+                    "required": ["username", "email", "password"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "email": {
+                            "title": "Email",
+                            "type": "string",
+                            "format": "email",
+                        },
+                        "full_name": {"title": "Full Name", "type": "string"},
+                        "password": {"title": "Password", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index d933f871cf3e93a735a5cb0196fc8b3d7a4b9656..6ccb054b8336b013f0e08b13b8fc45f8ddd28810 100644 (file)
@@ -4,82 +4,6 @@ from docs_src.response_model.tutorial003_02 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/portal": {
-            "get": {
-                "summary": "Get Portal",
-                "operationId": "get_portal_portal_get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Teleport",
-                            "type": "boolean",
-                            "default": False,
-                        },
-                        "name": "teleport",
-                        "in": "query",
-                    }
-                ],
-                "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_portal():
     response = client.get("/portal")
@@ -91,3 +15,79 @@ def test_get_redirect():
     response = client.get("/portal", params={"teleport": True}, follow_redirects=False)
     assert response.status_code == 307, response.text
     assert response.headers["location"] == "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/portal": {
+                "get": {
+                    "summary": "Get Portal",
+                    "operationId": "get_portal_portal_get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Teleport",
+                                "type": "boolean",
+                                "default": False,
+                            },
+                            "name": "teleport",
+                            "in": "query",
+                        }
+                    ],
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 398eb4765837f739ae8dbd47a1bc282848be60da..ba4c0f2750619070d2b0fae5a976b427cc39185d 100644 (file)
@@ -4,33 +4,31 @@ from docs_src.response_model.tutorial003_03 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/teleport": {
-            "get": {
-                "summary": "Get Teleport",
-                "operationId": "get_teleport_teleport_get",
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_portal():
     response = client.get("/teleport", follow_redirects=False)
     assert response.status_code == 307, response.text
     assert response.headers["location"] == "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/teleport": {
+                "get": {
+                    "summary": "Get Teleport",
+                    "operationId": "get_teleport_teleport_get",
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                }
+            }
+        },
+    }
index 27896d490ef32942565e7fb7e6bcb503c2d8f8b4..d7c232e75118f70822ddf9bae85e4f26450d8d45 100644 (file)
@@ -4,82 +4,6 @@ from docs_src.response_model.tutorial003_05 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/portal": {
-            "get": {
-                "summary": "Get Portal",
-                "operationId": "get_portal_portal_get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Teleport",
-                            "type": "boolean",
-                            "default": False,
-                        },
-                        "name": "teleport",
-                        "in": "query",
-                    }
-                ],
-                "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_get_portal():
     response = client.get("/portal")
@@ -91,3 +15,79 @@ def test_get_redirect():
     response = client.get("/portal", params={"teleport": True}, follow_redirects=False)
     assert response.status_code == 307, response.text
     assert response.headers["location"] == "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/portal": {
+                "get": {
+                    "summary": "Get Portal",
+                    "operationId": "get_portal_portal_get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Teleport",
+                                "type": "boolean",
+                                "default": False,
+                            },
+                            "name": "teleport",
+                            "in": "query",
+                        }
+                    ],
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index bf36c906b2de1bf6b7ebca15a5f98b6ad6c1a659..a89f1dad8b518ed28be1b7be21889795d2a29e10 100644 (file)
@@ -3,76 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/portal": {
-            "get": {
-                "summary": "Get Portal",
-                "operationId": "get_portal_portal_get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {
-                            "title": "Teleport",
-                            "type": "boolean",
-                            "default": False,
-                        },
-                        "name": "teleport",
-                        "in": "query",
-                    }
-                ],
-                "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -82,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_get_portal(client: TestClient):
     response = client.get("/portal")
@@ -101,3 +24,80 @@ def test_get_redirect(client: TestClient):
     response = client.get("/portal", params={"teleport": True}, follow_redirects=False)
     assert response.status_code == 307, response.text
     assert response.headers["location"] == "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/portal": {
+                "get": {
+                    "summary": "Get Portal",
+                    "operationId": "get_portal_portal_get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Teleport",
+                                "type": "boolean",
+                                "default": False,
+                            },
+                            "name": "teleport",
+                            "in": "query",
+                        }
+                    ],
+                    "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 9827dab8a31b6bf7f7d3d5dcbccff2dd30ddcb29..1f4ec9057f873689b3df373ac02ee6961a01307a 100644 (file)
@@ -3,97 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/user/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/UserOut"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create User",
-                "operationId": "create_user_user__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/UserIn"}
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "UserOut": {
-                "title": "UserOut",
-                "required": ["username", "email"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "email": {"title": "Email", "type": "string", "format": "email"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                },
-            },
-            "UserIn": {
-                "title": "UserIn",
-                "required": ["username", "password", "email"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "password": {"title": "Password", "type": "string"},
-                    "email": {"title": "Email", "type": "string", "format": "email"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -103,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_post_user(client: TestClient):
     response = client.post(
@@ -127,3 +29,109 @@ def test_post_user(client: TestClient):
         "email": "foo@example.com",
         "full_name": "Grave Dohl",
     }
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/user/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/UserOut"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create User",
+                    "operationId": "create_user_user__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/UserIn"}
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "UserOut": {
+                    "title": "UserOut",
+                    "required": ["username", "email"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "email": {
+                            "title": "Email",
+                            "type": "string",
+                            "format": "email",
+                        },
+                        "full_name": {"title": "Full Name", "type": "string"},
+                    },
+                },
+                "UserIn": {
+                    "title": "UserIn",
+                    "required": ["username", "password", "email"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "password": {"title": "Password", "type": "string"},
+                        "email": {
+                            "title": "Email",
+                            "type": "string",
+                            "format": "email",
+                        },
+                        "full_name": {"title": "Full Name", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 8c98c6de3088cbacf8d44825a4b6b7f44719f220..8cb7dc9cf412f39b44da72be731a443b9475e6bf 100644 (file)
@@ -5,99 +5,6 @@ from docs_src.response_model.tutorial004 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number", "default": 10.5},
-                    "tags": {
-                        "title": "Tags",
-                        "type": "array",
-                        "items": {"type": "string"},
-                        "default": [],
-                    },
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 @pytest.mark.parametrize(
     "url,data",
@@ -123,3 +30,96 @@ def test_get(url, data):
     response = client.get(url)
     assert response.status_code == 200, response.text
     assert response.json() == data
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number", "default": 10.5},
+                        "tags": {
+                            "title": "Tags",
+                            "type": "array",
+                            "items": {"type": "string"},
+                            "default": [],
+                        },
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 7fc86fafab8b00a49527238848e9002c06ca0394..2ba8143ba68ae8a7ee1e30f6386b8f9318287c38 100644 (file)
@@ -3,93 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number", "default": 10.5},
-                    "tags": {
-                        "title": "Tags",
-                        "type": "array",
-                        "items": {"type": "string"},
-                        "default": [],
-                    },
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -99,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 @pytest.mark.parametrize(
     "url,data",
@@ -131,3 +37,97 @@ def test_get(url, data, client: TestClient):
     response = client.get(url)
     assert response.status_code == 200, response.text
     assert response.json() == data
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number", "default": 10.5},
+                        "tags": {
+                            "title": "Tags",
+                            "type": "array",
+                            "items": {"type": "string"},
+                            "default": [],
+                        },
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 405fe79f50aa52fec5656f9fc707e2658b71d54d..97df0a238f59d8ea525ab05678393628d14b06d4 100644 (file)
@@ -3,93 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item",
-                "operationId": "read_item_items__item_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number", "default": 10.5},
-                    "tags": {
-                        "title": "Tags",
-                        "type": "array",
-                        "items": {"type": "string"},
-                        "default": [],
-                    },
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -99,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 @pytest.mark.parametrize(
     "url,data",
@@ -131,3 +37,97 @@ def test_get(url, data, client: TestClient):
     response = client.get(url)
     assert response.status_code == 200, response.text
     assert response.json() == data
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item",
+                    "operationId": "read_item_items__item_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number", "default": 10.5},
+                        "tags": {
+                            "title": "Tags",
+                            "type": "array",
+                            "items": {"type": "string"},
+                            "default": [],
+                        },
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 476b172d3d69c1abb9452e6d53144ac129b3962e..76662f7937201d27003dbdd694ceac8cb3aa0980 100644 (file)
@@ -4,127 +4,6 @@ from docs_src.response_model.tutorial005 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}/name": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item Name",
-                "operationId": "read_item_name_items__item_id__name_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/items/{item_id}/public": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item Public Data",
-                "operationId": "read_item_public_data_items__item_id__public_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number", "default": 10.5},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_read_item_name():
     response = client.get("/items/bar/name")
@@ -140,3 +19,124 @@ def test_read_item_public_data():
         "description": "The Bar fighters",
         "price": 62,
     }
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}/name": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item Name",
+                    "operationId": "read_item_name_items__item_id__name_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/items/{item_id}/public": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item Public Data",
+                    "operationId": "read_item_public_data_items__item_id__public_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number", "default": 10.5},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 389a302e08d62da1670459ff43eff50251406551..1b1cf4175592e35d4bb9c79cf90607d61758fa8f 100644 (file)
@@ -3,121 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}/name": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item Name",
-                "operationId": "read_item_name_items__item_id__name_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/items/{item_id}/public": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item Public Data",
-                "operationId": "read_item_public_data_items__item_id__public_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number", "default": 10.5},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -127,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_read_item_name(client: TestClient):
     response = client.get("/items/bar/name")
@@ -150,3 +28,125 @@ def test_read_item_public_data(client: TestClient):
         "description": "The Bar fighters",
         "price": 62,
     }
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}/name": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item Name",
+                    "operationId": "read_item_name_items__item_id__name_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/items/{item_id}/public": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item Public Data",
+                    "operationId": "read_item_public_data_items__item_id__public_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number", "default": 10.5},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 38eb31e54f7b4e760b1ff2b0b71bcc2bcf755dfb..3a759fde411063defb3fdb43837ac51de6090349 100644 (file)
@@ -4,127 +4,6 @@ from docs_src.response_model.tutorial006 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}/name": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item Name",
-                "operationId": "read_item_name_items__item_id__name_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/items/{item_id}/public": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item Public Data",
-                "operationId": "read_item_public_data_items__item_id__public_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number", "default": 10.5},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_read_item_name():
     response = client.get("/items/bar/name")
@@ -140,3 +19,124 @@ def test_read_item_public_data():
         "description": "The Bar fighters",
         "price": 62,
     }
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}/name": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item Name",
+                    "operationId": "read_item_name_items__item_id__name_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/items/{item_id}/public": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item Public Data",
+                    "operationId": "read_item_public_data_items__item_id__public_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number", "default": 10.5},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index f870f39261e59bcc682a2e4dae57760150350c09..07e84cc82ad4b1010b3eeaec85a07074186b08fe 100644 (file)
@@ -3,121 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/{item_id}/name": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item Name",
-                "operationId": "read_item_name_items__item_id__name_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/items/{item_id}/public": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Item Public Data",
-                "operationId": "read_item_public_data_items__item_id__public_get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "Item Id", "type": "string"},
-                        "name": "item_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "description": {"title": "Description", "type": "string"},
-                    "tax": {"title": "Tax", "type": "number", "default": 10.5},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -127,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_read_item_name(client: TestClient):
     response = client.get("/items/bar/name")
@@ -150,3 +28,125 @@ def test_read_item_public_data(client: TestClient):
         "description": "The Bar fighters",
         "price": 62,
     }
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/{item_id}/name": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item Name",
+                    "operationId": "read_item_name_items__item_id__name_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/items/{item_id}/public": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Item Public Data",
+                    "operationId": "read_item_public_data_items__item_id__public_get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "Item Id", "type": "string"},
+                            "name": "item_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "description": {"title": "Description", "type": "string"},
+                        "tax": {"title": "Tax", "type": "number", "default": 10.5},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index badf66b3d132d70a9d3f57a0b1a759a38b880f1b..784517d69ed9edae3f088fbf6088cb794f2ec996 100644 (file)
@@ -4,121 +4,6 @@ from docs_src.schema_extra_example.tutorial004 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 # Test required and embedded body parameters with no bodies sent
 def test_post_body_example():
@@ -132,3 +17,118 @@ def test_post_body_example():
         },
     )
     assert response.status_code == 200
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 7694669cef01bc5627f82d08bff3b89fa607b74f..222a4edfe8d5a6366182628ad3e8f747b0ca94d6 100644 (file)
@@ -4,121 +4,6 @@ from docs_src.schema_extra_example.tutorial004_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 # Test required and embedded body parameters with no bodies sent
 def test_post_body_example():
@@ -132,3 +17,118 @@ def test_post_body_example():
         },
     )
     assert response.status_code == 200
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index c81fbcf5201189ec6efdf32b36d416d2b786d0df..1eacd640af6cde9a0f60cd6efbbfffa558fff048 100644 (file)
@@ -3,115 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -121,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 # Test required and embedded body parameters with no bodies sent
 @needs_py310
 def test_post_body_example(client: TestClient):
@@ -141,3 +25,119 @@ def test_post_body_example(client: TestClient):
         },
     )
     assert response.status_code == 200
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 395c27b0e90805e3b7111c56c2c4bf6f7ab565b6..632f2cbe0bc8cdf5ed7c8f4333183d5726b58d51 100644 (file)
@@ -3,115 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -121,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 # Test required and embedded body parameters with no bodies sent
 @needs_py39
 def test_post_body_example(client: TestClient):
@@ -141,3 +25,119 @@ def test_post_body_example(client: TestClient):
         },
     )
     assert response.status_code == 200
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index d326a5a092e3feb170d6ca8b173d1b3dc4b31ce5..c99cb75c89beb6211a92c9fd19a6ff6001316377 100644 (file)
@@ -3,115 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["name", "price"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                    "price": {"title": "Price", "type": "number"},
-                    "tax": {"title": "Tax", "type": "number"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -121,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 # Test required and embedded body parameters with no bodies sent
 @needs_py310
 def test_post_body_example(client: TestClient):
@@ -141,3 +25,119 @@ def test_post_body_example(client: TestClient):
         },
     )
     assert response.status_code == 200
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "Item": {
+                    "title": "Item",
+                    "required": ["name", "price"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                        "price": {"title": "Price", "type": "number"},
+                        "tax": {"title": "Tax", "type": "number"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index 8a033c4f26be06e7ed152fe1cf8acb0650f5e7a2..a7f55b78b292e98241cacbfc80b07da545f8fd82 100644 (file)
@@ -4,40 +4,6 @@ from docs_src.security.tutorial001 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "security": [{"OAuth2PasswordBearer": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "OAuth2PasswordBearer": {
-                "type": "oauth2",
-                "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_no_token():
     response = client.get("/items")
@@ -57,3 +23,35 @@ def test_incorrect_token():
     assert response.status_code == 401, response.text
     assert response.json() == {"detail": "Not authenticated"}
     assert response.headers["WWW-Authenticate"] == "Bearer"
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "security": [{"OAuth2PasswordBearer": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "OAuth2PasswordBearer": {
+                    "type": "oauth2",
+                    "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
+                }
+            }
+        },
+    }
index fdcb9bfb813663cbb7a720f71bb4ec439437ee33..fc48703aa020cfb2d3d28df8d54875417d925930 100644 (file)
@@ -4,40 +4,6 @@ from docs_src.security.tutorial001_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "security": [{"OAuth2PasswordBearer": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "OAuth2PasswordBearer": {
-                "type": "oauth2",
-                "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
-            }
-        }
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_no_token():
     response = client.get("/items")
@@ -57,3 +23,35 @@ def test_incorrect_token():
     assert response.status_code == 401, response.text
     assert response.json() == {"detail": "Not authenticated"}
     assert response.headers["WWW-Authenticate"] == "Bearer"
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "security": [{"OAuth2PasswordBearer": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "OAuth2PasswordBearer": {
+                    "type": "oauth2",
+                    "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
+                }
+            }
+        },
+    }
index 4f8947b90ed4b4ff0e353c9794dc2a18195f27bf..345e0be0f3fb4f40350d9d31eab2e2c7c426bbb6 100644 (file)
@@ -3,34 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "security": [{"OAuth2PasswordBearer": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {
-            "OAuth2PasswordBearer": {
-                "type": "oauth2",
-                "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
-            }
-        }
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -40,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_no_token(client: TestClient):
     response = client.get("/items")
@@ -68,3 +33,36 @@ def test_incorrect_token(client: TestClient):
     assert response.status_code == 401, response.text
     assert response.json() == {"detail": "Not authenticated"}
     assert response.headers["WWW-Authenticate"] == "Bearer"
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "security": [{"OAuth2PasswordBearer": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {
+                "OAuth2PasswordBearer": {
+                    "type": "oauth2",
+                    "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
+                }
+            }
+        },
+    }
index 5951078343c67e9940f8996fdab9e6a6c08d5584..c10f928eb4800b987ad42a7a4b764dd0f4edcca3 100644 (file)
@@ -4,116 +4,6 @@ from docs_src.security.tutorial003 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "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",
-                        "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", "type": "string"},
-                    "client_secret": {"title": "Client Secret", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        },
-        "securitySchemes": {
-            "OAuth2PasswordBearer": {
-                "type": "oauth2",
-                "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
-            }
-        },
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_login():
     response = client.post("/token", data={"username": "johndoe", "password": "secret"})
@@ -174,3 +64,113 @@ def test_inactive_user():
     response = client.get("/users/me", headers={"Authorization": "Bearer alice"})
     assert response.status_code == 400, response.text
     assert response.json() == {"detail": "Inactive user"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "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",
+                            "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", "type": "string"},
+                        "client_secret": {"title": "Client Secret", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            },
+            "securitySchemes": {
+                "OAuth2PasswordBearer": {
+                    "type": "oauth2",
+                    "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
+                }
+            },
+        },
+    }
index b1b9c0fc184ffa23f731793a1a11fa0b06181875..41872fda03e1c68c71946884ba4ddf9f3f113175 100644 (file)
@@ -4,116 +4,6 @@ from docs_src.security.tutorial003_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "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",
-                        "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", "type": "string"},
-                    "client_secret": {"title": "Client Secret", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        },
-        "securitySchemes": {
-            "OAuth2PasswordBearer": {
-                "type": "oauth2",
-                "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
-            }
-        },
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_login():
     response = client.post("/token", data={"username": "johndoe", "password": "secret"})
@@ -174,3 +64,113 @@ def test_inactive_user():
     response = client.get("/users/me", headers={"Authorization": "Bearer alice"})
     assert response.status_code == 400, response.text
     assert response.json() == {"detail": "Inactive user"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "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",
+                            "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", "type": "string"},
+                        "client_secret": {"title": "Client Secret", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            },
+            "securitySchemes": {
+                "OAuth2PasswordBearer": {
+                    "type": "oauth2",
+                    "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
+                }
+            },
+        },
+    }
index 486f0c4ce1eee74f353d6964ad7966d0212f343d..02bd748c8cf3d609e3095255fe685d2f471402cb 100644 (file)
@@ -3,110 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "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",
-                        "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", "type": "string"},
-                    "client_secret": {"title": "Client Secret", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        },
-        "securitySchemes": {
-            "OAuth2PasswordBearer": {
-                "type": "oauth2",
-                "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
-            }
-        },
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -116,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_login(client: TestClient):
     response = client.post("/token", data={"username": "johndoe", "password": "secret"})
@@ -190,3 +79,114 @@ def test_inactive_user(client: TestClient):
     response = client.get("/users/me", headers={"Authorization": "Bearer alice"})
     assert response.status_code == 400, response.text
     assert response.json() == {"detail": "Inactive user"}
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "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",
+                            "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", "type": "string"},
+                        "client_secret": {"title": "Client Secret", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            },
+            "securitySchemes": {
+                "OAuth2PasswordBearer": {
+                    "type": "oauth2",
+                    "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
+                }
+            },
+        },
+    }
index b6709e2fbe5b238663698cb5d73af9bf8798ee94..7e74afafb16fe23a415c3d77fdd11e71861e9b7c 100644 (file)
@@ -3,110 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "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",
-                        "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", "type": "string"},
-                    "client_secret": {"title": "Client Secret", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        },
-        "securitySchemes": {
-            "OAuth2PasswordBearer": {
-                "type": "oauth2",
-                "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
-            }
-        },
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -116,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_login(client: TestClient):
     response = client.post("/token", data={"username": "johndoe", "password": "secret"})
@@ -190,3 +79,114 @@ def test_inactive_user(client: TestClient):
     response = client.get("/users/me", headers={"Authorization": "Bearer alice"})
     assert response.status_code == 400, response.text
     assert response.json() == {"detail": "Inactive user"}
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "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",
+                            "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", "type": "string"},
+                        "client_secret": {"title": "Client Secret", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            },
+            "securitySchemes": {
+                "OAuth2PasswordBearer": {
+                    "type": "oauth2",
+                    "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
+                }
+            },
+        },
+    }
index 26f5c097ffcb99a21072e1cb863ca9df0b201237..a463751f5ee3e2c8a6418fcc5d0e79f543a73100 100644 (file)
@@ -3,110 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "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",
-                        "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", "type": "string"},
-                    "client_secret": {"title": "Client Secret", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        },
-        "securitySchemes": {
-            "OAuth2PasswordBearer": {
-                "type": "oauth2",
-                "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
-            }
-        },
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -116,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_login(client: TestClient):
     response = client.post("/token", data={"username": "johndoe", "password": "secret"})
@@ -190,3 +79,114 @@ def test_inactive_user(client: TestClient):
     response = client.get("/users/me", headers={"Authorization": "Bearer alice"})
     assert response.status_code == 400, response.text
     assert response.json() == {"detail": "Inactive user"}
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "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",
+                            "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", "type": "string"},
+                        "client_secret": {"title": "Client Secret", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            },
+            "securitySchemes": {
+                "OAuth2PasswordBearer": {
+                    "type": "oauth2",
+                    "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
+                }
+            },
+        },
+    }
index e8697339ff1593ea23654439c5bb676918192601..ccb5b3c9f87568408395aac5acb3e1bdaa547194 100644 (file)
@@ -10,178 +10,6 @@ from docs_src.security.tutorial005 import (
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/token": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Token"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Login For Access Token",
-                "operationId": "login_for_access_token_token_post",
-                "requestBody": {
-                    "content": {
-                        "application/x-www-form-urlencoded": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_login_for_access_token_token_post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/users/me/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-                "summary": "Read Users Me",
-                "operationId": "read_users_me_users_me__get",
-                "security": [{"OAuth2PasswordBearer": ["me"]}],
-            }
-        },
-        "/users/me/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Own Items",
-                "operationId": "read_own_items_users_me_items__get",
-                "security": [{"OAuth2PasswordBearer": ["items", "me"]}],
-            }
-        },
-        "/status/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read System Status",
-                "operationId": "read_system_status_status__get",
-                "security": [{"OAuth2PasswordBearer": []}],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "User": {
-                "title": "User",
-                "required": ["username"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "email": {"title": "Email", "type": "string"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                    "disabled": {"title": "Disabled", "type": "boolean"},
-                },
-            },
-            "Token": {
-                "title": "Token",
-                "required": ["access_token", "token_type"],
-                "type": "object",
-                "properties": {
-                    "access_token": {"title": "Access Token", "type": "string"},
-                    "token_type": {"title": "Token Type", "type": "string"},
-                },
-            },
-            "Body_login_for_access_token_token_post": {
-                "title": "Body_login_for_access_token_token_post",
-                "required": ["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", "type": "string"},
-                    "client_secret": {"title": "Client Secret", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        },
-        "securitySchemes": {
-            "OAuth2PasswordBearer": {
-                "type": "oauth2",
-                "flows": {
-                    "password": {
-                        "scopes": {
-                            "me": "Read information about the current user.",
-                            "items": "Read items.",
-                        },
-                        "tokenUrl": "token",
-                    }
-                },
-            }
-        },
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def get_access_token(username="johndoe", password="secret", scope=None):
     data = {"username": username, "password": password}
@@ -345,3 +173,175 @@ def test_read_system_status_no_token():
     assert response.status_code == 401, response.text
     assert response.json() == {"detail": "Not authenticated"}
     assert response.headers["WWW-Authenticate"] == "Bearer"
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/token": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Token"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Login For Access Token",
+                    "operationId": "login_for_access_token_token_post",
+                    "requestBody": {
+                        "content": {
+                            "application/x-www-form-urlencoded": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_login_for_access_token_token_post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/users/me/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                    "summary": "Read Users Me",
+                    "operationId": "read_users_me_users_me__get",
+                    "security": [{"OAuth2PasswordBearer": ["me"]}],
+                }
+            },
+            "/users/me/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Own Items",
+                    "operationId": "read_own_items_users_me_items__get",
+                    "security": [{"OAuth2PasswordBearer": ["items", "me"]}],
+                }
+            },
+            "/status/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read System Status",
+                    "operationId": "read_system_status_status__get",
+                    "security": [{"OAuth2PasswordBearer": []}],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "User": {
+                    "title": "User",
+                    "required": ["username"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "email": {"title": "Email", "type": "string"},
+                        "full_name": {"title": "Full Name", "type": "string"},
+                        "disabled": {"title": "Disabled", "type": "boolean"},
+                    },
+                },
+                "Token": {
+                    "title": "Token",
+                    "required": ["access_token", "token_type"],
+                    "type": "object",
+                    "properties": {
+                        "access_token": {"title": "Access Token", "type": "string"},
+                        "token_type": {"title": "Token Type", "type": "string"},
+                    },
+                },
+                "Body_login_for_access_token_token_post": {
+                    "title": "Body_login_for_access_token_token_post",
+                    "required": ["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", "type": "string"},
+                        "client_secret": {"title": "Client Secret", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            },
+            "securitySchemes": {
+                "OAuth2PasswordBearer": {
+                    "type": "oauth2",
+                    "flows": {
+                        "password": {
+                            "scopes": {
+                                "me": "Read information about the current user.",
+                                "items": "Read items.",
+                            },
+                            "tokenUrl": "token",
+                        }
+                    },
+                }
+            },
+        },
+    }
index b6c2708f00d6fb700c231e029f59f2438baccb05..e851f47fecd373c5a59d2e039b1174523976a63d 100644 (file)
@@ -10,178 +10,6 @@ from docs_src.security.tutorial005_an import (
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/token": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Token"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Login For Access Token",
-                "operationId": "login_for_access_token_token_post",
-                "requestBody": {
-                    "content": {
-                        "application/x-www-form-urlencoded": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_login_for_access_token_token_post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/users/me/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-                "summary": "Read Users Me",
-                "operationId": "read_users_me_users_me__get",
-                "security": [{"OAuth2PasswordBearer": ["me"]}],
-            }
-        },
-        "/users/me/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Own Items",
-                "operationId": "read_own_items_users_me_items__get",
-                "security": [{"OAuth2PasswordBearer": ["items", "me"]}],
-            }
-        },
-        "/status/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read System Status",
-                "operationId": "read_system_status_status__get",
-                "security": [{"OAuth2PasswordBearer": []}],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "User": {
-                "title": "User",
-                "required": ["username"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "email": {"title": "Email", "type": "string"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                    "disabled": {"title": "Disabled", "type": "boolean"},
-                },
-            },
-            "Token": {
-                "title": "Token",
-                "required": ["access_token", "token_type"],
-                "type": "object",
-                "properties": {
-                    "access_token": {"title": "Access Token", "type": "string"},
-                    "token_type": {"title": "Token Type", "type": "string"},
-                },
-            },
-            "Body_login_for_access_token_token_post": {
-                "title": "Body_login_for_access_token_token_post",
-                "required": ["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", "type": "string"},
-                    "client_secret": {"title": "Client Secret", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        },
-        "securitySchemes": {
-            "OAuth2PasswordBearer": {
-                "type": "oauth2",
-                "flows": {
-                    "password": {
-                        "scopes": {
-                            "me": "Read information about the current user.",
-                            "items": "Read items.",
-                        },
-                        "tokenUrl": "token",
-                    }
-                },
-            }
-        },
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def get_access_token(username="johndoe", password="secret", scope=None):
     data = {"username": username, "password": password}
@@ -345,3 +173,175 @@ def test_read_system_status_no_token():
     assert response.status_code == 401, response.text
     assert response.json() == {"detail": "Not authenticated"}
     assert response.headers["WWW-Authenticate"] == "Bearer"
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/token": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Token"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Login For Access Token",
+                    "operationId": "login_for_access_token_token_post",
+                    "requestBody": {
+                        "content": {
+                            "application/x-www-form-urlencoded": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_login_for_access_token_token_post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/users/me/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                    "summary": "Read Users Me",
+                    "operationId": "read_users_me_users_me__get",
+                    "security": [{"OAuth2PasswordBearer": ["me"]}],
+                }
+            },
+            "/users/me/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Own Items",
+                    "operationId": "read_own_items_users_me_items__get",
+                    "security": [{"OAuth2PasswordBearer": ["items", "me"]}],
+                }
+            },
+            "/status/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read System Status",
+                    "operationId": "read_system_status_status__get",
+                    "security": [{"OAuth2PasswordBearer": []}],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "User": {
+                    "title": "User",
+                    "required": ["username"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "email": {"title": "Email", "type": "string"},
+                        "full_name": {"title": "Full Name", "type": "string"},
+                        "disabled": {"title": "Disabled", "type": "boolean"},
+                    },
+                },
+                "Token": {
+                    "title": "Token",
+                    "required": ["access_token", "token_type"],
+                    "type": "object",
+                    "properties": {
+                        "access_token": {"title": "Access Token", "type": "string"},
+                        "token_type": {"title": "Token Type", "type": "string"},
+                    },
+                },
+                "Body_login_for_access_token_token_post": {
+                    "title": "Body_login_for_access_token_token_post",
+                    "required": ["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", "type": "string"},
+                        "client_secret": {"title": "Client Secret", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            },
+            "securitySchemes": {
+                "OAuth2PasswordBearer": {
+                    "type": "oauth2",
+                    "flows": {
+                        "password": {
+                            "scopes": {
+                                "me": "Read information about the current user.",
+                                "items": "Read items.",
+                            },
+                            "tokenUrl": "token",
+                        }
+                    },
+                }
+            },
+        },
+    }
index 15a9445b9f2473590a7bc87da82e6e211b62ac27..cca5819802ccc52f7a7d0615cbfe522f6ddb1441 100644 (file)
@@ -3,172 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/token": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Token"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Login For Access Token",
-                "operationId": "login_for_access_token_token_post",
-                "requestBody": {
-                    "content": {
-                        "application/x-www-form-urlencoded": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_login_for_access_token_token_post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/users/me/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-                "summary": "Read Users Me",
-                "operationId": "read_users_me_users_me__get",
-                "security": [{"OAuth2PasswordBearer": ["me"]}],
-            }
-        },
-        "/users/me/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Own Items",
-                "operationId": "read_own_items_users_me_items__get",
-                "security": [{"OAuth2PasswordBearer": ["items", "me"]}],
-            }
-        },
-        "/status/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read System Status",
-                "operationId": "read_system_status_status__get",
-                "security": [{"OAuth2PasswordBearer": []}],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "User": {
-                "title": "User",
-                "required": ["username"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "email": {"title": "Email", "type": "string"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                    "disabled": {"title": "Disabled", "type": "boolean"},
-                },
-            },
-            "Token": {
-                "title": "Token",
-                "required": ["access_token", "token_type"],
-                "type": "object",
-                "properties": {
-                    "access_token": {"title": "Access Token", "type": "string"},
-                    "token_type": {"title": "Token Type", "type": "string"},
-                },
-            },
-            "Body_login_for_access_token_token_post": {
-                "title": "Body_login_for_access_token_token_post",
-                "required": ["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", "type": "string"},
-                    "client_secret": {"title": "Client Secret", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        },
-        "securitySchemes": {
-            "OAuth2PasswordBearer": {
-                "type": "oauth2",
-                "flows": {
-                    "password": {
-                        "scopes": {
-                            "me": "Read information about the current user.",
-                            "items": "Read items.",
-                        },
-                        "tokenUrl": "token",
-                    }
-                },
-            }
-        },
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -178,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def get_access_token(
     *, username="johndoe", password="secret", scope=None, client: TestClient
 ):
@@ -373,3 +200,176 @@ def test_read_system_status_no_token(client: TestClient):
     assert response.status_code == 401, response.text
     assert response.json() == {"detail": "Not authenticated"}
     assert response.headers["WWW-Authenticate"] == "Bearer"
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/token": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Token"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Login For Access Token",
+                    "operationId": "login_for_access_token_token_post",
+                    "requestBody": {
+                        "content": {
+                            "application/x-www-form-urlencoded": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_login_for_access_token_token_post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/users/me/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                    "summary": "Read Users Me",
+                    "operationId": "read_users_me_users_me__get",
+                    "security": [{"OAuth2PasswordBearer": ["me"]}],
+                }
+            },
+            "/users/me/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Own Items",
+                    "operationId": "read_own_items_users_me_items__get",
+                    "security": [{"OAuth2PasswordBearer": ["items", "me"]}],
+                }
+            },
+            "/status/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read System Status",
+                    "operationId": "read_system_status_status__get",
+                    "security": [{"OAuth2PasswordBearer": []}],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "User": {
+                    "title": "User",
+                    "required": ["username"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "email": {"title": "Email", "type": "string"},
+                        "full_name": {"title": "Full Name", "type": "string"},
+                        "disabled": {"title": "Disabled", "type": "boolean"},
+                    },
+                },
+                "Token": {
+                    "title": "Token",
+                    "required": ["access_token", "token_type"],
+                    "type": "object",
+                    "properties": {
+                        "access_token": {"title": "Access Token", "type": "string"},
+                        "token_type": {"title": "Token Type", "type": "string"},
+                    },
+                },
+                "Body_login_for_access_token_token_post": {
+                    "title": "Body_login_for_access_token_token_post",
+                    "required": ["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", "type": "string"},
+                        "client_secret": {"title": "Client Secret", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            },
+            "securitySchemes": {
+                "OAuth2PasswordBearer": {
+                    "type": "oauth2",
+                    "flows": {
+                        "password": {
+                            "scopes": {
+                                "me": "Read information about the current user.",
+                                "items": "Read items.",
+                            },
+                            "tokenUrl": "token",
+                        }
+                    },
+                }
+            },
+        },
+    }
index 989424dd389a6800449bce34de64768725b897f8..eae851457568789642ff4523ba562abf356bbf7d 100644 (file)
@@ -3,172 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/token": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Token"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Login For Access Token",
-                "operationId": "login_for_access_token_token_post",
-                "requestBody": {
-                    "content": {
-                        "application/x-www-form-urlencoded": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_login_for_access_token_token_post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/users/me/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-                "summary": "Read Users Me",
-                "operationId": "read_users_me_users_me__get",
-                "security": [{"OAuth2PasswordBearer": ["me"]}],
-            }
-        },
-        "/users/me/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Own Items",
-                "operationId": "read_own_items_users_me_items__get",
-                "security": [{"OAuth2PasswordBearer": ["items", "me"]}],
-            }
-        },
-        "/status/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read System Status",
-                "operationId": "read_system_status_status__get",
-                "security": [{"OAuth2PasswordBearer": []}],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "User": {
-                "title": "User",
-                "required": ["username"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "email": {"title": "Email", "type": "string"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                    "disabled": {"title": "Disabled", "type": "boolean"},
-                },
-            },
-            "Token": {
-                "title": "Token",
-                "required": ["access_token", "token_type"],
-                "type": "object",
-                "properties": {
-                    "access_token": {"title": "Access Token", "type": "string"},
-                    "token_type": {"title": "Token Type", "type": "string"},
-                },
-            },
-            "Body_login_for_access_token_token_post": {
-                "title": "Body_login_for_access_token_token_post",
-                "required": ["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", "type": "string"},
-                    "client_secret": {"title": "Client Secret", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        },
-        "securitySchemes": {
-            "OAuth2PasswordBearer": {
-                "type": "oauth2",
-                "flows": {
-                    "password": {
-                        "scopes": {
-                            "me": "Read information about the current user.",
-                            "items": "Read items.",
-                        },
-                        "tokenUrl": "token",
-                    }
-                },
-            }
-        },
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -178,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def get_access_token(
     *, username="johndoe", password="secret", scope=None, client: TestClient
 ):
@@ -373,3 +200,176 @@ def test_read_system_status_no_token(client: TestClient):
     assert response.status_code == 401, response.text
     assert response.json() == {"detail": "Not authenticated"}
     assert response.headers["WWW-Authenticate"] == "Bearer"
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/token": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Token"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Login For Access Token",
+                    "operationId": "login_for_access_token_token_post",
+                    "requestBody": {
+                        "content": {
+                            "application/x-www-form-urlencoded": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_login_for_access_token_token_post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/users/me/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                    "summary": "Read Users Me",
+                    "operationId": "read_users_me_users_me__get",
+                    "security": [{"OAuth2PasswordBearer": ["me"]}],
+                }
+            },
+            "/users/me/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Own Items",
+                    "operationId": "read_own_items_users_me_items__get",
+                    "security": [{"OAuth2PasswordBearer": ["items", "me"]}],
+                }
+            },
+            "/status/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read System Status",
+                    "operationId": "read_system_status_status__get",
+                    "security": [{"OAuth2PasswordBearer": []}],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "User": {
+                    "title": "User",
+                    "required": ["username"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "email": {"title": "Email", "type": "string"},
+                        "full_name": {"title": "Full Name", "type": "string"},
+                        "disabled": {"title": "Disabled", "type": "boolean"},
+                    },
+                },
+                "Token": {
+                    "title": "Token",
+                    "required": ["access_token", "token_type"],
+                    "type": "object",
+                    "properties": {
+                        "access_token": {"title": "Access Token", "type": "string"},
+                        "token_type": {"title": "Token Type", "type": "string"},
+                    },
+                },
+                "Body_login_for_access_token_token_post": {
+                    "title": "Body_login_for_access_token_token_post",
+                    "required": ["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", "type": "string"},
+                        "client_secret": {"title": "Client Secret", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            },
+            "securitySchemes": {
+                "OAuth2PasswordBearer": {
+                    "type": "oauth2",
+                    "flows": {
+                        "password": {
+                            "scopes": {
+                                "me": "Read information about the current user.",
+                                "items": "Read items.",
+                            },
+                            "tokenUrl": "token",
+                        }
+                    },
+                }
+            },
+        },
+    }
index 3144a2365719130fe3d9403b9dff5ff13e2e0049..cdbd8f75ec25c04ff16ada91f4df3d15b2497ab3 100644 (file)
@@ -3,172 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/token": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Token"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Login For Access Token",
-                "operationId": "login_for_access_token_token_post",
-                "requestBody": {
-                    "content": {
-                        "application/x-www-form-urlencoded": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_login_for_access_token_token_post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/users/me/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-                "summary": "Read Users Me",
-                "operationId": "read_users_me_users_me__get",
-                "security": [{"OAuth2PasswordBearer": ["me"]}],
-            }
-        },
-        "/users/me/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Own Items",
-                "operationId": "read_own_items_users_me_items__get",
-                "security": [{"OAuth2PasswordBearer": ["items", "me"]}],
-            }
-        },
-        "/status/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read System Status",
-                "operationId": "read_system_status_status__get",
-                "security": [{"OAuth2PasswordBearer": []}],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "User": {
-                "title": "User",
-                "required": ["username"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "email": {"title": "Email", "type": "string"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                    "disabled": {"title": "Disabled", "type": "boolean"},
-                },
-            },
-            "Token": {
-                "title": "Token",
-                "required": ["access_token", "token_type"],
-                "type": "object",
-                "properties": {
-                    "access_token": {"title": "Access Token", "type": "string"},
-                    "token_type": {"title": "Token Type", "type": "string"},
-                },
-            },
-            "Body_login_for_access_token_token_post": {
-                "title": "Body_login_for_access_token_token_post",
-                "required": ["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", "type": "string"},
-                    "client_secret": {"title": "Client Secret", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        },
-        "securitySchemes": {
-            "OAuth2PasswordBearer": {
-                "type": "oauth2",
-                "flows": {
-                    "password": {
-                        "scopes": {
-                            "me": "Read information about the current user.",
-                            "items": "Read items.",
-                        },
-                        "tokenUrl": "token",
-                    }
-                },
-            }
-        },
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -178,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def get_access_token(
     *, username="johndoe", password="secret", scope=None, client: TestClient
 ):
@@ -373,3 +200,176 @@ def test_read_system_status_no_token(client: TestClient):
     assert response.status_code == 401, response.text
     assert response.json() == {"detail": "Not authenticated"}
     assert response.headers["WWW-Authenticate"] == "Bearer"
+
+
+@needs_py310
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/token": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Token"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Login For Access Token",
+                    "operationId": "login_for_access_token_token_post",
+                    "requestBody": {
+                        "content": {
+                            "application/x-www-form-urlencoded": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_login_for_access_token_token_post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/users/me/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                    "summary": "Read Users Me",
+                    "operationId": "read_users_me_users_me__get",
+                    "security": [{"OAuth2PasswordBearer": ["me"]}],
+                }
+            },
+            "/users/me/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Own Items",
+                    "operationId": "read_own_items_users_me_items__get",
+                    "security": [{"OAuth2PasswordBearer": ["items", "me"]}],
+                }
+            },
+            "/status/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read System Status",
+                    "operationId": "read_system_status_status__get",
+                    "security": [{"OAuth2PasswordBearer": []}],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "User": {
+                    "title": "User",
+                    "required": ["username"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "email": {"title": "Email", "type": "string"},
+                        "full_name": {"title": "Full Name", "type": "string"},
+                        "disabled": {"title": "Disabled", "type": "boolean"},
+                    },
+                },
+                "Token": {
+                    "title": "Token",
+                    "required": ["access_token", "token_type"],
+                    "type": "object",
+                    "properties": {
+                        "access_token": {"title": "Access Token", "type": "string"},
+                        "token_type": {"title": "Token Type", "type": "string"},
+                    },
+                },
+                "Body_login_for_access_token_token_post": {
+                    "title": "Body_login_for_access_token_token_post",
+                    "required": ["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", "type": "string"},
+                        "client_secret": {"title": "Client Secret", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            },
+            "securitySchemes": {
+                "OAuth2PasswordBearer": {
+                    "type": "oauth2",
+                    "flows": {
+                        "password": {
+                            "scopes": {
+                                "me": "Read information about the current user.",
+                                "items": "Read items.",
+                            },
+                            "tokenUrl": "token",
+                        }
+                    },
+                }
+            },
+        },
+    }
index 290136e179ace76ea0f6e216a2b3002fa7c8a750..45b2a2341d7f008d00e5b798e3096cafd721738d 100644 (file)
@@ -3,172 +3,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/token": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Token"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Login For Access Token",
-                "operationId": "login_for_access_token_token_post",
-                "requestBody": {
-                    "content": {
-                        "application/x-www-form-urlencoded": {
-                            "schema": {
-                                "$ref": "#/components/schemas/Body_login_for_access_token_token_post"
-                            }
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/users/me/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    }
-                },
-                "summary": "Read Users Me",
-                "operationId": "read_users_me_users_me__get",
-                "security": [{"OAuth2PasswordBearer": ["me"]}],
-            }
-        },
-        "/users/me/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Own Items",
-                "operationId": "read_own_items_users_me_items__get",
-                "security": [{"OAuth2PasswordBearer": ["items", "me"]}],
-            }
-        },
-        "/status/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read System Status",
-                "operationId": "read_system_status_status__get",
-                "security": [{"OAuth2PasswordBearer": []}],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "User": {
-                "title": "User",
-                "required": ["username"],
-                "type": "object",
-                "properties": {
-                    "username": {"title": "Username", "type": "string"},
-                    "email": {"title": "Email", "type": "string"},
-                    "full_name": {"title": "Full Name", "type": "string"},
-                    "disabled": {"title": "Disabled", "type": "boolean"},
-                },
-            },
-            "Token": {
-                "title": "Token",
-                "required": ["access_token", "token_type"],
-                "type": "object",
-                "properties": {
-                    "access_token": {"title": "Access Token", "type": "string"},
-                    "token_type": {"title": "Token Type", "type": "string"},
-                },
-            },
-            "Body_login_for_access_token_token_post": {
-                "title": "Body_login_for_access_token_token_post",
-                "required": ["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", "type": "string"},
-                    "client_secret": {"title": "Client Secret", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        },
-        "securitySchemes": {
-            "OAuth2PasswordBearer": {
-                "type": "oauth2",
-                "flows": {
-                    "password": {
-                        "scopes": {
-                            "me": "Read information about the current user.",
-                            "items": "Read items.",
-                        },
-                        "tokenUrl": "token",
-                    }
-                },
-            }
-        },
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -178,13 +12,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def get_access_token(
     *, username="johndoe", password="secret", scope=None, client: TestClient
 ):
@@ -373,3 +200,176 @@ def test_read_system_status_no_token(client: TestClient):
     assert response.status_code == 401, response.text
     assert response.json() == {"detail": "Not authenticated"}
     assert response.headers["WWW-Authenticate"] == "Bearer"
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/token": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Token"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Login For Access Token",
+                    "operationId": "login_for_access_token_token_post",
+                    "requestBody": {
+                        "content": {
+                            "application/x-www-form-urlencoded": {
+                                "schema": {
+                                    "$ref": "#/components/schemas/Body_login_for_access_token_token_post"
+                                }
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/users/me/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        }
+                    },
+                    "summary": "Read Users Me",
+                    "operationId": "read_users_me_users_me__get",
+                    "security": [{"OAuth2PasswordBearer": ["me"]}],
+                }
+            },
+            "/users/me/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Own Items",
+                    "operationId": "read_own_items_users_me_items__get",
+                    "security": [{"OAuth2PasswordBearer": ["items", "me"]}],
+                }
+            },
+            "/status/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read System Status",
+                    "operationId": "read_system_status_status__get",
+                    "security": [{"OAuth2PasswordBearer": []}],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "User": {
+                    "title": "User",
+                    "required": ["username"],
+                    "type": "object",
+                    "properties": {
+                        "username": {"title": "Username", "type": "string"},
+                        "email": {"title": "Email", "type": "string"},
+                        "full_name": {"title": "Full Name", "type": "string"},
+                        "disabled": {"title": "Disabled", "type": "boolean"},
+                    },
+                },
+                "Token": {
+                    "title": "Token",
+                    "required": ["access_token", "token_type"],
+                    "type": "object",
+                    "properties": {
+                        "access_token": {"title": "Access Token", "type": "string"},
+                        "token_type": {"title": "Token Type", "type": "string"},
+                    },
+                },
+                "Body_login_for_access_token_token_post": {
+                    "title": "Body_login_for_access_token_token_post",
+                    "required": ["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", "type": "string"},
+                        "client_secret": {"title": "Client Secret", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            },
+            "securitySchemes": {
+                "OAuth2PasswordBearer": {
+                    "type": "oauth2",
+                    "flows": {
+                        "password": {
+                            "scopes": {
+                                "me": "Read information about the current user.",
+                                "items": "Read items.",
+                            },
+                            "tokenUrl": "token",
+                        }
+                    },
+                }
+            },
+        },
+    }
index bbfef9f7c4d7b84f5b347753737bdd51034f0711..73cbdc538d21bfb237b8969692266d69baf1a90f 100644 (file)
@@ -6,35 +6,6 @@ from docs_src.security.tutorial006 import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"HTTPBasic": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_http_basic():
     response = client.get("/users/me", auth=("john", "secret"))
@@ -65,3 +36,30 @@ def test_security_http_basic_non_basic_credentials():
     assert response.status_code == 401, response.text
     assert response.headers["WWW-Authenticate"] == "Basic"
     assert response.json() == {"detail": "Invalid authentication credentials"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"HTTPBasic": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
+        },
+    }
index 1d1668fec14dcb0199ceab16dff8b3e5e1905149..5f970ed013fb73e270039e7a2369e1e0216f72d3 100644 (file)
@@ -6,35 +6,6 @@ from docs_src.security.tutorial006_an import app
 
 client = TestClient(app)
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"HTTPBasic": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
-    },
-}
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
 
 def test_security_http_basic():
     response = client.get("/users/me", auth=("john", "secret"))
@@ -65,3 +36,30 @@ def test_security_http_basic_non_basic_credentials():
     assert response.status_code == 401, response.text
     assert response.headers["WWW-Authenticate"] == "Basic"
     assert response.json() == {"detail": "Invalid authentication credentials"}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"HTTPBasic": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
+        },
+    }
index b72b5d864d42d6e85d31adc6c3cca1b1bea34bf6..7d7a851acf65b082f6b703adfb83d2b5e220761a 100644 (file)
@@ -5,29 +5,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/me": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Current User",
-                "operationId": "read_current_user_users_me_get",
-                "security": [{"HTTPBasic": []}],
-            }
-        }
-    },
-    "components": {
-        "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
-    },
-}
-
 
 @pytest.fixture(name="client")
 def get_client():
@@ -37,13 +14,6 @@ def get_client():
     return client
 
 
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_security_http_basic(client: TestClient):
     response = client.get("/users/me", auth=("john", "secret"))
@@ -77,3 +47,31 @@ def test_security_http_basic_non_basic_credentials(client: TestClient):
     assert response.status_code == 401, response.text
     assert response.headers["WWW-Authenticate"] == "Basic"
     assert response.json() == {"detail": "Invalid authentication credentials"}
+
+
+@needs_py39
+def test_openapi_schema(client: TestClient):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/me": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Current User",
+                    "operationId": "read_current_user_users_me_get",
+                    "security": [{"HTTPBasic": []}],
+                }
+            }
+        },
+        "components": {
+            "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
+        },
+    }
index 9d03ce61bad1845d055dd2eff1540f939859657a..a2628f3c3bc0855c19b94c1d0c8e4794293a708c 100644 (file)
@@ -5,283 +5,6 @@ from pathlib import Path
 import pytest
 from fastapi.testclient import TestClient
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Users Users  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/User"},
-                                }
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            },
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create User",
-                "operationId": "create_user_users__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/UserCreate"}
-                        }
-                    },
-                    "required": True,
-                },
-            },
-        },
-        "/users/{user_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read User",
-                "operationId": "read_user_users__user_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "User Id", "type": "integer"},
-                        "name": "user_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/users/{user_id}/items/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Item For User",
-                "operationId": "create_item_for_user_users__user_id__items__post",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "User Id", "type": "integer"},
-                        "name": "user_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/ItemCreate"}
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Items Items  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/Item"},
-                                }
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "ItemCreate": {
-                "title": "ItemCreate",
-                "required": ["title"],
-                "type": "object",
-                "properties": {
-                    "title": {"title": "Title", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["title", "id", "owner_id"],
-                "type": "object",
-                "properties": {
-                    "title": {"title": "Title", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                    "id": {"title": "Id", "type": "integer"},
-                    "owner_id": {"title": "Owner Id", "type": "integer"},
-                },
-            },
-            "User": {
-                "title": "User",
-                "required": ["email", "id", "is_active"],
-                "type": "object",
-                "properties": {
-                    "email": {"title": "Email", "type": "string"},
-                    "id": {"title": "Id", "type": "integer"},
-                    "is_active": {"title": "Is Active", "type": "boolean"},
-                    "items": {
-                        "title": "Items",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/Item"},
-                        "default": [],
-                    },
-                },
-            },
-            "UserCreate": {
-                "title": "UserCreate",
-                "required": ["email", "password"],
-                "type": "object",
-                "properties": {
-                    "email": {"title": "Email", "type": "string"},
-                    "password": {"title": "Password", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(scope="module")
 def client(tmp_path_factory: pytest.TempPathFactory):
@@ -303,12 +26,6 @@ def client(tmp_path_factory: pytest.TempPathFactory):
     os.chdir(cwd)
 
 
-def test_openapi_schema(client):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_create_user(client):
     test_user = {"email": "johndoe@example.com", "password": "secret"}
     response = client.post("/users/", json=test_user)
@@ -366,3 +83,302 @@ def test_read_items(client):
     first_item = data[0]
     assert "title" in first_item
     assert "description" in first_item
+
+
+def test_openapi_schema(client):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Users Users  Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/User"},
+                                    }
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                },
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create User",
+                    "operationId": "create_user_users__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/UserCreate"}
+                            }
+                        },
+                        "required": True,
+                    },
+                },
+            },
+            "/users/{user_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read User",
+                    "operationId": "read_user_users__user_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "User Id", "type": "integer"},
+                            "name": "user_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/users/{user_id}/items/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Item For User",
+                    "operationId": "create_item_for_user_users__user_id__items__post",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "User Id", "type": "integer"},
+                            "name": "user_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/ItemCreate"}
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Items Items  Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/Item"},
+                                    }
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "ItemCreate": {
+                    "title": "ItemCreate",
+                    "required": ["title"],
+                    "type": "object",
+                    "properties": {
+                        "title": {"title": "Title", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                    },
+                },
+                "Item": {
+                    "title": "Item",
+                    "required": ["title", "id", "owner_id"],
+                    "type": "object",
+                    "properties": {
+                        "title": {"title": "Title", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                        "id": {"title": "Id", "type": "integer"},
+                        "owner_id": {"title": "Owner Id", "type": "integer"},
+                    },
+                },
+                "User": {
+                    "title": "User",
+                    "required": ["email", "id", "is_active"],
+                    "type": "object",
+                    "properties": {
+                        "email": {"title": "Email", "type": "string"},
+                        "id": {"title": "Id", "type": "integer"},
+                        "is_active": {"title": "Is Active", "type": "boolean"},
+                        "items": {
+                            "title": "Items",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/Item"},
+                            "default": [],
+                        },
+                    },
+                },
+                "UserCreate": {
+                    "title": "UserCreate",
+                    "required": ["email", "password"],
+                    "type": "object",
+                    "properties": {
+                        "email": {"title": "Email", "type": "string"},
+                        "password": {"title": "Password", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index fbaa8938a46d160322fae5484e9d3f380800a0bd..02501b1a248f911bb69fdfd9fa923f31012b4013 100644 (file)
@@ -4,283 +4,6 @@ from pathlib import Path
 import pytest
 from fastapi.testclient import TestClient
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Users Users  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/User"},
-                                }
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            },
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create User",
-                "operationId": "create_user_users__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/UserCreate"}
-                        }
-                    },
-                    "required": True,
-                },
-            },
-        },
-        "/users/{user_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read User",
-                "operationId": "read_user_users__user_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "User Id", "type": "integer"},
-                        "name": "user_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/users/{user_id}/items/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Item For User",
-                "operationId": "create_item_for_user_users__user_id__items__post",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "User Id", "type": "integer"},
-                        "name": "user_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/ItemCreate"}
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Items Items  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/Item"},
-                                }
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "ItemCreate": {
-                "title": "ItemCreate",
-                "required": ["title"],
-                "type": "object",
-                "properties": {
-                    "title": {"title": "Title", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["title", "id", "owner_id"],
-                "type": "object",
-                "properties": {
-                    "title": {"title": "Title", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                    "id": {"title": "Id", "type": "integer"},
-                    "owner_id": {"title": "Owner Id", "type": "integer"},
-                },
-            },
-            "User": {
-                "title": "User",
-                "required": ["email", "id", "is_active"],
-                "type": "object",
-                "properties": {
-                    "email": {"title": "Email", "type": "string"},
-                    "id": {"title": "Id", "type": "integer"},
-                    "is_active": {"title": "Is Active", "type": "boolean"},
-                    "items": {
-                        "title": "Items",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/Item"},
-                        "default": [],
-                    },
-                },
-            },
-            "UserCreate": {
-                "title": "UserCreate",
-                "required": ["email", "password"],
-                "type": "object",
-                "properties": {
-                    "email": {"title": "Email", "type": "string"},
-                    "password": {"title": "Password", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(scope="module")
 def client():
@@ -299,12 +22,6 @@ def client():
         test_db.unlink()
 
 
-def test_openapi_schema(client):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_create_user(client):
     test_user = {"email": "johndoe@example.com", "password": "secret"}
     response = client.post("/users/", json=test_user)
@@ -368,3 +85,302 @@ def test_read_items(client):
     first_item = data[0]
     assert "title" in first_item
     assert "description" in first_item
+
+
+def test_openapi_schema(client):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Users Users  Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/User"},
+                                    }
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                },
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create User",
+                    "operationId": "create_user_users__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/UserCreate"}
+                            }
+                        },
+                        "required": True,
+                    },
+                },
+            },
+            "/users/{user_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read User",
+                    "operationId": "read_user_users__user_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "User Id", "type": "integer"},
+                            "name": "user_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/users/{user_id}/items/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Item For User",
+                    "operationId": "create_item_for_user_users__user_id__items__post",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "User Id", "type": "integer"},
+                            "name": "user_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/ItemCreate"}
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Items Items  Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/Item"},
+                                    }
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "ItemCreate": {
+                    "title": "ItemCreate",
+                    "required": ["title"],
+                    "type": "object",
+                    "properties": {
+                        "title": {"title": "Title", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                    },
+                },
+                "Item": {
+                    "title": "Item",
+                    "required": ["title", "id", "owner_id"],
+                    "type": "object",
+                    "properties": {
+                        "title": {"title": "Title", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                        "id": {"title": "Id", "type": "integer"},
+                        "owner_id": {"title": "Owner Id", "type": "integer"},
+                    },
+                },
+                "User": {
+                    "title": "User",
+                    "required": ["email", "id", "is_active"],
+                    "type": "object",
+                    "properties": {
+                        "email": {"title": "Email", "type": "string"},
+                        "id": {"title": "Id", "type": "integer"},
+                        "is_active": {"title": "Is Active", "type": "boolean"},
+                        "items": {
+                            "title": "Items",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/Item"},
+                            "default": [],
+                        },
+                    },
+                },
+                "UserCreate": {
+                    "title": "UserCreate",
+                    "required": ["email", "password"],
+                    "type": "object",
+                    "properties": {
+                        "email": {"title": "Email", "type": "string"},
+                        "password": {"title": "Password", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index d131b4b6a9495abb5e9c1418cf28c334f00121b4..67b92ea4a4012f7effcd9c9244cdcb23881ed09c 100644 (file)
@@ -7,283 +7,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Users Users  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/User"},
-                                }
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            },
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create User",
-                "operationId": "create_user_users__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/UserCreate"}
-                        }
-                    },
-                    "required": True,
-                },
-            },
-        },
-        "/users/{user_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read User",
-                "operationId": "read_user_users__user_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "User Id", "type": "integer"},
-                        "name": "user_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/users/{user_id}/items/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Item For User",
-                "operationId": "create_item_for_user_users__user_id__items__post",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "User Id", "type": "integer"},
-                        "name": "user_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/ItemCreate"}
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Items Items  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/Item"},
-                                }
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "ItemCreate": {
-                "title": "ItemCreate",
-                "required": ["title"],
-                "type": "object",
-                "properties": {
-                    "title": {"title": "Title", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["title", "id", "owner_id"],
-                "type": "object",
-                "properties": {
-                    "title": {"title": "Title", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                    "id": {"title": "Id", "type": "integer"},
-                    "owner_id": {"title": "Owner Id", "type": "integer"},
-                },
-            },
-            "User": {
-                "title": "User",
-                "required": ["email", "id", "is_active"],
-                "type": "object",
-                "properties": {
-                    "email": {"title": "Email", "type": "string"},
-                    "id": {"title": "Id", "type": "integer"},
-                    "is_active": {"title": "Is Active", "type": "boolean"},
-                    "items": {
-                        "title": "Items",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/Item"},
-                        "default": [],
-                    },
-                },
-            },
-            "UserCreate": {
-                "title": "UserCreate",
-                "required": ["email", "password"],
-                "type": "object",
-                "properties": {
-                    "email": {"title": "Email", "type": "string"},
-                    "password": {"title": "Password", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(scope="module")
 def client(tmp_path_factory: pytest.TempPathFactory):
@@ -306,13 +29,6 @@ def client(tmp_path_factory: pytest.TempPathFactory):
     os.chdir(cwd)
 
 
-@needs_py310
-def test_openapi_schema(client):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_create_user(client):
     test_user = {"email": "johndoe@example.com", "password": "secret"}
@@ -382,3 +98,303 @@ def test_read_items(client):
     first_item = data[0]
     assert "title" in first_item
     assert "description" in first_item
+
+
+@needs_py310
+def test_openapi_schema(client):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Users Users  Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/User"},
+                                    }
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                },
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create User",
+                    "operationId": "create_user_users__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/UserCreate"}
+                            }
+                        },
+                        "required": True,
+                    },
+                },
+            },
+            "/users/{user_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read User",
+                    "operationId": "read_user_users__user_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "User Id", "type": "integer"},
+                            "name": "user_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/users/{user_id}/items/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Item For User",
+                    "operationId": "create_item_for_user_users__user_id__items__post",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "User Id", "type": "integer"},
+                            "name": "user_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/ItemCreate"}
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Items Items  Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/Item"},
+                                    }
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "ItemCreate": {
+                    "title": "ItemCreate",
+                    "required": ["title"],
+                    "type": "object",
+                    "properties": {
+                        "title": {"title": "Title", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                    },
+                },
+                "Item": {
+                    "title": "Item",
+                    "required": ["title", "id", "owner_id"],
+                    "type": "object",
+                    "properties": {
+                        "title": {"title": "Title", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                        "id": {"title": "Id", "type": "integer"},
+                        "owner_id": {"title": "Owner Id", "type": "integer"},
+                    },
+                },
+                "User": {
+                    "title": "User",
+                    "required": ["email", "id", "is_active"],
+                    "type": "object",
+                    "properties": {
+                        "email": {"title": "Email", "type": "string"},
+                        "id": {"title": "Id", "type": "integer"},
+                        "is_active": {"title": "Is Active", "type": "boolean"},
+                        "items": {
+                            "title": "Items",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/Item"},
+                            "default": [],
+                        },
+                    },
+                },
+                "UserCreate": {
+                    "title": "UserCreate",
+                    "required": ["email", "password"],
+                    "type": "object",
+                    "properties": {
+                        "email": {"title": "Email", "type": "string"},
+                        "password": {"title": "Password", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 470fb52fd5d90c94a7d82e30eaa2a99fb1b07994..a2af20ea23194e78b2aedd802580639020e492a9 100644 (file)
@@ -7,283 +7,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Users Users  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/User"},
-                                }
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            },
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create User",
-                "operationId": "create_user_users__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/UserCreate"}
-                        }
-                    },
-                    "required": True,
-                },
-            },
-        },
-        "/users/{user_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read User",
-                "operationId": "read_user_users__user_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "User Id", "type": "integer"},
-                        "name": "user_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/users/{user_id}/items/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Item For User",
-                "operationId": "create_item_for_user_users__user_id__items__post",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "User Id", "type": "integer"},
-                        "name": "user_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/ItemCreate"}
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Items Items  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/Item"},
-                                }
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "ItemCreate": {
-                "title": "ItemCreate",
-                "required": ["title"],
-                "type": "object",
-                "properties": {
-                    "title": {"title": "Title", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["title", "id", "owner_id"],
-                "type": "object",
-                "properties": {
-                    "title": {"title": "Title", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                    "id": {"title": "Id", "type": "integer"},
-                    "owner_id": {"title": "Owner Id", "type": "integer"},
-                },
-            },
-            "User": {
-                "title": "User",
-                "required": ["email", "id", "is_active"],
-                "type": "object",
-                "properties": {
-                    "email": {"title": "Email", "type": "string"},
-                    "id": {"title": "Id", "type": "integer"},
-                    "is_active": {"title": "Is Active", "type": "boolean"},
-                    "items": {
-                        "title": "Items",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/Item"},
-                        "default": [],
-                    },
-                },
-            },
-            "UserCreate": {
-                "title": "UserCreate",
-                "required": ["email", "password"],
-                "type": "object",
-                "properties": {
-                    "email": {"title": "Email", "type": "string"},
-                    "password": {"title": "Password", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(scope="module")
 def client(tmp_path_factory: pytest.TempPathFactory):
@@ -306,13 +29,6 @@ def client(tmp_path_factory: pytest.TempPathFactory):
     os.chdir(cwd)
 
 
-@needs_py39
-def test_openapi_schema(client):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_create_user(client):
     test_user = {"email": "johndoe@example.com", "password": "secret"}
@@ -382,3 +98,303 @@ def test_read_items(client):
     first_item = data[0]
     assert "title" in first_item
     assert "description" in first_item
+
+
+@needs_py39
+def test_openapi_schema(client):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Users Users  Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/User"},
+                                    }
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                },
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create User",
+                    "operationId": "create_user_users__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/UserCreate"}
+                            }
+                        },
+                        "required": True,
+                    },
+                },
+            },
+            "/users/{user_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read User",
+                    "operationId": "read_user_users__user_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "User Id", "type": "integer"},
+                            "name": "user_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/users/{user_id}/items/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Item For User",
+                    "operationId": "create_item_for_user_users__user_id__items__post",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "User Id", "type": "integer"},
+                            "name": "user_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/ItemCreate"}
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Items Items  Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/Item"},
+                                    }
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "ItemCreate": {
+                    "title": "ItemCreate",
+                    "required": ["title"],
+                    "type": "object",
+                    "properties": {
+                        "title": {"title": "Title", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                    },
+                },
+                "Item": {
+                    "title": "Item",
+                    "required": ["title", "id", "owner_id"],
+                    "type": "object",
+                    "properties": {
+                        "title": {"title": "Title", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                        "id": {"title": "Id", "type": "integer"},
+                        "owner_id": {"title": "Owner Id", "type": "integer"},
+                    },
+                },
+                "User": {
+                    "title": "User",
+                    "required": ["email", "id", "is_active"],
+                    "type": "object",
+                    "properties": {
+                        "email": {"title": "Email", "type": "string"},
+                        "id": {"title": "Id", "type": "integer"},
+                        "is_active": {"title": "Is Active", "type": "boolean"},
+                        "items": {
+                            "title": "Items",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/Item"},
+                            "default": [],
+                        },
+                    },
+                },
+                "UserCreate": {
+                    "title": "UserCreate",
+                    "required": ["email", "password"],
+                    "type": "object",
+                    "properties": {
+                        "email": {"title": "Email", "type": "string"},
+                        "password": {"title": "Password", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index dc6a1db157ebc055cb2948b4b73024077bb08bf9..2f918cfd8bb497543c4c9dff9c771633cd4baf9e 100644 (file)
@@ -7,283 +7,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Users Users  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/User"},
-                                }
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            },
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create User",
-                "operationId": "create_user_users__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/UserCreate"}
-                        }
-                    },
-                    "required": True,
-                },
-            },
-        },
-        "/users/{user_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read User",
-                "operationId": "read_user_users__user_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "User Id", "type": "integer"},
-                        "name": "user_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/users/{user_id}/items/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Item For User",
-                "operationId": "create_item_for_user_users__user_id__items__post",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "User Id", "type": "integer"},
-                        "name": "user_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/ItemCreate"}
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Items Items  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/Item"},
-                                }
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "ItemCreate": {
-                "title": "ItemCreate",
-                "required": ["title"],
-                "type": "object",
-                "properties": {
-                    "title": {"title": "Title", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["title", "id", "owner_id"],
-                "type": "object",
-                "properties": {
-                    "title": {"title": "Title", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                    "id": {"title": "Id", "type": "integer"},
-                    "owner_id": {"title": "Owner Id", "type": "integer"},
-                },
-            },
-            "User": {
-                "title": "User",
-                "required": ["email", "id", "is_active"],
-                "type": "object",
-                "properties": {
-                    "email": {"title": "Email", "type": "string"},
-                    "id": {"title": "Id", "type": "integer"},
-                    "is_active": {"title": "Is Active", "type": "boolean"},
-                    "items": {
-                        "title": "Items",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/Item"},
-                        "default": [],
-                    },
-                },
-            },
-            "UserCreate": {
-                "title": "UserCreate",
-                "required": ["email", "password"],
-                "type": "object",
-                "properties": {
-                    "email": {"title": "Email", "type": "string"},
-                    "password": {"title": "Password", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(scope="module", name="client")
 def get_client(tmp_path_factory: pytest.TempPathFactory):
@@ -305,13 +28,6 @@ def get_client(tmp_path_factory: pytest.TempPathFactory):
     os.chdir(cwd)
 
 
-@needs_py310
-def test_openapi_schema(client):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py310
 def test_create_user(client):
     test_user = {"email": "johndoe@example.com", "password": "secret"}
@@ -381,3 +97,303 @@ def test_read_items(client):
     first_item = data[0]
     assert "title" in first_item
     assert "description" in first_item
+
+
+@needs_py310
+def test_openapi_schema(client):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Users Users  Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/User"},
+                                    }
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                },
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create User",
+                    "operationId": "create_user_users__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/UserCreate"}
+                            }
+                        },
+                        "required": True,
+                    },
+                },
+            },
+            "/users/{user_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read User",
+                    "operationId": "read_user_users__user_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "User Id", "type": "integer"},
+                            "name": "user_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/users/{user_id}/items/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Item For User",
+                    "operationId": "create_item_for_user_users__user_id__items__post",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "User Id", "type": "integer"},
+                            "name": "user_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/ItemCreate"}
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Items Items  Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/Item"},
+                                    }
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "ItemCreate": {
+                    "title": "ItemCreate",
+                    "required": ["title"],
+                    "type": "object",
+                    "properties": {
+                        "title": {"title": "Title", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                    },
+                },
+                "Item": {
+                    "title": "Item",
+                    "required": ["title", "id", "owner_id"],
+                    "type": "object",
+                    "properties": {
+                        "title": {"title": "Title", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                        "id": {"title": "Id", "type": "integer"},
+                        "owner_id": {"title": "Owner Id", "type": "integer"},
+                    },
+                },
+                "User": {
+                    "title": "User",
+                    "required": ["email", "id", "is_active"],
+                    "type": "object",
+                    "properties": {
+                        "email": {"title": "Email", "type": "string"},
+                        "id": {"title": "Id", "type": "integer"},
+                        "is_active": {"title": "Is Active", "type": "boolean"},
+                        "items": {
+                            "title": "Items",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/Item"},
+                            "default": [],
+                        },
+                    },
+                },
+                "UserCreate": {
+                    "title": "UserCreate",
+                    "required": ["email", "password"],
+                    "type": "object",
+                    "properties": {
+                        "email": {"title": "Email", "type": "string"},
+                        "password": {"title": "Password", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index ebf55ed0152e0640169fe726c6b306d91156d941..f2eefe41d03a429f44b651f818b94fb0730f1516 100644 (file)
@@ -7,283 +7,6 @@ from fastapi.testclient import TestClient
 
 from ...utils import needs_py39
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Users Users  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/User"},
-                                }
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            },
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create User",
-                "operationId": "create_user_users__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/UserCreate"}
-                        }
-                    },
-                    "required": True,
-                },
-            },
-        },
-        "/users/{user_id}": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read User",
-                "operationId": "read_user_users__user_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "User Id", "type": "integer"},
-                        "name": "user_id",
-                        "in": "path",
-                    }
-                ],
-            }
-        },
-        "/users/{user_id}/items/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Create Item For User",
-                "operationId": "create_item_for_user_users__user_id__items__post",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "User Id", "type": "integer"},
-                        "name": "user_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/ItemCreate"}
-                        }
-                    },
-                    "required": True,
-                },
-            }
-        },
-        "/items/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Items Items  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/Item"},
-                                }
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-            }
-        },
-    },
-    "components": {
-        "schemas": {
-            "ItemCreate": {
-                "title": "ItemCreate",
-                "required": ["title"],
-                "type": "object",
-                "properties": {
-                    "title": {"title": "Title", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["title", "id", "owner_id"],
-                "type": "object",
-                "properties": {
-                    "title": {"title": "Title", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                    "id": {"title": "Id", "type": "integer"},
-                    "owner_id": {"title": "Owner Id", "type": "integer"},
-                },
-            },
-            "User": {
-                "title": "User",
-                "required": ["email", "id", "is_active"],
-                "type": "object",
-                "properties": {
-                    "email": {"title": "Email", "type": "string"},
-                    "id": {"title": "Id", "type": "integer"},
-                    "is_active": {"title": "Is Active", "type": "boolean"},
-                    "items": {
-                        "title": "Items",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/Item"},
-                        "default": [],
-                    },
-                },
-            },
-            "UserCreate": {
-                "title": "UserCreate",
-                "required": ["email", "password"],
-                "type": "object",
-                "properties": {
-                    "email": {"title": "Email", "type": "string"},
-                    "password": {"title": "Password", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(scope="module", name="client")
 def get_client(tmp_path_factory: pytest.TempPathFactory):
@@ -305,13 +28,6 @@ def get_client(tmp_path_factory: pytest.TempPathFactory):
     os.chdir(cwd)
 
 
-@needs_py39
-def test_openapi_schema(client):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 @needs_py39
 def test_create_user(client):
     test_user = {"email": "johndoe@example.com", "password": "secret"}
@@ -381,3 +97,303 @@ def test_read_items(client):
     first_item = data[0]
     assert "title" in first_item
     assert "description" in first_item
+
+
+@needs_py39
+def test_openapi_schema(client):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Users Users  Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/User"},
+                                    }
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                },
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create User",
+                    "operationId": "create_user_users__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/UserCreate"}
+                            }
+                        },
+                        "required": True,
+                    },
+                },
+            },
+            "/users/{user_id}": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read User",
+                    "operationId": "read_user_users__user_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "User Id", "type": "integer"},
+                            "name": "user_id",
+                            "in": "path",
+                        }
+                    ],
+                }
+            },
+            "/users/{user_id}/items/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Create Item For User",
+                    "operationId": "create_item_for_user_users__user_id__items__post",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "User Id", "type": "integer"},
+                            "name": "user_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/ItemCreate"}
+                            }
+                        },
+                        "required": True,
+                    },
+                }
+            },
+            "/items/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Items Items  Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/Item"},
+                                    }
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                }
+            },
+        },
+        "components": {
+            "schemas": {
+                "ItemCreate": {
+                    "title": "ItemCreate",
+                    "required": ["title"],
+                    "type": "object",
+                    "properties": {
+                        "title": {"title": "Title", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                    },
+                },
+                "Item": {
+                    "title": "Item",
+                    "required": ["title", "id", "owner_id"],
+                    "type": "object",
+                    "properties": {
+                        "title": {"title": "Title", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                        "id": {"title": "Id", "type": "integer"},
+                        "owner_id": {"title": "Owner Id", "type": "integer"},
+                    },
+                },
+                "User": {
+                    "title": "User",
+                    "required": ["email", "id", "is_active"],
+                    "type": "object",
+                    "properties": {
+                        "email": {"title": "Email", "type": "string"},
+                        "id": {"title": "Id", "type": "integer"},
+                        "is_active": {"title": "Is Active", "type": "boolean"},
+                        "items": {
+                            "title": "Items",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/Item"},
+                            "default": [],
+                        },
+                    },
+                },
+                "UserCreate": {
+                    "title": "UserCreate",
+                    "required": ["email", "password"],
+                    "type": "object",
+                    "properties": {
+                        "email": {"title": "Email", "type": "string"},
+                        "password": {"title": "Password", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+            }
+        },
+    }
index 1b4a7b302c39c963f893323b852babe5b6c2cf4a..d2470a2db9248a08a6bd62fe2710ca47912b5d63 100644 (file)
@@ -5,327 +5,6 @@ from unittest.mock import MagicMock
 import pytest
 from fastapi.testclient import TestClient
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/users/": {
-            "get": {
-                "summary": "Read Users",
-                "operationId": "read_users_users__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Users Users  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/User"},
-                                }
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            },
-            "post": {
-                "summary": "Create User",
-                "operationId": "create_user_users__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/UserCreate"}
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            },
-        },
-        "/users/{user_id}": {
-            "get": {
-                "summary": "Read User",
-                "operationId": "read_user_users__user_id__get",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "User Id", "type": "integer"},
-                        "name": "user_id",
-                        "in": "path",
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/User"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/users/{user_id}/items/": {
-            "post": {
-                "summary": "Create Item For User",
-                "operationId": "create_item_for_user_users__user_id__items__post",
-                "parameters": [
-                    {
-                        "required": True,
-                        "schema": {"title": "User Id", "type": "integer"},
-                        "name": "user_id",
-                        "in": "path",
-                    }
-                ],
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {"$ref": "#/components/schemas/ItemCreate"}
-                        }
-                    },
-                    "required": True,
-                },
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/Item"}
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/items/": {
-            "get": {
-                "summary": "Read Items",
-                "operationId": "read_items_items__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Items Items  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/Item"},
-                                }
-                            }
-                        },
-                    },
-                    "422": {
-                        "description": "Validation Error",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
-                                }
-                            }
-                        },
-                    },
-                },
-            }
-        },
-        "/slowusers/": {
-            "get": {
-                "summary": "Read Slow Users",
-                "operationId": "read_slow_users_slowusers__get",
-                "parameters": [
-                    {
-                        "required": False,
-                        "schema": {"title": "Skip", "type": "integer", "default": 0},
-                        "name": "skip",
-                        "in": "query",
-                    },
-                    {
-                        "required": False,
-                        "schema": {"title": "Limit", "type": "integer", "default": 100},
-                        "name": "limit",
-                        "in": "query",
-                    },
-                ],
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {
-                            "application/json": {
-                                "schema": {
-                                    "title": "Response Read Slow Users Slowusers  Get",
-                                    "type": "array",
-                                    "items": {"$ref": "#/components/schemas/User"},
-                                }
-                            }
-                        },
-                    },
-                    "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": {"$ref": "#/components/schemas/ValidationError"},
-                    }
-                },
-            },
-            "Item": {
-                "title": "Item",
-                "required": ["title", "id", "owner_id"],
-                "type": "object",
-                "properties": {
-                    "title": {"title": "Title", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                    "id": {"title": "Id", "type": "integer"},
-                    "owner_id": {"title": "Owner Id", "type": "integer"},
-                },
-            },
-            "ItemCreate": {
-                "title": "ItemCreate",
-                "required": ["title"],
-                "type": "object",
-                "properties": {
-                    "title": {"title": "Title", "type": "string"},
-                    "description": {"title": "Description", "type": "string"},
-                },
-            },
-            "User": {
-                "title": "User",
-                "required": ["email", "id", "is_active"],
-                "type": "object",
-                "properties": {
-                    "email": {"title": "Email", "type": "string"},
-                    "id": {"title": "Id", "type": "integer"},
-                    "is_active": {"title": "Is Active", "type": "boolean"},
-                    "items": {
-                        "title": "Items",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/Item"},
-                        "default": [],
-                    },
-                },
-            },
-            "UserCreate": {
-                "title": "UserCreate",
-                "required": ["email", "password"],
-                "type": "object",
-                "properties": {
-                    "email": {"title": "Email", "type": "string"},
-                    "password": {"title": "Password", "type": "string"},
-                },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
-                    },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
-                },
-            },
-        }
-    },
-}
-
 
 @pytest.fixture(scope="module")
 def client():
@@ -338,12 +17,6 @@ def client():
     test_db.unlink()
 
 
-def test_openapi_schema(client):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
 def test_create_user(client):
     test_user = {"email": "johndoe@example.com", "password": "secret"}
     response = client.post("/users/", json=test_user)
@@ -418,3 +91,354 @@ def test_read_items(client):
     first_item = data[0]
     assert "title" in first_item
     assert "description" in first_item
+
+
+def test_openapi_schema(client):
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/users/": {
+                "get": {
+                    "summary": "Read Users",
+                    "operationId": "read_users_users__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Users Users  Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/User"},
+                                    }
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                },
+                "post": {
+                    "summary": "Create User",
+                    "operationId": "create_user_users__post",
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/UserCreate"}
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                },
+            },
+            "/users/{user_id}": {
+                "get": {
+                    "summary": "Read User",
+                    "operationId": "read_user_users__user_id__get",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "User Id", "type": "integer"},
+                            "name": "user_id",
+                            "in": "path",
+                        }
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/User"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/users/{user_id}/items/": {
+                "post": {
+                    "summary": "Create Item For User",
+                    "operationId": "create_item_for_user_users__user_id__items__post",
+                    "parameters": [
+                        {
+                            "required": True,
+                            "schema": {"title": "User Id", "type": "integer"},
+                            "name": "user_id",
+                            "in": "path",
+                        }
+                    ],
+                    "requestBody": {
+                        "content": {
+                            "application/json": {
+                                "schema": {"$ref": "#/components/schemas/ItemCreate"}
+                            }
+                        },
+                        "required": True,
+                    },
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {"$ref": "#/components/schemas/Item"}
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/items/": {
+                "get": {
+                    "summary": "Read Items",
+                    "operationId": "read_items_items__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Items Items  Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/Item"},
+                                    }
+                                }
+                            },
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
+                    },
+                }
+            },
+            "/slowusers/": {
+                "get": {
+                    "summary": "Read Slow Users",
+                    "operationId": "read_slow_users_slowusers__get",
+                    "parameters": [
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Skip",
+                                "type": "integer",
+                                "default": 0,
+                            },
+                            "name": "skip",
+                            "in": "query",
+                        },
+                        {
+                            "required": False,
+                            "schema": {
+                                "title": "Limit",
+                                "type": "integer",
+                                "default": 100,
+                            },
+                            "name": "limit",
+                            "in": "query",
+                        },
+                    ],
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "title": "Response Read Slow Users Slowusers  Get",
+                                        "type": "array",
+                                        "items": {"$ref": "#/components/schemas/User"},
+                                    }
+                                }
+                            },
+                        },
+                        "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": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
+                },
+                "Item": {
+                    "title": "Item",
+                    "required": ["title", "id", "owner_id"],
+                    "type": "object",
+                    "properties": {
+                        "title": {"title": "Title", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                        "id": {"title": "Id", "type": "integer"},
+                        "owner_id": {"title": "Owner Id", "type": "integer"},
+                    },
+                },
+                "ItemCreate": {
+                    "title": "ItemCreate",
+                    "required": ["title"],
+                    "type": "object",
+                    "properties": {
+                        "title": {"title": "Title", "type": "string"},
+                        "description": {"title": "Description", "type": "string"},
+                    },
+                },
+                "User": {
+                    "title": "User",
+                    "required": ["email", "id", "is_active"],
+                    "type": "object",
+                    "properties": {
+                        "email": {"title": "Email", "type": "string"},
+                        "id": {"title": "Id", "type": "integer"},
+                        "is_active": {"title": "Is Active", "type": "boolean"},
+                        "items": {
+                            "title": "Items",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/Item"},
+                            "default": [],
+                        },
+                    },
+                },
+                "UserCreate": {
+                    "title": "UserCreate",
+                    "required": ["email", "password"],
+                    "type": "object",
+                    "properties": {
+                        "email": {"title": "Email", "type": "string"},
+                        "password": {"title": "Password", "type": "string"},
+                    },
+                },
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
+                    },
+                },
+            }
+        },
+    }
index e6747fffd0a1ba79bb1747cc133c47238ca451a3..937ce75e428150cff05ce3dadd2b5d2d2d9c73f9 100644 (file)
@@ -1,30 +1,28 @@
 from docs_src.app_testing.test_main import client, test_read_main
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Main",
-                "operationId": "read_main__get",
-            }
-        }
-    },
-}
+
+def test_main():
+    test_read_main()
 
 
 def test_openapi_schema():
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
-def test_main():
-    test_read_main()
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Main",
+                    "operationId": "read_main__get",
+                }
+            }
+        },
+    }
index 7dea477f0e1fd971400b25727e8940b7d821c933..f3db70af2baca4bae608557765ce5264c5a4991a 100644 (file)
@@ -1,30 +1,28 @@
 from docs_src.app_testing.tutorial001 import client, test_read_main
 
-openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/": {
-            "get": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
-                    }
-                },
-                "summary": "Read Main",
-                "operationId": "read_main__get",
-            }
-        }
-    },
-}
+
+def test_main():
+    test_read_main()
 
 
 def test_openapi_schema():
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == openapi_schema
-
-
-def test_main():
-    test_read_main()
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/": {
+                "get": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        }
+                    },
+                    "summary": "Read Main",
+                    "operationId": "read_main__get",
+                }
+            }
+        },
+    }
index 3e424de07d1c865d70caedda64b6f77290d52a79..bc1e744328aef51c4960bfb7e832f97179cd9ddf 100644 (file)
@@ -22,103 +22,103 @@ def save_union_body(item: Union[OtherItem, Item]):
 
 client = TestClient(app)
 
-item_openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
+
+def test_post_other_item():
+    response = client.post("/items/", json={"price": 100})
+    assert response.status_code == 200, response.text
+    assert response.json() == {"item": {"price": 100}}
+
+
+def test_post_item():
+    response = client.post("/items/", json={"name": "Foo"})
+    assert response.status_code == 200, response.text
+    assert response.json() == {"item": {"name": "Foo"}}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
                     },
-                    "422": {
-                        "description": "Validation Error",
+                    "summary": "Save Union Body",
+                    "operationId": "save_union_body_items__post",
+                    "requestBody": {
                         "content": {
                             "application/json": {
                                 "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                                    "title": "Item",
+                                    "anyOf": [
+                                        {"$ref": "#/components/schemas/OtherItem"},
+                                        {"$ref": "#/components/schemas/Item"},
+                                    ],
                                 }
                             }
                         },
+                        "required": True,
                     },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "OtherItem": {
+                    "title": "OtherItem",
+                    "required": ["price"],
+                    "type": "object",
+                    "properties": {"price": {"title": "Price", "type": "integer"}},
                 },
-                "summary": "Save Union Body",
-                "operationId": "save_union_body_items__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {
-                                "title": "Item",
-                                "anyOf": [
-                                    {"$ref": "#/components/schemas/OtherItem"},
-                                    {"$ref": "#/components/schemas/Item"},
-                                ],
-                            }
-                        }
-                    },
-                    "required": True,
+                "Item": {
+                    "title": "Item",
+                    "type": "object",
+                    "properties": {"name": {"title": "Name", "type": "string"}},
                 },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "OtherItem": {
-                "title": "OtherItem",
-                "required": ["price"],
-                "type": "object",
-                "properties": {"price": {"title": "Price", "type": "integer"}},
-            },
-            "Item": {
-                "title": "Item",
-                "type": "object",
-                "properties": {"name": {"title": "Name", "type": "string"}},
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
                     },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
                 },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
                 },
-            },
-        }
-    },
-}
-
-
-def test_item_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == item_openapi_schema
-
-
-def test_post_other_item():
-    response = client.post("/items/", json={"price": 100})
-    assert response.status_code == 200, response.text
-    assert response.json() == {"item": {"price": 100}}
-
-
-def test_post_item():
-    response = client.post("/items/", json={"name": "Foo"})
-    assert response.status_code == 200, response.text
-    assert response.json() == {"item": {"name": "Foo"}}
+            }
+        },
+    }
index 9ee981b24e9b99fc4ad8590508443b3fb7c68d5f..988b920aa77ad4c4de0c864b904a5ffe992a5573 100644 (file)
@@ -23,106 +23,105 @@ def save_union_different_body(item: Union[ExtendedItem, Item]):
 client = TestClient(app)
 
 
-inherited_item_openapi_schema = {
-    "openapi": "3.0.2",
-    "info": {"title": "FastAPI", "version": "0.1.0"},
-    "paths": {
-        "/items/": {
-            "post": {
-                "responses": {
-                    "200": {
-                        "description": "Successful Response",
-                        "content": {"application/json": {"schema": {}}},
+def test_post_extended_item():
+    response = client.post("/items/", json={"name": "Foo", "age": 5})
+    assert response.status_code == 200, response.text
+    assert response.json() == {"item": {"name": "Foo", "age": 5}}
+
+
+def test_post_item():
+    response = client.post("/items/", json={"name": "Foo"})
+    assert response.status_code == 200, response.text
+    assert response.json() == {"item": {"name": "Foo"}}
+
+
+def test_openapi_schema():
+    response = client.get("/openapi.json")
+    assert response.status_code == 200, response.text
+    assert response.json() == {
+        "openapi": "3.0.2",
+        "info": {"title": "FastAPI", "version": "0.1.0"},
+        "paths": {
+            "/items/": {
+                "post": {
+                    "responses": {
+                        "200": {
+                            "description": "Successful Response",
+                            "content": {"application/json": {"schema": {}}},
+                        },
+                        "422": {
+                            "description": "Validation Error",
+                            "content": {
+                                "application/json": {
+                                    "schema": {
+                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                    }
+                                }
+                            },
+                        },
                     },
-                    "422": {
-                        "description": "Validation Error",
+                    "summary": "Save Union Different Body",
+                    "operationId": "save_union_different_body_items__post",
+                    "requestBody": {
                         "content": {
                             "application/json": {
                                 "schema": {
-                                    "$ref": "#/components/schemas/HTTPValidationError"
+                                    "title": "Item",
+                                    "anyOf": [
+                                        {"$ref": "#/components/schemas/ExtendedItem"},
+                                        {"$ref": "#/components/schemas/Item"},
+                                    ],
                                 }
                             }
                         },
+                        "required": True,
                     },
+                }
+            }
+        },
+        "components": {
+            "schemas": {
+                "Item": {
+                    "title": "Item",
+                    "type": "object",
+                    "properties": {"name": {"title": "Name", "type": "string"}},
                 },
-                "summary": "Save Union Different Body",
-                "operationId": "save_union_different_body_items__post",
-                "requestBody": {
-                    "content": {
-                        "application/json": {
-                            "schema": {
-                                "title": "Item",
-                                "anyOf": [
-                                    {"$ref": "#/components/schemas/ExtendedItem"},
-                                    {"$ref": "#/components/schemas/Item"},
-                                ],
-                            }
-                        }
+                "ExtendedItem": {
+                    "title": "ExtendedItem",
+                    "required": ["age"],
+                    "type": "object",
+                    "properties": {
+                        "name": {"title": "Name", "type": "string"},
+                        "age": {"title": "Age", "type": "integer"},
                     },
-                    "required": True,
-                },
-            }
-        }
-    },
-    "components": {
-        "schemas": {
-            "Item": {
-                "title": "Item",
-                "type": "object",
-                "properties": {"name": {"title": "Name", "type": "string"}},
-            },
-            "ExtendedItem": {
-                "title": "ExtendedItem",
-                "required": ["age"],
-                "type": "object",
-                "properties": {
-                    "name": {"title": "Name", "type": "string"},
-                    "age": {"title": "Age", "type": "integer"},
                 },
-            },
-            "ValidationError": {
-                "title": "ValidationError",
-                "required": ["loc", "msg", "type"],
-                "type": "object",
-                "properties": {
-                    "loc": {
-                        "title": "Location",
-                        "type": "array",
-                        "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
+                "ValidationError": {
+                    "title": "ValidationError",
+                    "required": ["loc", "msg", "type"],
+                    "type": "object",
+                    "properties": {
+                        "loc": {
+                            "title": "Location",
+                            "type": "array",
+                            "items": {
+                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                            },
+                        },
+                        "msg": {"title": "Message", "type": "string"},
+                        "type": {"title": "Error Type", "type": "string"},
                     },
-                    "msg": {"title": "Message", "type": "string"},
-                    "type": {"title": "Error Type", "type": "string"},
                 },
-            },
-            "HTTPValidationError": {
-                "title": "HTTPValidationError",
-                "type": "object",
-                "properties": {
-                    "detail": {
-                        "title": "Detail",
-                        "type": "array",
-                        "items": {"$ref": "#/components/schemas/ValidationError"},
-                    }
+                "HTTPValidationError": {
+                    "title": "HTTPValidationError",
+                    "type": "object",
+                    "properties": {
+                        "detail": {
+                            "title": "Detail",
+                            "type": "array",
+                            "items": {"$ref": "#/components/schemas/ValidationError"},
+                        }
+                    },
                 },
-            },
-        }
-    },
-}
-
-
-def test_inherited_item_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == inherited_item_openapi_schema
-
-
-def test_post_extended_item():
-    response = client.post("/items/", json={"name": "Foo", "age": 5})
-    assert response.status_code == 200, response.text
-    assert response.json() == {"item": {"name": "Foo", "age": 5}}
-
-
-def test_post_item():
-    response = client.post("/items/", json={"name": "Foo"})
-    assert response.status_code == 200, response.text
-    assert response.json() == {"item": {"name": "Foo"}}
+            }
+        },
+    }