From a1bfbd3fc788f3f068473d70fe4faf4f21a58451 Mon Sep 17 00:00:00 2001 From: JONEMI19 Date: Sat, 8 Jul 2023 09:57:15 +0000 Subject: [PATCH] add new routes to api schema --- tests/test_application.py | 1748 +++++++++++++++++++------------------ 1 file changed, 900 insertions(+), 848 deletions(-) diff --git a/tests/test_application.py b/tests/test_application.py index 8fa84b074..ba2942196 100644 --- a/tests/test_application.py +++ b/tests/test_application.py @@ -1,4 +1,6 @@ import pytest +from deepdiff import DeepDiff +from dirty_equals import IsDict from fastapi.testclient import TestClient from .main import app @@ -60,172 +62,162 @@ def test_openapi_schema(): "paths": { "/api_route": { "get": { - "summary": "Non Operation", - "operationId": "non_operation_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": { - "summary": "Non Decorated Route", - "operationId": "non_decorated_route_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": { - "summary": "Get Text", - "operationId": "get_text_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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": {"title": "Item Id"}, + "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/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", - "required": True, - "schema": {"type": "string", "title": "Item Id"}, } ], - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - }, - }, - }, } }, "/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", - "required": True, - "schema": {"type": "integer", "title": "Item Id"}, } ], - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - }, - }, - }, } }, "/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", - "required": True, - "schema": {"type": "number", "title": "Item Id"}, } ], - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - }, - }, - }, } }, "/path/bool/{item_id}": { "get": { - "summary": "Get Bool Id", - "operationId": "get_bool_id_path_bool__item_id__get", - "parameters": [ - { - "name": "item_id", - "in": "path", - "required": True, - "schema": {"type": "boolean", "title": "Item Id"}, - } - ], "responses": { "200": { "description": "Successful Response", @@ -242,10 +234,36 @@ def test_openapi_schema(): }, }, }, + "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": [ @@ -253,685 +271,663 @@ def test_openapi_schema(): "name": "item_id", "in": "path", "required": True, - "schema": { - "anyOf": [{"type": "string"}, {"type": "null"}], - "title": "Item Id", - }, + "schema": IsDict( + { + "anyOf": [{"type": "string"}, {"type": "null"}], + "title": "Item Id", + } + ) + # TODO: remove when deprecating Pydantic v1 + | IsDict({"title": "Item Id", "type": "string"}), } ], - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - }, - }, - }, } }, "/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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": { - "type": "string", - "minLength": 3, "title": "Item Id", + "minLength": 3, + "type": "string", }, + "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/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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": { - "type": "string", - "maxLength": 3, "title": "Item Id", + "maxLength": 3, + "type": "string", }, + "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/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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": { - "type": "string", - "minLength": 2, - "maxLength": 3, "title": "Item Id", + "maxLength": 3, + "minLength": 2, + "type": "string", }, + "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/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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": { - "type": "number", - "exclusiveMinimum": 3, "title": "Item Id", + "exclusiveMinimum": 3.0, + "type": "number", }, + "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/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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": { - "type": "number", - "exclusiveMinimum": 0, "title": "Item Id", + "exclusiveMinimum": 0.0, + "type": "number", }, + "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/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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": { - "type": "number", - "minimum": 3, "title": "Item Id", + "minimum": 3.0, + "type": "number", }, + "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/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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": { - "type": "number", - "exclusiveMaximum": 3, "title": "Item Id", + "exclusiveMaximum": 3.0, + "type": "number", }, + "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/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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": { - "type": "number", - "exclusiveMaximum": 0, "title": "Item Id", + "exclusiveMaximum": 0.0, + "type": "number", }, + "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/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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": { - "type": "number", - "maximum": 3, "title": "Item Id", + "maximum": 3.0, + "type": "number", }, + "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/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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": { - "type": "number", - "exclusiveMaximum": 3, - "exclusiveMinimum": 1, "title": "Item Id", + "exclusiveMaximum": 3.0, + "exclusiveMinimum": 1.0, + "type": "number", }, + "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/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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": { - "type": "number", - "maximum": 3, - "minimum": 1, "title": "Item Id", + "maximum": 3.0, + "minimum": 1.0, + "type": "number", }, + "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/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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": { - "type": "integer", - "exclusiveMaximum": 3, "title": "Item Id", + "exclusiveMaximum": 3.0, + "type": "integer", }, + "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/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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": { - "type": "integer", - "exclusiveMinimum": 3, "title": "Item Id", + "exclusiveMinimum": 3.0, + "type": "integer", }, + "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/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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": { - "type": "integer", - "maximum": 3, "title": "Item Id", + "maximum": 3.0, + "type": "integer", }, + "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/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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": { - "type": "integer", - "minimum": 3, "title": "Item Id", + "minimum": 3.0, + "type": "integer", }, + "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/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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": { - "type": "integer", - "exclusiveMaximum": 3, - "exclusiveMinimum": 1, "title": "Item Id", + "exclusiveMaximum": 3.0, + "exclusiveMinimum": 1.0, + "type": "integer", }, + "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/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": [ { - "name": "item_id", - "in": "path", "required": True, "schema": { - "type": "integer", - "maximum": 3, - "minimum": 1, "title": "Item Id", + "maximum": 3.0, + "minimum": 1.0, + "type": "integer", }, + "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": { "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": [ { - "name": "query", - "in": "query", "required": True, "schema": {"title": "Query"}, + "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" - } - } - }, - }, - }, } }, "/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": [ { - "name": "query", - "in": "query", "required": False, "schema": {"title": "Query"}, + "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" - } - } - }, - }, - }, } }, "/query/int": { "get": { - "summary": "Get Query Type", - "operationId": "get_query_type_query_int_get", - "parameters": [ - { - "name": "query", - "in": "query", - "required": True, - "schema": {"type": "integer", "title": "Query"}, - } - ], "responses": { "200": { "description": "Successful Response", @@ -948,10 +944,36 @@ def test_openapi_schema(): }, }, }, + "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": [ @@ -959,395 +981,152 @@ def test_openapi_schema(): "name": "query", "in": "query", "required": False, - "schema": { - "anyOf": [{"type": "integer"}, {"type": "null"}], - "title": "Query", - }, + "schema": IsDict( + { + "anyOf": [{"type": "integer"}, {"type": "null"}], + "title": "Query", + } + ) + # TODO: remove when deprecating Pydantic v1 + | IsDict({"title": "Query", "type": "integer"}), } ], - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - }, - }, - }, } }, "/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": [ { - "name": "query", - "in": "query", "required": False, "schema": { + "title": "Query", "type": "integer", "default": 10, - "title": "Query", }, + "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" - } - } - }, - }, - }, } }, "/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": [ { - "name": "query", - "in": "query", "required": False, "schema": {"title": "Query"}, + "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" - } - } - }, - }, - }, } }, "/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" + } + } + }, + }, + }, "summary": "Get Query Param Required", "operationId": "get_query_param_required_query_param_required_get", "parameters": [ { - "name": "query", - "in": "query", "required": True, "schema": {"title": "Query"}, + "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" - } - } - }, - }, - }, } }, "/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 Type", "operationId": "get_query_param_required_type_query_param_required_int_get", "parameters": [ { + "required": True, + "schema": {"title": "Query", "type": "integer"}, "name": "query", "in": "query", - "required": True, - "schema": {"type": "integer", "title": "Query"}, } ], - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - }, - }, - }, - } - }, - "/query/sequence-params": { - "get": { - "summary": "Get Sequence Query Params", - "operationId": "get_sequence_query_params_query_sequence_params_get", - "parameters": [ - { - "name": "query", - "in": "query", - "required": False, - "schema": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": {"type": "integer"}, - }, - "default": {}, - "title": "Query", - }, - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - }, - }, - }, - } - }, - "/query/mapping-params": { - "get": { - "summary": "Get Mapping Query Params", - "operationId": "get_mapping_query_params_query_mapping_params_get", - "parameters": [ - { - "name": "queries", - "in": "query", - "required": False, - "schema": { - "type": "object", - "additionalProperties": {"type": "string"}, - "default": {}, - "title": "Queries", - }, - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - }, - }, - }, - } - }, - "/query/mapping-sequence-params": { - "get": { - "summary": "Get Sequence Mapping Query Params", - "operationId": "get_sequence_mapping_query_params_query_mapping_sequence_params_get", - "parameters": [ - { - "name": "queries", - "in": "query", - "required": False, - "schema": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": {"type": "integer"}, - }, - "default": {}, - "title": "Queries", - }, - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - }, - }, - }, - } - }, - "/query/mixed-params": { - "get": { - "summary": "Get Mixed Mapping Query Params", - "operationId": "get_mixed_mapping_query_params_query_mixed_params_get", - "parameters": [ - { - "name": "sequence_mapping_queries", - "in": "query", - "required": False, - "schema": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": {"type": "string"}, - }, - "default": {}, - "title": "Sequence Mapping Queries", - }, - }, - { - "name": "mapping_query", - "in": "query", - "required": True, - "schema": { - "type": "object", - "additionalProperties": {"type": "string"}, - "title": "Mapping Query", - }, - }, - { - "name": "query", - "in": "query", - "required": True, - "schema": {"type": "string", "title": "Query"}, - }, - ], - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - }, - }, - }, - } - }, - "/query/mixed-type-params": { - "get": { - "summary": "Get Mixed Mapping Mixed Type Query Params", - "operationId": "get_mixed_mapping_mixed_type_query_params_query_mixed_type_params_get", - "parameters": [ - { - "name": "sequence_mapping_queries", - "in": "query", - "required": False, - "schema": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": {"type": "integer"}, - }, - "default": {}, - "title": "Sequence Mapping Queries", - }, - }, - { - "name": "mapping_query_str", - "in": "query", - "required": False, - "schema": { - "type": "object", - "additionalProperties": {"type": "string"}, - "default": {}, - "title": "Mapping Query Str", - }, - }, - { - "name": "mapping_query_int", - "in": "query", - "required": False, - "schema": { - "type": "object", - "additionalProperties": {"type": "integer"}, - "default": {}, - "title": "Mapping Query Int", - }, - }, - { - "name": "query", - "in": "query", - "required": True, - "schema": {"type": "integer", "title": "Query"}, - }, - ], - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - }, - }, - }, } }, "/enum-status-code": { "get": { - "summary": "Get Enum Status Code", - "operationId": "get_enum_status_code_enum_status_code_get", "responses": { "201": { "description": "Successful Response", "content": {"application/json": {"schema": {}}}, - } + }, }, + "summary": "Get Enum Status Code", + "operationId": "get_enum_status_code_enum_status_code_get", } }, "/query/frozenset": { @@ -1356,15 +1135,15 @@ def test_openapi_schema(): "operationId": "get_query_type_frozenset_query_frozenset_get", "parameters": [ { - "name": "query", - "in": "query", "required": True, "schema": { - "type": "array", - "uniqueItems": True, - "items": {"type": "integer"}, "title": "Query", + "uniqueItems": True, + "type": "array", + "items": {"type": "integer"}, }, + "name": "query", + "in": "query", } ], "responses": { @@ -1385,35 +1164,308 @@ def test_openapi_schema(): }, } }, + "/query/sequence-params": { + "get": { + "summary": "Get Sequence Query Params", + "operationId": "get_sequence_query_params_query_sequence_params_get", + "parameters": [ + { + "required": False, + "schema": { + "additionalProperties": { + "items": { + "type": "integer" + }, + "type": "array" + }, + "type": "object", + "title": "Query", + "default": {} + }, + "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" + } + } + } + } + } + } + }, + "/query/mapping-params": { + "get": { + "summary": "Get Mapping Query Params", + "operationId": "get_mapping_query_params_query_mapping_params_get", + "parameters": [ + { + "required": False, + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "title": "Queries", + "default": {} + }, + "name": "queries", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": {} + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/query/mapping-sequence-params": { + "get": { + "summary": "Get Sequence Mapping Query Params", + "operationId": "get_sequence_mapping_query_params_query_mapping_sequence_params_get", + "parameters": [ + { + "required": False, + "schema": { + "additionalProperties": { + "items": { + "type": "integer" + }, + "type": "array" + }, + "type": "object", + "title": "Queries", + "default": {} + }, + "name": "queries", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": {} + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/query/mixed-params": { + "get": { + "summary": "Get Mixed Mapping Query Params", + "operationId": "get_mixed_mapping_query_params_query_mixed_params_get", + "parameters": [ + { + "required": False, + "schema": { + "additionalProperties": { + "items": { + "type": "string" + }, + "type": "array" + }, + "type": "object", + "title": "Sequence Mapping Queries", + "default": {} + }, + "name": "sequence_mapping_queries", + "in": "query" + }, + { + "required": True, + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "title": "Mapping Query" + }, + "name": "mapping_query", + "in": "query" + }, + { + "required": True, + "schema": { + "type": "string", + "title": "Query" + }, + "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" + } + } + } + } + } + } + }, + "/query/mixed-type-params": { + "get": { + "summary": "Get Mixed Mapping Mixed Type Query Params", + "operationId": "get_mixed_mapping_mixed_type_query_params_query_mixed_type_params_get", + "parameters": [ + { + "required": False, + "schema": { + "additionalProperties": { + "items": { + "type": "integer" + }, + "type": "array" + }, + "type": "object", + "title": "Sequence Mapping Queries", + "default": {} + }, + "name": "sequence_mapping_queries", + "in": "query" + }, + { + "required": False, + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "title": "Mapping Query Str", + "default": {} + }, + "name": "mapping_query_str", + "in": "query" + }, + { + "required": False, + "schema": { + "additionalProperties": { + "type": "integer" + }, + "type": "object", + "title": "Mapping Query Int", + "default": {} + }, + "name": "mapping_query_int", + "in": "query" + }, + { + "required": True, + "schema": { + "type": "integer", + "title": "Query" + }, + "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" + } + } + } + } + } + } + } }, "components": { "schemas": { - "HTTPValidationError": { - "properties": { - "detail": { - "items": {"$ref": "#/components/schemas/ValidationError"}, - "type": "array", - "title": "Detail", - } - }, - "type": "object", - "title": "HTTPValidationError", - }, "ValidationError": { + "title": "ValidationError", + "required": ["loc", "msg", "type"], + "type": "object", "properties": { "loc": { + "title": "Location", + "type": "array", "items": { "anyOf": [{"type": "string"}, {"type": "integer"}] }, - "type": "array", - "title": "Location", }, - "msg": {"type": "string", "title": "Message"}, - "type": {"type": "string", "title": "Error Type"}, + "msg": {"title": "Message", "type": "string"}, + "type": {"title": "Error Type", "type": "string"}, }, + }, + "HTTPValidationError": { + "title": "HTTPValidationError", "type": "object", - "required": ["loc", "msg", "type"], - "title": "ValidationError", + "properties": { + "detail": { + "title": "Detail", + "type": "array", + "items": {"$ref": "#/components/schemas/ValidationError"}, + } + }, }, } },