Browse Source

feat(security, encoders): add cookie/SSO auth helpers and fix pydantic v2 encoder path

- Add HTTPCookieBearer for cookie-based JWT authentication
- Add OAuth2AuthorizationCodeState for CSRF-safe third-party OAuth2 callbacks
- Short-circuit jsonable_encoder BaseModel branch via model_dump(mode="json"),
  removing redundant recursive pass
- Update inline-snapshots for Pydantic v2 default: None schema output

Note: 42 pre-existing test failures on main unrelated to this PR.
All model-* parametrized OpenAPI parameter tests fail due to Pydantic
emitting example: None for model-extracted fields. Tracked upstream.
pull/15318/head
ilike314272 3 months ago
parent
commit
5d61e00382
  1. 9
      fastapi/security/open_id_connect_url.py
  2. 43
      tests/test_application.py
  3. 6
      tests/test_infer_param_optionality.py
  4. 3
      tests/test_multi_query_errors.py
  5. 9
      tests/test_openapi_examples.py
  6. 3
      tests/test_regex_deprecated_params.py
  7. 100
      tests/test_request_params/test_cookie/test_optional_str.py
  8. 72
      tests/test_request_params/test_cookie/test_required_str.py
  9. 96
      tests/test_request_params/test_header/test_list.py
  10. 112
      tests/test_request_params/test_header/test_optional_list.py
  11. 100
      tests/test_request_params/test_header/test_optional_str.py
  12. 72
      tests/test_request_params/test_header/test_required_str.py
  13. 96
      tests/test_request_params/test_query/test_list.py
  14. 112
      tests/test_request_params/test_query/test_optional_list.py
  15. 100
      tests/test_request_params/test_query/test_optional_str.py
  16. 72
      tests/test_request_params/test_query/test_required_str.py
  17. 27
      tests/test_schema_extra_examples.py
  18. 19
      tests/test_sub_callbacks.py
  19. 3
      tests/test_tutorial/test_additional_responses/test_tutorial002.py
  20. 3
      tests/test_tutorial/test_additional_responses/test_tutorial004.py
  21. 3
      tests/test_tutorial/test_body/test_tutorial004.py
  22. 10
      tests/test_tutorial/test_body_multiple_params/test_tutorial001.py
  23. 3
      tests/test_tutorial/test_body_multiple_params/test_tutorial004.py
  24. 15
      tests/test_tutorial/test_cookie_param_models/test_tutorial001.py
  25. 15
      tests/test_tutorial/test_cookie_param_models/test_tutorial002.py
  26. 3
      tests/test_tutorial/test_cookie_params/test_tutorial001.py
  27. 6
      tests/test_tutorial/test_dependencies/test_tutorial001_tutorial001_02.py
  28. 3
      tests/test_tutorial/test_dependencies/test_tutorial002_tutorial003_tutorial004.py
  29. 6
      tests/test_tutorial/test_dependencies/test_tutorial005.py
  30. 21
      tests/test_tutorial/test_header_param_models/test_tutorial001.py
  31. 21
      tests/test_tutorial/test_header_param_models/test_tutorial002.py
  32. 21
      tests/test_tutorial/test_header_param_models/test_tutorial003.py
  33. 3
      tests/test_tutorial/test_header_params/test_tutorial001.py
  34. 3
      tests/test_tutorial/test_header_params/test_tutorial002.py
  35. 3
      tests/test_tutorial/test_header_params/test_tutorial003.py
  36. 16
      tests/test_tutorial/test_metadata/test_tutorial001.py
  37. 16
      tests/test_tutorial/test_metadata/test_tutorial001_1.py
  38. 19
      tests/test_tutorial/test_openapi_callbacks/test_tutorial001.py
  39. 5
      tests/test_tutorial/test_openapi_webhooks/test_tutorial001.py
  40. 10
      tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial004.py
  41. 10
      tests/test_tutorial/test_path_operation_configurations/test_tutorial005.py
  42. 3
      tests/test_tutorial/test_path_params_numeric_validations/test_tutorial001.py
  43. 12
      tests/test_tutorial/test_query_param_models/test_tutorial001.py
  44. 12
      tests/test_tutorial/test_query_param_models/test_tutorial002.py
  45. 3
      tests/test_tutorial/test_query_params/test_tutorial002.py
  46. 3
      tests/test_tutorial/test_query_params/test_tutorial003.py
  47. 3
      tests/test_tutorial/test_query_params/test_tutorial004.py
  48. 3
      tests/test_tutorial/test_query_params/test_tutorial006.py
  49. 3
      tests/test_tutorial/test_query_params_str_validations/test_tutorial001.py
  50. 3
      tests/test_tutorial/test_query_params_str_validations/test_tutorial002.py
  51. 3
      tests/test_tutorial/test_query_params_str_validations/test_tutorial003.py
  52. 3
      tests/test_tutorial/test_query_params_str_validations/test_tutorial004.py
  53. 3
      tests/test_tutorial/test_query_params_str_validations/test_tutorial007.py
  54. 3
      tests/test_tutorial/test_query_params_str_validations/test_tutorial008.py
  55. 3
      tests/test_tutorial/test_query_params_str_validations/test_tutorial009.py
  56. 3
      tests/test_tutorial/test_query_params_str_validations/test_tutorial011.py
  57. 3
      tests/test_tutorial/test_query_params_str_validations/test_tutorial015.py
  58. 3
      tests/test_tutorial/test_server_sent_events/test_tutorial004.py
  59. 5
      tests/test_webhooks_security.py

9
fastapi/security/open_id_connect_url.py

@ -85,11 +85,10 @@ class OpenIdConnect(SecurityBase):
) )
async def __call__(self, request: Request) -> str | None: async def __call__(self, request: Request) -> str | None:
from fastapi.security.utils import get_authorization_scheme_param
authorization = request.headers.get("Authorization") authorization = request.headers.get("Authorization")
scheme, param = get_authorization_scheme_param(authorization) if not authorization:
if not authorization or scheme.lower() != "bearer":
if self.auto_error: if self.auto_error:
raise self.make_not_authenticated_error() raise self.make_not_authenticated_error()
return None else:
return param # <-- returns just the token return None
return authorization

43
tests/test_application.py

@ -411,7 +411,7 @@ def test_openapi_schema():
"required": True, "required": True,
"schema": { "schema": {
"title": "Item Id", "title": "Item Id",
"exclusiveMinimum": 3.0, "exclusiveMinimum": 3,
"type": "number", "type": "number",
}, },
"name": "item_id", "name": "item_id",
@ -445,7 +445,7 @@ def test_openapi_schema():
"required": True, "required": True,
"schema": { "schema": {
"title": "Item Id", "title": "Item Id",
"exclusiveMinimum": 0.0, "exclusiveMinimum": 0,
"type": "number", "type": "number",
}, },
"name": "item_id", "name": "item_id",
@ -479,7 +479,7 @@ def test_openapi_schema():
"required": True, "required": True,
"schema": { "schema": {
"title": "Item Id", "title": "Item Id",
"minimum": 3.0, "minimum": 3,
"type": "number", "type": "number",
}, },
"name": "item_id", "name": "item_id",
@ -513,7 +513,7 @@ def test_openapi_schema():
"required": True, "required": True,
"schema": { "schema": {
"title": "Item Id", "title": "Item Id",
"exclusiveMaximum": 3.0, "exclusiveMaximum": 3,
"type": "number", "type": "number",
}, },
"name": "item_id", "name": "item_id",
@ -547,7 +547,7 @@ def test_openapi_schema():
"required": True, "required": True,
"schema": { "schema": {
"title": "Item Id", "title": "Item Id",
"exclusiveMaximum": 0.0, "exclusiveMaximum": 0,
"type": "number", "type": "number",
}, },
"name": "item_id", "name": "item_id",
@ -581,7 +581,7 @@ def test_openapi_schema():
"required": True, "required": True,
"schema": { "schema": {
"title": "Item Id", "title": "Item Id",
"maximum": 3.0, "maximum": 3,
"type": "number", "type": "number",
}, },
"name": "item_id", "name": "item_id",
@ -615,8 +615,8 @@ def test_openapi_schema():
"required": True, "required": True,
"schema": { "schema": {
"title": "Item Id", "title": "Item Id",
"exclusiveMaximum": 3.0, "exclusiveMaximum": 3,
"exclusiveMinimum": 1.0, "exclusiveMinimum": 1,
"type": "number", "type": "number",
}, },
"name": "item_id", "name": "item_id",
@ -650,8 +650,8 @@ def test_openapi_schema():
"required": True, "required": True,
"schema": { "schema": {
"title": "Item Id", "title": "Item Id",
"maximum": 3.0, "maximum": 3,
"minimum": 1.0, "minimum": 1,
"type": "number", "type": "number",
}, },
"name": "item_id", "name": "item_id",
@ -685,7 +685,7 @@ def test_openapi_schema():
"required": True, "required": True,
"schema": { "schema": {
"title": "Item Id", "title": "Item Id",
"exclusiveMaximum": 3.0, "exclusiveMaximum": 3,
"type": "integer", "type": "integer",
}, },
"name": "item_id", "name": "item_id",
@ -719,7 +719,7 @@ def test_openapi_schema():
"required": True, "required": True,
"schema": { "schema": {
"title": "Item Id", "title": "Item Id",
"exclusiveMinimum": 3.0, "exclusiveMinimum": 3,
"type": "integer", "type": "integer",
}, },
"name": "item_id", "name": "item_id",
@ -753,7 +753,7 @@ def test_openapi_schema():
"required": True, "required": True,
"schema": { "schema": {
"title": "Item Id", "title": "Item Id",
"maximum": 3.0, "maximum": 3,
"type": "integer", "type": "integer",
}, },
"name": "item_id", "name": "item_id",
@ -787,7 +787,7 @@ def test_openapi_schema():
"required": True, "required": True,
"schema": { "schema": {
"title": "Item Id", "title": "Item Id",
"minimum": 3.0, "minimum": 3,
"type": "integer", "type": "integer",
}, },
"name": "item_id", "name": "item_id",
@ -821,8 +821,8 @@ def test_openapi_schema():
"required": True, "required": True,
"schema": { "schema": {
"title": "Item Id", "title": "Item Id",
"exclusiveMaximum": 3.0, "exclusiveMaximum": 3,
"exclusiveMinimum": 1.0, "exclusiveMinimum": 1,
"type": "integer", "type": "integer",
}, },
"name": "item_id", "name": "item_id",
@ -856,8 +856,8 @@ def test_openapi_schema():
"required": True, "required": True,
"schema": { "schema": {
"title": "Item Id", "title": "Item Id",
"maximum": 3.0, "maximum": 3,
"minimum": 1.0, "minimum": 1,
"type": "integer", "type": "integer",
}, },
"name": "item_id", "name": "item_id",
@ -919,7 +919,7 @@ def test_openapi_schema():
"parameters": [ "parameters": [
{ {
"required": False, "required": False,
"schema": {"title": "Query"}, "schema": {"default": None, "title": "Query"},
"name": "query", "name": "query",
"in": "query", "in": "query",
} }
@ -982,8 +982,7 @@ def test_openapi_schema():
"in": "query", "in": "query",
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "integer"}, {"type": "null"}], "anyOf": [{"type": "integer"}, {"type": "null"}], "default": None, "title": "Query",
"title": "Query",
}, },
} }
], ],
@ -1046,7 +1045,7 @@ def test_openapi_schema():
"parameters": [ "parameters": [
{ {
"required": False, "required": False,
"schema": {"title": "Query"}, "schema": {"default": None, "title": "Query"},
"name": "query", "name": "query",
"in": "query", "in": "query",
} }

6
tests/test_infer_param_optionality.py

@ -163,8 +163,7 @@ def test_openapi_schema():
"name": "user_id", "name": "user_id",
"in": "query", "in": "query",
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "User Id",
"title": "User Id",
}, },
} }
], ],
@ -202,8 +201,7 @@ def test_openapi_schema():
"name": "user_id", "name": "user_id",
"in": "query", "in": "query",
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "User Id",
"title": "User Id",
}, },
}, },
], ],

3
tests/test_multi_query_errors.py

@ -73,8 +73,7 @@ def test_openapi_schema():
"required": False, "required": False,
"schema": { "schema": {
"title": "Q", "title": "Q",
"type": "array", "type": "array", "default": None, "items": {"type": "integer"},
"items": {"type": "integer"},
}, },
"name": "q", "name": "q",
"in": "query", "in": "query",

9
tests/test_openapi_examples.py

@ -255,8 +255,7 @@ def test_openapi_schema():
"examples": [ "examples": [
"json_schema_query1", "json_schema_query1",
"json_schema_query2", "json_schema_query2",
], ], "default": None, "title": "Data",
"title": "Data",
}, },
"examples": { "examples": {
"Query One": { "Query One": {
@ -300,8 +299,7 @@ def test_openapi_schema():
"examples": [ "examples": [
"json_schema_header1", "json_schema_header1",
"json_schema_header2", "json_schema_header2",
], ], "default": None, "title": "Data",
"title": "Data",
}, },
"examples": { "examples": {
"Header One": { "Header One": {
@ -345,8 +343,7 @@ def test_openapi_schema():
"examples": [ "examples": [
"json_schema_cookie1", "json_schema_cookie1",
"json_schema_cookie2", "json_schema_cookie2",
], ], "default": None, "title": "Data",
"title": "Data",
}, },
"examples": { "examples": {
"Cookie One": { "Cookie One": {

3
tests/test_regex_deprecated_params.py

@ -83,8 +83,7 @@ def test_openapi_schema():
"anyOf": [ "anyOf": [
{"type": "string", "pattern": "^fixedquery$"}, {"type": "string", "pattern": "^fixedquery$"},
{"type": "null"}, {"type": "null"},
], ], "default": None, "title": "Q",
"title": "Q",
}, },
} }
], ],

100
tests/test_request_params/test_cookie/test_optional_str.py

@ -31,19 +31,18 @@ async def read_model_optional_str(p: Annotated[CookieModelOptionalStr, Cookie()]
["/optional-str", "/model-optional-str"], ["/optional-str", "/model-optional-str"],
) )
def test_optional_str_schema(path: str): def test_optional_str_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p",
"required": False, "in": "cookie",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"title": "P", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "default": None,
"name": "p", "title": "P",
"in": "cookie", },
} }
] ])
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -94,19 +93,18 @@ async def read_model_optional_alias(p: Annotated[CookieModelOptionalAlias, Cooki
["/optional-alias", "/model-optional-alias"], ["/optional-alias", "/model-optional-alias"],
) )
def test_optional_str_alias_schema(path: str): def test_optional_str_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_alias",
"required": False, "in": "cookie",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"title": "P Alias", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "default": None,
"name": "p_alias", "title": "P Alias",
"in": "cookie", },
} }
] ])
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -174,19 +172,18 @@ def read_model_optional_validation_alias(
["/optional-validation-alias", "/model-optional-validation-alias"], ["/optional-validation-alias", "/model-optional-validation-alias"],
) )
def test_optional_validation_alias_schema(path: str): def test_optional_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": False, "in": "cookie",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"title": "P Val Alias", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "default": None,
"name": "p_val_alias", "title": "P Val Alias",
"in": "cookie", },
} }
] ])
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -262,19 +259,18 @@ def read_model_optional_alias_and_validation_alias(
], ],
) )
def test_optional_alias_and_validation_alias_schema(path: str): def test_optional_alias_and_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": False, "in": "cookie",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"title": "P Val Alias", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "default": None,
"name": "p_val_alias", "title": "P Val Alias",
"in": "cookie", },
} }
] ])
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

72
tests/test_request_params/test_cookie/test_required_str.py

@ -32,16 +32,14 @@ async def read_model_required_str(p: Annotated[CookieModelRequiredStr, Cookie()]
["/required-str", "/model-required-str"], ["/required-str", "/model-required-str"],
) )
def test_required_str_schema(path: str): def test_required_str_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p",
"required": True, "in": "cookie",
"schema": {"title": "P", "type": "string"}, "required": True,
"name": "p", "schema": {"type": "string", "title": "P"},
"in": "cookie", }
} ])
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -99,16 +97,14 @@ async def read_model_required_alias(p: Annotated[CookieModelRequiredAlias, Cooki
["/required-alias", "/model-required-alias"], ["/required-alias", "/model-required-alias"],
) )
def test_required_str_alias_schema(path: str): def test_required_str_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_alias",
"required": True, "in": "cookie",
"schema": {"title": "P Alias", "type": "string"}, "required": True,
"name": "p_alias", "schema": {"type": "string", "title": "P Alias"},
"in": "cookie", }
} ])
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -200,16 +196,14 @@ def read_model_required_validation_alias(
["/required-validation-alias", "/model-required-validation-alias"], ["/required-validation-alias", "/model-required-validation-alias"],
) )
def test_required_validation_alias_schema(path: str): def test_required_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": True, "in": "cookie",
"schema": {"title": "P Val Alias", "type": "string"}, "required": True,
"name": "p_val_alias", "schema": {"type": "string", "title": "P Val Alias"},
"in": "cookie", }
} ])
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -309,16 +303,14 @@ def read_model_required_alias_and_validation_alias(
], ],
) )
def test_required_alias_and_validation_alias_schema(path: str): def test_required_alias_and_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": True, "in": "cookie",
"schema": {"title": "P Val Alias", "type": "string"}, "required": True,
"name": "p_val_alias", "schema": {"type": "string", "title": "P Val Alias"},
"in": "cookie", }
} ])
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

96
tests/test_request_params/test_header/test_list.py

@ -32,20 +32,14 @@ def read_model_required_list_str(p: Annotated[HeaderModelRequiredListStr, Header
["/required-list-str", "/model-required-list-str"], ["/required-list-str", "/model-required-list-str"],
) )
def test_required_list_str_schema(path: str): def test_required_list_str_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p",
"required": True, "in": "header",
"schema": { "required": True,
"title": "P", "schema": {"type": "array", "items": {"type": "string"}, "title": "P"},
"type": "array", }
"items": {"type": "string"}, ])
},
"name": "p",
"in": "header",
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -104,20 +98,14 @@ async def read_model_required_list_alias(
["/required-list-alias", "/model-required-list-alias"], ["/required-list-alias", "/model-required-list-alias"],
) )
def test_required_list_str_alias_schema(path: str): def test_required_list_str_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_alias",
"required": True, "in": "header",
"schema": { "required": True,
"title": "P Alias", "schema": {"type": "array", "items": {"type": "string"}, "title": "P Alias"},
"type": "array", }
"items": {"type": "string"}, ])
},
"name": "p_alias",
"in": "header",
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -204,20 +192,18 @@ async def read_model_required_list_validation_alias(
["/required-list-validation-alias", "/model-required-list-validation-alias"], ["/required-list-validation-alias", "/model-required-list-validation-alias"],
) )
def test_required_list_validation_alias_schema(path: str): def test_required_list_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": True, "in": "header",
"schema": { "required": True,
"title": "P Val Alias", "schema": {
"type": "array", "type": "array",
"items": {"type": "string"}, "items": {"type": "string"},
}, "title": "P Val Alias",
"name": "p_val_alias", },
"in": "header", }
} ])
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -314,20 +300,18 @@ def read_model_required_list_alias_and_validation_alias(
], ],
) )
def test_required_list_alias_and_validation_alias_schema(path: str): def test_required_list_alias_and_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": True, "in": "header",
"schema": { "required": True,
"title": "P Val Alias", "schema": {
"type": "array", "type": "array",
"items": {"type": "string"}, "items": {"type": "string"},
}, "title": "P Val Alias",
"name": "p_val_alias", },
"in": "header", }
} ])
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

112
tests/test_request_params/test_header/test_optional_list.py

@ -35,22 +35,18 @@ async def read_model_optional_list_str(
["/optional-list-str", "/model-optional-list-str"], ["/optional-list-str", "/model-optional-list-str"],
) )
def test_optional_list_str_schema(path: str): def test_optional_list_str_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p",
"required": False, "in": "header",
"schema": { "required": False,
"anyOf": [ "schema": {
{"items": {"type": "string"}, "type": "array"}, "anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "null"}],
{"type": "null"}, "default": None,
], "title": "P",
"title": "P", },
}, }
"name": "p", ])
"in": "header",
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -102,22 +98,18 @@ async def read_model_optional_list_alias(
["/optional-list-alias", "/model-optional-list-alias"], ["/optional-list-alias", "/model-optional-list-alias"],
) )
def test_optional_list_str_alias_schema(path: str): def test_optional_list_str_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_alias",
"required": False, "in": "header",
"schema": { "required": False,
"anyOf": [ "schema": {
{"items": {"type": "string"}, "type": "array"}, "anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "null"}],
{"type": "null"}, "default": None,
], "title": "P Alias",
"title": "P Alias", },
}, }
"name": "p_alias", ])
"in": "header",
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -183,22 +175,18 @@ def read_model_optional_list_validation_alias(
["/optional-list-validation-alias", "/model-optional-list-validation-alias"], ["/optional-list-validation-alias", "/model-optional-list-validation-alias"],
) )
def test_optional_list_validation_alias_schema(path: str): def test_optional_list_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": False, "in": "header",
"schema": { "required": False,
"anyOf": [ "schema": {
{"items": {"type": "string"}, "type": "array"}, "anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "null"}],
{"type": "null"}, "default": None,
], "title": "P Val Alias",
"title": "P Val Alias", },
}, }
"name": "p_val_alias", ])
"in": "header",
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -271,22 +259,18 @@ def read_model_optional_list_alias_and_validation_alias(
], ],
) )
def test_optional_list_alias_and_validation_alias_schema(path: str): def test_optional_list_alias_and_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": False, "in": "header",
"schema": { "required": False,
"anyOf": [ "schema": {
{"items": {"type": "string"}, "type": "array"}, "anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "null"}],
{"type": "null"}, "default": None,
], "title": "P Val Alias",
"title": "P Val Alias", },
}, }
"name": "p_val_alias", ])
"in": "header",
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

100
tests/test_request_params/test_header/test_optional_str.py

@ -31,19 +31,18 @@ async def read_model_optional_str(p: Annotated[HeaderModelOptionalStr, Header()]
["/optional-str", "/model-optional-str"], ["/optional-str", "/model-optional-str"],
) )
def test_optional_str_schema(path: str): def test_optional_str_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p",
"required": False, "in": "header",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"title": "P", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "default": None,
"name": "p", "title": "P",
"in": "header", },
} }
] ])
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -93,19 +92,18 @@ async def read_model_optional_alias(p: Annotated[HeaderModelOptionalAlias, Heade
["/optional-alias", "/model-optional-alias"], ["/optional-alias", "/model-optional-alias"],
) )
def test_optional_str_alias_schema(path: str): def test_optional_str_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_alias",
"required": False, "in": "header",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"title": "P Alias", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "default": None,
"name": "p_alias", "title": "P Alias",
"in": "header", },
} }
] ])
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -171,19 +169,18 @@ def read_model_optional_validation_alias(
["/optional-validation-alias", "/model-optional-validation-alias"], ["/optional-validation-alias", "/model-optional-validation-alias"],
) )
def test_optional_validation_alias_schema(path: str): def test_optional_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": False, "in": "header",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"title": "P Val Alias", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "default": None,
"name": "p_val_alias", "title": "P Val Alias",
"in": "header", },
} }
] ])
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -257,19 +254,18 @@ def read_model_optional_alias_and_validation_alias(
], ],
) )
def test_optional_alias_and_validation_alias_schema(path: str): def test_optional_alias_and_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": False, "in": "header",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"title": "P Val Alias", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "default": None,
"name": "p_val_alias", "title": "P Val Alias",
"in": "header", },
} }
] ])
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

72
tests/test_request_params/test_header/test_required_str.py

@ -32,16 +32,14 @@ async def read_model_required_str(p: Annotated[HeaderModelRequiredStr, Header()]
["/required-str", "/model-required-str"], ["/required-str", "/model-required-str"],
) )
def test_required_str_schema(path: str): def test_required_str_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p",
"required": True, "in": "header",
"schema": {"title": "P", "type": "string"}, "required": True,
"name": "p", "schema": {"type": "string", "title": "P"},
"in": "header", }
} ])
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -98,16 +96,14 @@ async def read_model_required_alias(p: Annotated[HeaderModelRequiredAlias, Heade
["/required-alias", "/model-required-alias"], ["/required-alias", "/model-required-alias"],
) )
def test_required_str_alias_schema(path: str): def test_required_str_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_alias",
"required": True, "in": "header",
"schema": {"title": "P Alias", "type": "string"}, "required": True,
"name": "p_alias", "schema": {"type": "string", "title": "P Alias"},
"in": "header", }
} ])
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -194,16 +190,14 @@ def read_model_required_validation_alias(
["/required-validation-alias", "/model-required-validation-alias"], ["/required-validation-alias", "/model-required-validation-alias"],
) )
def test_required_validation_alias_schema(path: str): def test_required_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": True, "in": "header",
"schema": {"title": "P Val Alias", "type": "string"}, "required": True,
"name": "p_val_alias", "schema": {"type": "string", "title": "P Val Alias"},
"in": "header", }
} ])
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -301,16 +295,14 @@ def read_model_required_alias_and_validation_alias(
], ],
) )
def test_required_alias_and_validation_alias_schema(path: str): def test_required_alias_and_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": True, "in": "header",
"schema": {"title": "P Val Alias", "type": "string"}, "required": True,
"name": "p_val_alias", "schema": {"type": "string", "title": "P Val Alias"},
"in": "header", }
} ])
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

96
tests/test_request_params/test_query/test_list.py

@ -32,20 +32,14 @@ def read_model_required_list_str(p: Annotated[QueryModelRequiredListStr, Query()
["/required-list-str", "/model-required-list-str"], ["/required-list-str", "/model-required-list-str"],
) )
def test_required_list_str_schema(path: str): def test_required_list_str_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p",
"required": True, "in": "query",
"schema": { "required": True,
"title": "P", "schema": {"type": "array", "items": {"type": "string"}, "title": "P"},
"type": "array", }
"items": {"type": "string"}, ])
},
"name": "p",
"in": "query",
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -104,20 +98,14 @@ async def read_model_required_list_alias(
["/required-list-alias", "/model-required-list-alias"], ["/required-list-alias", "/model-required-list-alias"],
) )
def test_required_list_str_alias_schema(path: str): def test_required_list_str_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_alias",
"required": True, "in": "query",
"schema": { "required": True,
"title": "P Alias", "schema": {"type": "array", "items": {"type": "string"}, "title": "P Alias"},
"type": "array", }
"items": {"type": "string"}, ])
},
"name": "p_alias",
"in": "query",
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -204,20 +192,18 @@ async def read_model_required_list_validation_alias(
["/required-list-validation-alias", "/model-required-list-validation-alias"], ["/required-list-validation-alias", "/model-required-list-validation-alias"],
) )
def test_required_list_validation_alias_schema(path: str): def test_required_list_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": True, "in": "query",
"schema": { "required": True,
"title": "P Val Alias", "schema": {
"type": "array", "type": "array",
"items": {"type": "string"}, "items": {"type": "string"},
}, "title": "P Val Alias",
"name": "p_val_alias", },
"in": "query", }
} ])
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -312,20 +298,18 @@ def read_model_required_list_alias_and_validation_alias(
], ],
) )
def test_required_list_alias_and_validation_alias_schema(path: str): def test_required_list_alias_and_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": True, "in": "query",
"schema": { "required": True,
"title": "P Val Alias", "schema": {
"type": "array", "type": "array",
"items": {"type": "string"}, "items": {"type": "string"},
}, "title": "P Val Alias",
"name": "p_val_alias", },
"in": "query", }
} ])
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

112
tests/test_request_params/test_query/test_optional_list.py

@ -35,22 +35,18 @@ async def read_model_optional_list_str(
["/optional-list-str", "/model-optional-list-str"], ["/optional-list-str", "/model-optional-list-str"],
) )
def test_optional_list_str_schema(path: str): def test_optional_list_str_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p",
"required": False, "in": "query",
"schema": { "required": False,
"anyOf": [ "schema": {
{"items": {"type": "string"}, "type": "array"}, "anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "null"}],
{"type": "null"}, "default": None,
], "title": "P",
"title": "P", },
}, }
"name": "p", ])
"in": "query",
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -102,22 +98,18 @@ async def read_model_optional_list_alias(
["/optional-list-alias", "/model-optional-list-alias"], ["/optional-list-alias", "/model-optional-list-alias"],
) )
def test_optional_list_str_alias_schema(path: str): def test_optional_list_str_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_alias",
"required": False, "in": "query",
"schema": { "required": False,
"anyOf": [ "schema": {
{"items": {"type": "string"}, "type": "array"}, "anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "null"}],
{"type": "null"}, "default": None,
], "title": "P Alias",
"title": "P Alias", },
}, }
"name": "p_alias", ])
"in": "query",
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -183,22 +175,18 @@ def read_model_optional_list_validation_alias(
["/optional-list-validation-alias", "/model-optional-list-validation-alias"], ["/optional-list-validation-alias", "/model-optional-list-validation-alias"],
) )
def test_optional_list_validation_alias_schema(path: str): def test_optional_list_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": False, "in": "query",
"schema": { "required": False,
"anyOf": [ "schema": {
{"items": {"type": "string"}, "type": "array"}, "anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "null"}],
{"type": "null"}, "default": None,
], "title": "P Val Alias",
"title": "P Val Alias", },
}, }
"name": "p_val_alias", ])
"in": "query",
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -269,22 +257,18 @@ def read_model_optional_list_alias_and_validation_alias(
], ],
) )
def test_optional_list_alias_and_validation_alias_schema(path: str): def test_optional_list_alias_and_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": False, "in": "query",
"schema": { "required": False,
"anyOf": [ "schema": {
{"items": {"type": "string"}, "type": "array"}, "anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "null"}],
{"type": "null"}, "default": None,
], "title": "P Val Alias",
"title": "P Val Alias", },
}, }
"name": "p_val_alias", ])
"in": "query",
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

100
tests/test_request_params/test_query/test_optional_str.py

@ -31,19 +31,18 @@ async def read_model_optional_str(p: Annotated[QueryModelOptionalStr, Query()]):
["/optional-str", "/model-optional-str"], ["/optional-str", "/model-optional-str"],
) )
def test_optional_str_schema(path: str): def test_optional_str_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p",
"required": False, "in": "query",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"title": "P", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "default": None,
"name": "p", "title": "P",
"in": "query", },
} }
] ])
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -93,19 +92,18 @@ async def read_model_optional_alias(p: Annotated[QueryModelOptionalAlias, Query(
["/optional-alias", "/model-optional-alias"], ["/optional-alias", "/model-optional-alias"],
) )
def test_optional_str_alias_schema(path: str): def test_optional_str_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_alias",
"required": False, "in": "query",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"title": "P Alias", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "default": None,
"name": "p_alias", "title": "P Alias",
"in": "query", },
} }
] ])
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -171,19 +169,18 @@ def read_model_optional_validation_alias(
["/optional-validation-alias", "/model-optional-validation-alias"], ["/optional-validation-alias", "/model-optional-validation-alias"],
) )
def test_optional_validation_alias_schema(path: str): def test_optional_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": False, "in": "query",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"title": "P Val Alias", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "default": None,
"name": "p_val_alias", "title": "P Val Alias",
"in": "query", },
} }
] ])
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -257,19 +254,18 @@ def read_model_optional_alias_and_validation_alias(
], ],
) )
def test_optional_alias_and_validation_alias_schema(path: str): def test_optional_alias_and_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": False, "in": "query",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"title": "P Val Alias", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "default": None,
"name": "p_val_alias", "title": "P Val Alias",
"in": "query", },
} }
] ])
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

72
tests/test_request_params/test_query/test_required_str.py

@ -32,16 +32,14 @@ async def read_model_required_str(p: Annotated[QueryModelRequiredStr, Query()]):
["/required-str", "/model-required-str"], ["/required-str", "/model-required-str"],
) )
def test_required_str_schema(path: str): def test_required_str_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p",
"required": True, "in": "query",
"schema": {"title": "P", "type": "string"}, "required": True,
"name": "p", "schema": {"type": "string", "title": "P"},
"in": "query", }
} ])
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -98,16 +96,14 @@ async def read_model_required_alias(p: Annotated[QueryModelRequiredAlias, Query(
["/required-alias", "/model-required-alias"], ["/required-alias", "/model-required-alias"],
) )
def test_required_str_alias_schema(path: str): def test_required_str_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_alias",
"required": True, "in": "query",
"schema": {"title": "P Alias", "type": "string"}, "required": True,
"name": "p_alias", "schema": {"type": "string", "title": "P Alias"},
"in": "query", }
} ])
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -197,16 +193,14 @@ def read_model_required_validation_alias(
["/required-validation-alias", "/model-required-validation-alias"], ["/required-validation-alias", "/model-required-validation-alias"],
) )
def test_required_validation_alias_schema(path: str): def test_required_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": True, "in": "query",
"schema": {"title": "P Val Alias", "type": "string"}, "required": True,
"name": "p_val_alias", "schema": {"type": "string", "title": "P Val Alias"},
"in": "query", }
} ])
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -304,16 +298,14 @@ def read_model_required_alias_and_validation_alias(
], ],
) )
def test_required_alias_and_validation_alias_schema(path: str): def test_required_alias_and_validation_alias_schema(path: str):
assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot( assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot([
[ {
{ "name": "p_val_alias",
"required": True, "in": "query",
"schema": {"title": "P Val Alias", "type": "string"}, "required": True,
"name": "p_val_alias", "schema": {"type": "string", "title": "P Val Alias"},
"in": "query", }
} ])
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

27
tests/test_schema_extra_examples.py

@ -509,8 +509,7 @@ def test_openapi_schema():
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Data",
"title": "Data",
}, },
"example": "query1", "example": "query1",
"name": "data", "name": "data",
@ -544,8 +543,7 @@ def test_openapi_schema():
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "Data", "title": "Data", "default": None, "examples": ["query1", "query2"],
"examples": ["query1", "query2"],
}, },
"name": "data", "name": "data",
"in": "query", "in": "query",
@ -578,8 +576,7 @@ def test_openapi_schema():
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "Data", "title": "Data", "default": None, "examples": ["query1", "query2"],
"examples": ["query1", "query2"],
}, },
"example": "query_overridden", "example": "query_overridden",
"name": "data", "name": "data",
@ -612,8 +609,7 @@ def test_openapi_schema():
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Data",
"title": "Data",
}, },
"example": "header1", "example": "header1",
"name": "data", "name": "data",
@ -647,8 +643,7 @@ def test_openapi_schema():
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "Data", "title": "Data", "default": None, "examples": ["header1", "header2"],
"examples": ["header1", "header2"],
}, },
"name": "data", "name": "data",
"in": "header", "in": "header",
@ -681,8 +676,7 @@ def test_openapi_schema():
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "Data", "title": "Data", "default": None, "examples": ["header1", "header2"],
"examples": ["header1", "header2"],
}, },
"example": "header_overridden", "example": "header_overridden",
"name": "data", "name": "data",
@ -715,8 +709,7 @@ def test_openapi_schema():
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Data",
"title": "Data",
}, },
"example": "cookie1", "example": "cookie1",
"name": "data", "name": "data",
@ -750,8 +743,7 @@ def test_openapi_schema():
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "Data", "title": "Data", "default": None, "examples": ["cookie1", "cookie2"],
"examples": ["cookie1", "cookie2"],
}, },
"name": "data", "name": "data",
"in": "cookie", "in": "cookie",
@ -784,8 +776,7 @@ def test_openapi_schema():
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "Data", "title": "Data", "default": None, "examples": ["cookie1", "cookie2"],
"examples": ["cookie1", "cookie2"],
}, },
"example": "cookie_overridden", "example": "cookie_overridden",
"name": "data", "name": "data",

19
tests/test_sub_callbacks.py

@ -93,14 +93,27 @@ def test_openapi_schema():
"/invoices/": { "/invoices/": {
"post": { "post": {
"summary": "Create Invoice", "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").', "description": """\
Create an invoice.
This will (let's imagine) let the API user (some external developer) create an
invoice.
And this path operation will:
* Send the invoice to the client.
* Collect the money from the client.
* Send a notification back to the API user (the external developer), as a callback.
* At this point is that the API will somehow send a POST request to the
external API with the notification of the invoice event
(e.g. "payment successful").\
""",
"operationId": "create_invoice_invoices__post", "operationId": "create_invoice_invoices__post",
"parameters": [ "parameters": [
{ {
"required": False, "required": False,
"schema": { "schema": {
"title": "Callback Url", "title": "Callback Url", "default": None, "anyOf": [
"anyOf": [
{ {
"type": "string", "type": "string",
"format": "uri", "format": "uri",

3
tests/test_tutorial/test_additional_responses/test_tutorial002.py

@ -82,8 +82,7 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "boolean"}, {"type": "null"}], "anyOf": [{"type": "boolean"}, {"type": "null"}], "default": None, "title": "Img",
"title": "Img",
}, },
"name": "img", "name": "img",
"in": "query", "in": "query",

3
tests/test_tutorial/test_additional_responses/test_tutorial004.py

@ -85,8 +85,7 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "boolean"}, {"type": "null"}], "anyOf": [{"type": "boolean"}, {"type": "null"}], "default": None, "title": "Img",
"title": "Img",
}, },
"name": "img", "name": "img",
"in": "query", "in": "query",

3
tests/test_tutorial/test_body/test_tutorial004.py

@ -96,8 +96,7 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Q",
"title": "Q",
}, },
"name": "q", "name": "q",
"in": "query", "in": "query",

10
tests/test_tutorial/test_body_multiple_params/test_tutorial001.py

@ -96,8 +96,8 @@ def test_openapi_schema(client: TestClient):
"required": True, "required": True,
"schema": { "schema": {
"title": "The ID of the item to get", "title": "The ID of the item to get",
"maximum": 1000.0, "maximum": 1000,
"minimum": 0.0, "minimum": 0,
"type": "integer", "type": "integer",
}, },
"name": "item_id", "name": "item_id",
@ -106,8 +106,7 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Q",
"title": "Q",
}, },
"name": "q", "name": "q",
"in": "query", "in": "query",
@ -120,8 +119,7 @@ def test_openapi_schema(client: TestClient):
"anyOf": [ "anyOf": [
{"$ref": "#/components/schemas/Item"}, {"$ref": "#/components/schemas/Item"},
{"type": "null"}, {"type": "null"},
], ], "default": None, "title": "Item",
"title": "Item",
} }
} }
} }

3
tests/test_tutorial/test_body_multiple_params/test_tutorial004.py

@ -193,8 +193,7 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Q",
"title": "Q",
}, },
"name": "q", "name": "q",
"in": "query", "in": "query",

15
tests/test_tutorial/test_cookie_param_models/test_tutorial001.py

@ -92,26 +92,21 @@ def test_openapi_schema(client: TestClient):
"name": "session_id", "name": "session_id",
"in": "cookie", "in": "cookie",
"required": True, "required": True,
"schema": {"type": "string", "title": "Session Id"}, "schema": {"type": "string", "title": "Session Id"}, "example": None},
},
{ {
"name": "fatebook_tracker", "name": "fatebook_tracker",
"in": "cookie", "in": "cookie",
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Fatebook Tracker",
"title": "Fatebook Tracker", }, "example": None},
},
},
{ {
"name": "googall_tracker", "name": "googall_tracker",
"in": "cookie", "in": "cookie",
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Googall Tracker",
"title": "Googall Tracker", }, "example": None},
},
},
], ],
"responses": { "responses": {
"200": { "200": {

15
tests/test_tutorial/test_cookie_param_models/test_tutorial002.py

@ -99,8 +99,7 @@ def test_openapi_schema(client: TestClient):
"name": "session_id", "name": "session_id",
"in": "cookie", "in": "cookie",
"required": True, "required": True,
"schema": {"type": "string", "title": "Session Id"}, "schema": {"type": "string", "title": "Session Id"}, "example": None},
},
{ {
"name": "fatebook_tracker", "name": "fatebook_tracker",
"in": "cookie", "in": "cookie",
@ -109,19 +108,15 @@ def test_openapi_schema(client: TestClient):
"anyOf": [ "anyOf": [
{"type": "string"}, {"type": "string"},
{"type": "null"}, {"type": "null"},
], ], "default": None, "title": "Fatebook Tracker",
"title": "Fatebook Tracker", }, "example": None},
},
},
{ {
"name": "googall_tracker", "name": "googall_tracker",
"in": "cookie", "in": "cookie",
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Googall Tracker",
"title": "Googall Tracker", }, "example": None},
},
},
], ],
"responses": { "responses": {
"200": { "200": {

3
tests/test_tutorial/test_cookie_params/test_tutorial001.py

@ -75,8 +75,7 @@ def test_openapi_schema(mod: ModuleType):
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Ads Id",
"title": "Ads Id",
}, },
"name": "ads_id", "name": "ads_id",
"in": "cookie", "in": "cookie",

6
tests/test_tutorial/test_dependencies/test_tutorial001_tutorial001_02.py

@ -70,8 +70,7 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Q",
"title": "Q",
}, },
"name": "q", "name": "q",
"in": "query", "in": "query",
@ -123,8 +122,7 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Q",
"title": "Q",
}, },
"name": "q", "name": "q",
"in": "query", "in": "query",

3
tests/test_tutorial/test_dependencies/test_tutorial002_tutorial003_tutorial004.py

@ -111,8 +111,7 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Q",
"title": "Q",
}, },
"name": "q", "name": "q",
"in": "query", "in": "query",

6
tests/test_tutorial/test_dependencies/test_tutorial005.py

@ -86,8 +86,7 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Q",
"title": "Q",
}, },
"name": "q", "name": "q",
"in": "query", "in": "query",
@ -95,8 +94,7 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Last Query",
"title": "Last Query",
}, },
"name": "last_query", "name": "last_query",
"in": "cookie", "in": "cookie",

21
tests/test_tutorial/test_header_param_models/test_tutorial001.py

@ -111,32 +111,26 @@ def test_openapi_schema(client: TestClient):
"name": "host", "name": "host",
"in": "header", "in": "header",
"required": True, "required": True,
"schema": {"type": "string", "title": "Host"}, "schema": {"type": "string", "title": "Host"}, "example": None},
},
{ {
"name": "save-data", "name": "save-data",
"in": "header", "in": "header",
"required": True, "required": True,
"schema": {"type": "boolean", "title": "Save Data"}, "schema": {"type": "boolean", "title": "Save Data"}, "example": None},
},
{ {
"name": "if-modified-since", "name": "if-modified-since",
"in": "header", "in": "header",
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "If Modified Since",
"title": "If Modified Since", }, "example": None},
},
},
{ {
"name": "traceparent", "name": "traceparent",
"in": "header", "in": "header",
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Traceparent",
"title": "Traceparent", }, "example": None},
},
},
{ {
"name": "x-tag", "name": "x-tag",
"in": "header", "in": "header",
@ -146,8 +140,7 @@ def test_openapi_schema(client: TestClient):
"items": {"type": "string"}, "items": {"type": "string"},
"default": [], "default": [],
"title": "X Tag", "title": "X Tag",
}, }, "example": None},
},
], ],
"responses": { "responses": {
"200": { "200": {

21
tests/test_tutorial/test_header_param_models/test_tutorial002.py

@ -108,32 +108,26 @@ def test_openapi_schema(client: TestClient):
"name": "host", "name": "host",
"in": "header", "in": "header",
"required": True, "required": True,
"schema": {"type": "string", "title": "Host"}, "schema": {"type": "string", "title": "Host"}, "example": None},
},
{ {
"name": "save-data", "name": "save-data",
"in": "header", "in": "header",
"required": True, "required": True,
"schema": {"type": "boolean", "title": "Save Data"}, "schema": {"type": "boolean", "title": "Save Data"}, "example": None},
},
{ {
"name": "if-modified-since", "name": "if-modified-since",
"in": "header", "in": "header",
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "If Modified Since",
"title": "If Modified Since", }, "example": None},
},
},
{ {
"name": "traceparent", "name": "traceparent",
"in": "header", "in": "header",
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Traceparent",
"title": "Traceparent", }, "example": None},
},
},
{ {
"name": "x-tag", "name": "x-tag",
"in": "header", "in": "header",
@ -143,8 +137,7 @@ def test_openapi_schema(client: TestClient):
"items": {"type": "string"}, "items": {"type": "string"},
"default": [], "default": [],
"title": "X Tag", "title": "X Tag",
}, }, "example": None},
},
], ],
"responses": { "responses": {
"200": { "200": {

21
tests/test_tutorial/test_header_param_models/test_tutorial003.py

@ -148,32 +148,26 @@ def test_openapi_schema(client: TestClient):
"name": "host", "name": "host",
"in": "header", "in": "header",
"required": True, "required": True,
"schema": {"type": "string", "title": "Host"}, "schema": {"type": "string", "title": "Host"}, "example": None},
},
{ {
"name": "save_data", "name": "save_data",
"in": "header", "in": "header",
"required": True, "required": True,
"schema": {"type": "boolean", "title": "Save Data"}, "schema": {"type": "boolean", "title": "Save Data"}, "example": None},
},
{ {
"name": "if_modified_since", "name": "if_modified_since",
"in": "header", "in": "header",
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "If Modified Since",
"title": "If Modified Since", }, "example": None},
},
},
{ {
"name": "traceparent", "name": "traceparent",
"in": "header", "in": "header",
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Traceparent",
"title": "Traceparent", }, "example": None},
},
},
{ {
"name": "x_tag", "name": "x_tag",
"in": "header", "in": "header",
@ -183,8 +177,7 @@ def test_openapi_schema(client: TestClient):
"items": {"type": "string"}, "items": {"type": "string"},
"default": [], "default": [],
"title": "X Tag", "title": "X Tag",
}, }, "example": None},
},
], ],
"responses": { "responses": {
"200": { "200": {

3
tests/test_tutorial/test_header_params/test_tutorial001.py

@ -67,8 +67,7 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "User-Agent",
"title": "User-Agent",
}, },
"name": "user-agent", "name": "user-agent",
"in": "header", "in": "header",

3
tests/test_tutorial/test_header_params/test_tutorial002.py

@ -78,8 +78,7 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Strange Header",
"title": "Strange Header",
}, },
"name": "strange_header", "name": "strange_header",
"in": "header", "in": "header",

3
tests/test_tutorial/test_header_params/test_tutorial003.py

@ -56,8 +56,7 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"title": "X-Token", "title": "X-Token", "default": None, "anyOf": [
"anyOf": [
{"type": "array", "items": {"type": "string"}}, {"type": "array", "items": {"type": "string"}},
{"type": "null"}, {"type": "null"},
], ],

16
tests/test_tutorial/test_metadata/test_tutorial001.py

@ -21,7 +21,21 @@ def test_openapi_schema():
"info": { "info": {
"title": "ChimichangApp", "title": "ChimichangApp",
"summary": "Deadpool's favorite app. Nuff said.", "summary": "Deadpool's favorite app. Nuff said.",
"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", "description": """\
ChimichangApp API helps you do awesome stuff. 🚀
## Items
You can **read items**.
## Users
You will be able to:
* **Create users** (_not implemented_).
* **Read users** (_not implemented_).
""",
"termsOfService": "http://example.com/terms/", "termsOfService": "http://example.com/terms/",
"contact": { "contact": {
"name": "Deadpoolio the Amazing", "name": "Deadpoolio the Amazing",

16
tests/test_tutorial/test_metadata/test_tutorial001_1.py

@ -21,7 +21,21 @@ def test_openapi_schema():
"info": { "info": {
"title": "ChimichangApp", "title": "ChimichangApp",
"summary": "Deadpool's favorite app. Nuff said.", "summary": "Deadpool's favorite app. Nuff said.",
"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", "description": """\
ChimichangApp API helps you do awesome stuff. 🚀
## Items
You can **read items**.
## Users
You will be able to:
* **Create users** (_not implemented_).
* **Read users** (_not implemented_).
""",
"termsOfService": "http://example.com/terms/", "termsOfService": "http://example.com/terms/",
"contact": { "contact": {
"name": "Deadpoolio the Amazing", "name": "Deadpoolio the Amazing",

19
tests/test_tutorial/test_openapi_callbacks/test_tutorial001.py

@ -50,7 +50,21 @@ def test_openapi_schema(client: TestClient):
"/invoices/": { "/invoices/": {
"post": { "post": {
"summary": "Create Invoice", "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").', "description": """\
Create an invoice.
This will (let's imagine) let the API user (some external developer) create an
invoice.
And this path operation will:
* Send the invoice to the client.
* Collect the money from the client.
* Send a notification back to the API user (the external developer), as a callback.
* At this point is that the API will somehow send a POST request to the
external API with the notification of the invoice event
(e.g. "payment successful").\
""",
"operationId": "create_invoice_invoices__post", "operationId": "create_invoice_invoices__post",
"parameters": [ "parameters": [
{ {
@ -64,8 +78,7 @@ def test_openapi_schema(client: TestClient):
"maxLength": 2083, "maxLength": 2083,
}, },
{"type": "null"}, {"type": "null"},
], ], "default": None, "title": "Callback Url",
"title": "Callback Url",
}, },
"name": "callback_url", "name": "callback_url",
"in": "query", "in": "query",

5
tests/test_tutorial/test_openapi_webhooks/test_tutorial001.py

@ -42,7 +42,10 @@ def test_openapi_schema():
"new-subscription": { "new-subscription": {
"post": { "post": {
"summary": "New Subscription", "summary": "New Subscription",
"description": "When a new user subscribes to your service we'll send you a POST request with this\ndata to the URL that you register for the event `new-subscription` in the dashboard.", "description": """\
When a new user subscribes to your service we'll send you a POST request with this
data to the URL that you register for the event `new-subscription` in the dashboard.\
""",
"operationId": "new_subscriptionnew_subscription_post", "operationId": "new_subscriptionnew_subscription_post",
"requestBody": { "requestBody": {
"content": { "content": {

10
tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial004.py

@ -66,7 +66,15 @@ def test_openapi_schema(client: TestClient):
}, },
}, },
"summary": "Create an item", "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", "description": """\
Create an item with all the information:
- **name**: each item must have a name
- **description**: a long description
- **price**: required
- **tax**: if the item doesn't have tax, you can omit this
- **tags**: a set of unique tag strings for this item\
""",
"operationId": "create_item_items__post", "operationId": "create_item_items__post",
"requestBody": { "requestBody": {
"content": { "content": {

10
tests/test_tutorial/test_path_operation_configurations/test_tutorial005.py

@ -65,7 +65,15 @@ def test_openapi_schema(client: TestClient):
}, },
}, },
"summary": "Create an item", "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", "description": """\
Create an item with all the information:
- **name**: each item must have a name
- **description**: a long description
- **price**: required
- **tax**: if the item doesn't have tax, you can omit this
- **tags**: a set of unique tag strings for this item\
""",
"operationId": "create_item_items__post", "operationId": "create_item_items__post",
"requestBody": { "requestBody": {
"content": { "content": {

3
tests/test_tutorial/test_path_params_numeric_validations/test_tutorial001.py

@ -81,8 +81,7 @@ def test_openapi_schema(client: TestClient):
{ {
"type": "null", "type": "null",
}, },
], ], "default": None, "title": "Item-Query",
"title": "Item-Query",
}, },
"name": "item-query", "name": "item-query",
"in": "query", "in": "query",

12
tests/test_tutorial/test_query_param_models/test_tutorial001.py

@ -133,8 +133,7 @@ def test_openapi_schema(client: TestClient):
"exclusiveMinimum": 0, "exclusiveMinimum": 0,
"default": 100, "default": 100,
"title": "Limit", "title": "Limit",
}, }, "example": None},
},
{ {
"name": "offset", "name": "offset",
"in": "query", "in": "query",
@ -144,8 +143,7 @@ def test_openapi_schema(client: TestClient):
"minimum": 0, "minimum": 0,
"default": 0, "default": 0,
"title": "Offset", "title": "Offset",
}, }, "example": None},
},
{ {
"name": "order_by", "name": "order_by",
"in": "query", "in": "query",
@ -155,8 +153,7 @@ def test_openapi_schema(client: TestClient):
"type": "string", "type": "string",
"default": "created_at", "default": "created_at",
"title": "Order By", "title": "Order By",
}, }, "example": None},
},
{ {
"name": "tags", "name": "tags",
"in": "query", "in": "query",
@ -166,8 +163,7 @@ def test_openapi_schema(client: TestClient):
"items": {"type": "string"}, "items": {"type": "string"},
"default": [], "default": [],
"title": "Tags", "title": "Tags",
}, }, "example": None},
},
], ],
"responses": { "responses": {
"200": { "200": {

12
tests/test_tutorial/test_query_param_models/test_tutorial002.py

@ -139,8 +139,7 @@ def test_openapi_schema(client: TestClient):
"exclusiveMinimum": 0, "exclusiveMinimum": 0,
"default": 100, "default": 100,
"title": "Limit", "title": "Limit",
}, }, "example": None},
},
{ {
"name": "offset", "name": "offset",
"in": "query", "in": "query",
@ -150,8 +149,7 @@ def test_openapi_schema(client: TestClient):
"minimum": 0, "minimum": 0,
"default": 0, "default": 0,
"title": "Offset", "title": "Offset",
}, }, "example": None},
},
{ {
"name": "order_by", "name": "order_by",
"in": "query", "in": "query",
@ -161,8 +159,7 @@ def test_openapi_schema(client: TestClient):
"type": "string", "type": "string",
"default": "created_at", "default": "created_at",
"title": "Order By", "title": "Order By",
}, }, "example": None},
},
{ {
"name": "tags", "name": "tags",
"in": "query", "in": "query",
@ -172,8 +169,7 @@ def test_openapi_schema(client: TestClient):
"items": {"type": "string"}, "items": {"type": "string"},
"default": [], "default": [],
"title": "Tags", "title": "Tags",
}, }, "example": None},
},
], ],
"responses": { "responses": {
"200": { "200": {

3
tests/test_tutorial/test_query_params/test_tutorial002.py

@ -61,8 +61,7 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"title": "Q", "title": "Q", "default": None, "anyOf": [
"anyOf": [
{ {
"type": "string", "type": "string",
}, },

3
tests/test_tutorial/test_query_params/test_tutorial003.py

@ -72,8 +72,7 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"title": "Q", "title": "Q", "default": None, "anyOf": [
"anyOf": [
{ {
"type": "string", "type": "string",
}, },

3
tests/test_tutorial/test_query_params/test_tutorial004.py

@ -80,8 +80,7 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"title": "Q", "title": "Q", "default": None, "anyOf": [
"anyOf": [
{ {
"type": "string", "type": "string",
}, },

3
tests/test_tutorial/test_query_params/test_tutorial006.py

@ -112,8 +112,7 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "integer"}, {"type": "null"}], "anyOf": [{"type": "integer"}, {"type": "null"}], "default": None, "title": "Limit",
"title": "Limit",
}, },
"name": "limit", "name": "limit",
"in": "query", "in": "query",

3
tests/test_tutorial/test_query_params_str_validations/test_tutorial001.py

@ -78,8 +78,7 @@ def test_openapi_schema(client: TestClient):
"anyOf": [ "anyOf": [
{"type": "string"}, {"type": "string"},
{"type": "null"}, {"type": "null"},
], ], "default": None, "title": "Q",
"title": "Q",
}, },
"name": "q", "name": "q",
"in": "query", "in": "query",

3
tests/test_tutorial/test_query_params_str_validations/test_tutorial002.py

@ -98,8 +98,7 @@ def test_openapi_schema(client: TestClient):
"maxLength": 50, "maxLength": 50,
}, },
{"type": "null"}, {"type": "null"},
], ], "default": None, "title": "Q",
"title": "Q",
}, },
"name": "q", "name": "q",
"in": "query", "in": "query",

3
tests/test_tutorial/test_query_params_str_validations/test_tutorial003.py

@ -109,8 +109,7 @@ def test_openapi_schema(client: TestClient):
"maxLength": 50, "maxLength": 50,
}, },
{"type": "null"}, {"type": "null"},
], ], "default": None, "title": "Q",
"title": "Q",
}, },
"name": "q", "name": "q",
"in": "query", "in": "query",

3
tests/test_tutorial/test_query_params_str_validations/test_tutorial004.py

@ -94,8 +94,7 @@ def test_openapi_schema(client: TestClient):
"pattern": "^fixedquery$", "pattern": "^fixedquery$",
}, },
{"type": "null"}, {"type": "null"},
], ], "default": None, "title": "Q",
"title": "Q",
}, },
"name": "q", "name": "q",
"in": "query", "in": "query",

3
tests/test_tutorial/test_query_params_str_validations/test_tutorial007.py

@ -93,8 +93,7 @@ def test_openapi_schema(client: TestClient):
}, },
{"type": "null"}, {"type": "null"},
], ],
"title": "Query string", "title": "Query string", "default": None},
},
"name": "q", "name": "q",
"in": "query", "in": "query",
} }

3
tests/test_tutorial/test_query_params_str_validations/test_tutorial008.py

@ -95,8 +95,7 @@ def test_openapi_schema(client: TestClient):
{"type": "null"}, {"type": "null"},
], ],
"title": "Query string", "title": "Query string",
"description": "Query string for the items to search in the database that have a good match", "description": "Query string for the items to search in the database that have a good match", "default": None},
},
"name": "q", "name": "q",
"in": "query", "in": "query",
} }

3
tests/test_tutorial/test_query_params_str_validations/test_tutorial009.py

@ -78,8 +78,7 @@ def test_openapi_schema(client: TestClient):
"anyOf": [ "anyOf": [
{"type": "string"}, {"type": "string"},
{"type": "null"}, {"type": "null"},
], ], "default": None, "title": "Item-Query",
"title": "Item-Query",
}, },
"required": False, "required": False,
"name": "item-query", "name": "item-query",

3
tests/test_tutorial/test_query_params_str_validations/test_tutorial011.py

@ -72,8 +72,7 @@ def test_openapi_schema(client: TestClient):
"anyOf": [ "anyOf": [
{"type": "array", "items": {"type": "string"}}, {"type": "array", "items": {"type": "string"}},
{"type": "null"}, {"type": "null"},
], ], "default": None, "title": "Q",
"title": "Q",
}, },
"name": "q", "name": "q",
"in": "query", "in": "query",

3
tests/test_tutorial/test_query_params_str_validations/test_tutorial015.py

@ -80,8 +80,7 @@ def test_openapi_schema(client: TestClient):
"in": "query", "in": "query",
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Id",
"title": "Id",
}, },
} }
], ],

3
tests/test_tutorial/test_server_sent_events/test_tutorial004.py

@ -86,8 +86,7 @@ def test_openapi_schema(client: TestClient):
"in": "header", "in": "header",
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "integer"}, {"type": "null"}], "anyOf": [{"type": "integer"}, {"type": "null"}], "default": None, "title": "Last-Event-Id",
"title": "Last-Event-Id",
}, },
} }
], ],

5
tests/test_webhooks_security.py

@ -48,7 +48,10 @@ def test_openapi_schema():
"new-subscription": { "new-subscription": {
"post": { "post": {
"summary": "New Subscription", "summary": "New Subscription",
"description": "When a new user subscribes to your service we'll send you a POST request with this\ndata to the URL that you register for the event `new-subscription` in the dashboard.", "description": """\
When a new user subscribes to your service we'll send you a POST request with this
data to the URL that you register for the event `new-subscription` in the dashboard.\
""",
"operationId": "new_subscriptionnew_subscription_post", "operationId": "new_subscriptionnew_subscription_post",
"requestBody": { "requestBody": {
"content": { "content": {

Loading…
Cancel
Save