Browse Source

🎨 Auto format

pull/15318/head
pre-commit-ci-lite[bot] 3 months ago
committed by GitHub
parent
commit
d50bbb487d
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      fastapi/encoders.py
  2. 2
      fastapi/security/http.py
  3. 4
      fastapi/security/oauth2.py
  4. 4
      tests/test_application.py
  5. 8
      tests/test_infer_param_optionality.py
  6. 4
      tests/test_multi_query_errors.py
  7. 12
      tests/test_openapi_examples.py
  8. 4
      tests/test_regex_deprecated_params.py
  9. 104
      tests/test_request_params/test_cookie/test_optional_str.py
  10. 72
      tests/test_request_params/test_cookie/test_required_str.py
  11. 92
      tests/test_request_params/test_header/test_list.py
  12. 116
      tests/test_request_params/test_header/test_optional_list.py
  13. 104
      tests/test_request_params/test_header/test_optional_str.py
  14. 72
      tests/test_request_params/test_header/test_required_str.py
  15. 92
      tests/test_request_params/test_query/test_list.py
  16. 116
      tests/test_request_params/test_query/test_optional_list.py
  17. 104
      tests/test_request_params/test_query/test_optional_str.py
  18. 72
      tests/test_request_params/test_query/test_required_str.py
  19. 36
      tests/test_schema_extra_examples.py
  20. 4
      tests/test_sub_callbacks.py
  21. 4
      tests/test_tutorial/test_additional_responses/test_tutorial002.py
  22. 4
      tests/test_tutorial/test_additional_responses/test_tutorial004.py
  23. 4
      tests/test_tutorial/test_body/test_tutorial004.py
  24. 8
      tests/test_tutorial/test_body_multiple_params/test_tutorial001.py
  25. 4
      tests/test_tutorial/test_body_multiple_params/test_tutorial004.py
  26. 20
      tests/test_tutorial/test_cookie_param_models/test_tutorial001.py
  27. 20
      tests/test_tutorial/test_cookie_param_models/test_tutorial002.py
  28. 4
      tests/test_tutorial/test_cookie_params/test_tutorial001.py
  29. 8
      tests/test_tutorial/test_dependencies/test_tutorial001_tutorial001_02.py
  30. 4
      tests/test_tutorial/test_dependencies/test_tutorial002_tutorial003_tutorial004.py
  31. 8
      tests/test_tutorial/test_dependencies/test_tutorial005.py
  32. 28
      tests/test_tutorial/test_header_param_models/test_tutorial001.py
  33. 28
      tests/test_tutorial/test_header_param_models/test_tutorial002.py
  34. 28
      tests/test_tutorial/test_header_param_models/test_tutorial003.py
  35. 4
      tests/test_tutorial/test_header_params/test_tutorial001.py
  36. 4
      tests/test_tutorial/test_header_params/test_tutorial002.py
  37. 4
      tests/test_tutorial/test_header_params/test_tutorial003.py
  38. 4
      tests/test_tutorial/test_openapi_callbacks/test_tutorial001.py
  39. 4
      tests/test_tutorial/test_path_params_numeric_validations/test_tutorial001.py
  40. 16
      tests/test_tutorial/test_query_param_models/test_tutorial001.py
  41. 16
      tests/test_tutorial/test_query_param_models/test_tutorial002.py
  42. 4
      tests/test_tutorial/test_query_params/test_tutorial002.py
  43. 4
      tests/test_tutorial/test_query_params/test_tutorial003.py
  44. 4
      tests/test_tutorial/test_query_params/test_tutorial004.py
  45. 4
      tests/test_tutorial/test_query_params/test_tutorial006.py
  46. 4
      tests/test_tutorial/test_query_params_str_validations/test_tutorial001.py
  47. 4
      tests/test_tutorial/test_query_params_str_validations/test_tutorial002.py
  48. 4
      tests/test_tutorial/test_query_params_str_validations/test_tutorial003.py
  49. 4
      tests/test_tutorial/test_query_params_str_validations/test_tutorial004.py
  50. 4
      tests/test_tutorial/test_query_params_str_validations/test_tutorial007.py
  51. 4
      tests/test_tutorial/test_query_params_str_validations/test_tutorial008.py
  52. 4
      tests/test_tutorial/test_query_params_str_validations/test_tutorial009.py
  53. 4
      tests/test_tutorial/test_query_params_str_validations/test_tutorial011.py
  54. 4
      tests/test_tutorial/test_query_params_str_validations/test_tutorial015.py
  55. 4
      tests/test_tutorial/test_server_sent_events/test_tutorial004.py

6
fastapi/encoders.py

@ -235,7 +235,11 @@ def jsonable_encoder(
) )
if sqlalchemy_safe: if sqlalchemy_safe:
result = {k: v for k, v in result.items() if not (isinstance(k, str) and k.startswith("_sa"))} result = {
k: v
for k, v in result.items()
if not (isinstance(k, str) and k.startswith("_sa"))
}
return result return result
if dataclasses.is_dataclass(obj): if dataclasses.is_dataclass(obj):
assert not isinstance(obj, type) assert not isinstance(obj, type)

2
fastapi/security/http.py

@ -315,6 +315,7 @@ class HTTPBearer(HTTPBase):
return None return None
return HTTPAuthorizationCredentials(scheme=scheme, credentials=credentials) return HTTPAuthorizationCredentials(scheme=scheme, credentials=credentials)
class HTTPCookieBearer(SecurityBase): class HTTPCookieBearer(SecurityBase):
""" """
Bearer token authentication via a named cookie (e.g. `access_token`). Bearer token authentication via a named cookie (e.g. `access_token`).
@ -363,6 +364,7 @@ class HTTPCookieBearer(SecurityBase):
return None return None
return HTTPAuthorizationCredentials(scheme="Bearer", credentials=token) return HTTPAuthorizationCredentials(scheme="Bearer", credentials=token)
class HTTPDigest(HTTPBase): class HTTPDigest(HTTPBase):
""" """
HTTP Digest authentication. HTTP Digest authentication.

4
fastapi/security/oauth2.py

@ -1,3 +1,4 @@
import secrets
from typing import Annotated, Any, cast from typing import Annotated, Any, cast
from annotated_doc import Doc from annotated_doc import Doc
@ -8,9 +9,8 @@ from fastapi.param_functions import Form
from fastapi.security.base import SecurityBase from fastapi.security.base import SecurityBase
from fastapi.security.utils import get_authorization_scheme_param from fastapi.security.utils import get_authorization_scheme_param
from starlette.requests import Request from starlette.requests import Request
from starlette.status import HTTP_401_UNAUTHORIZED
from starlette.responses import RedirectResponse from starlette.responses import RedirectResponse
import secrets from starlette.status import HTTP_401_UNAUTHORIZED
class OAuth2PasswordRequestForm: class OAuth2PasswordRequestForm:

4
tests/test_application.py

@ -982,7 +982,9 @@ def test_openapi_schema():
"in": "query", "in": "query",
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "integer"}, {"type": "null"}], "default": None, "title": "Query", "anyOf": [{"type": "integer"}, {"type": "null"}],
"default": None,
"title": "Query",
}, },
} }
], ],

8
tests/test_infer_param_optionality.py

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

4
tests/test_multi_query_errors.py

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

12
tests/test_openapi_examples.py

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

4
tests/test_regex_deprecated_params.py

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

104
tests/test_request_params/test_cookie/test_optional_str.py

@ -31,18 +31,20 @@ 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", {
"in": "cookie", "name": "p",
"required": False, "in": "cookie",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"default": None, "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "P", "default": None,
}, "title": "P",
} },
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -93,18 +95,20 @@ 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", {
"in": "cookie", "name": "p_alias",
"required": False, "in": "cookie",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"default": None, "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "P Alias", "default": None,
}, "title": "P Alias",
} },
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -172,18 +176,20 @@ 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", {
"in": "cookie", "name": "p_val_alias",
"required": False, "in": "cookie",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"default": None, "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "P Val Alias", "default": None,
}, "title": "P Val Alias",
} },
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -259,18 +265,20 @@ 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", {
"in": "cookie", "name": "p_val_alias",
"required": False, "in": "cookie",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"default": None, "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "P Val Alias", "default": None,
}, "title": "P Val Alias",
} },
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

72
tests/test_request_params/test_cookie/test_required_str.py

@ -32,14 +32,16 @@ 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", {
"in": "cookie", "name": "p",
"required": True, "in": "cookie",
"schema": {"type": "string", "title": "P"}, "required": True,
} "schema": {"type": "string", "title": "P"},
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -97,14 +99,16 @@ 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", {
"in": "cookie", "name": "p_alias",
"required": True, "in": "cookie",
"schema": {"type": "string", "title": "P Alias"}, "required": True,
} "schema": {"type": "string", "title": "P Alias"},
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -196,14 +200,16 @@ 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", {
"in": "cookie", "name": "p_val_alias",
"required": True, "in": "cookie",
"schema": {"type": "string", "title": "P Val Alias"}, "required": True,
} "schema": {"type": "string", "title": "P Val Alias"},
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -303,14 +309,16 @@ 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", {
"in": "cookie", "name": "p_val_alias",
"required": True, "in": "cookie",
"schema": {"type": "string", "title": "P Val Alias"}, "required": True,
} "schema": {"type": "string", "title": "P Val Alias"},
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

92
tests/test_request_params/test_header/test_list.py

@ -32,14 +32,16 @@ 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", {
"in": "header", "name": "p",
"required": True, "in": "header",
"schema": {"type": "array", "items": {"type": "string"}, "title": "P"}, "required": True,
} "schema": {"type": "array", "items": {"type": "string"}, "title": "P"},
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -98,14 +100,20 @@ 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", {
"in": "header", "name": "p_alias",
"required": True, "in": "header",
"schema": {"type": "array", "items": {"type": "string"}, "title": "P Alias"}, "required": True,
} "schema": {
]) "type": "array",
"items": {"type": "string"},
"title": "P Alias",
},
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -192,18 +200,20 @@ 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", {
"in": "header", "name": "p_val_alias",
"required": True, "in": "header",
"schema": { "required": True,
"type": "array", "schema": {
"items": {"type": "string"}, "type": "array",
"title": "P Val Alias", "items": {"type": "string"},
}, "title": "P Val Alias",
} },
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -300,18 +310,20 @@ 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", {
"in": "header", "name": "p_val_alias",
"required": True, "in": "header",
"schema": { "required": True,
"type": "array", "schema": {
"items": {"type": "string"}, "type": "array",
"title": "P Val Alias", "items": {"type": "string"},
}, "title": "P Val Alias",
} },
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

116
tests/test_request_params/test_header/test_optional_list.py

@ -35,18 +35,23 @@ 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", {
"in": "header", "name": "p",
"required": False, "in": "header",
"schema": { "required": False,
"anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "null"}], "schema": {
"default": None, "anyOf": [
"title": "P", {"type": "array", "items": {"type": "string"}},
}, {"type": "null"},
} ],
]) "default": None,
"title": "P",
},
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -98,18 +103,23 @@ 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", {
"in": "header", "name": "p_alias",
"required": False, "in": "header",
"schema": { "required": False,
"anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "null"}], "schema": {
"default": None, "anyOf": [
"title": "P Alias", {"type": "array", "items": {"type": "string"}},
}, {"type": "null"},
} ],
]) "default": None,
"title": "P Alias",
},
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -175,18 +185,23 @@ 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", {
"in": "header", "name": "p_val_alias",
"required": False, "in": "header",
"schema": { "required": False,
"anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "null"}], "schema": {
"default": None, "anyOf": [
"title": "P Val Alias", {"type": "array", "items": {"type": "string"}},
}, {"type": "null"},
} ],
]) "default": None,
"title": "P Val Alias",
},
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -259,18 +274,23 @@ 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", {
"in": "header", "name": "p_val_alias",
"required": False, "in": "header",
"schema": { "required": False,
"anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "null"}], "schema": {
"default": None, "anyOf": [
"title": "P Val Alias", {"type": "array", "items": {"type": "string"}},
}, {"type": "null"},
} ],
]) "default": None,
"title": "P Val Alias",
},
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

104
tests/test_request_params/test_header/test_optional_str.py

@ -31,18 +31,20 @@ 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", {
"in": "header", "name": "p",
"required": False, "in": "header",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"default": None, "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "P", "default": None,
}, "title": "P",
} },
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -92,18 +94,20 @@ 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", {
"in": "header", "name": "p_alias",
"required": False, "in": "header",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"default": None, "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "P Alias", "default": None,
}, "title": "P Alias",
} },
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -169,18 +173,20 @@ 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", {
"in": "header", "name": "p_val_alias",
"required": False, "in": "header",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"default": None, "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "P Val Alias", "default": None,
}, "title": "P Val Alias",
} },
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -254,18 +260,20 @@ 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", {
"in": "header", "name": "p_val_alias",
"required": False, "in": "header",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"default": None, "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "P Val Alias", "default": None,
}, "title": "P Val Alias",
} },
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

72
tests/test_request_params/test_header/test_required_str.py

@ -32,14 +32,16 @@ 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", {
"in": "header", "name": "p",
"required": True, "in": "header",
"schema": {"type": "string", "title": "P"}, "required": True,
} "schema": {"type": "string", "title": "P"},
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -96,14 +98,16 @@ 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", {
"in": "header", "name": "p_alias",
"required": True, "in": "header",
"schema": {"type": "string", "title": "P Alias"}, "required": True,
} "schema": {"type": "string", "title": "P Alias"},
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -190,14 +194,16 @@ 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", {
"in": "header", "name": "p_val_alias",
"required": True, "in": "header",
"schema": {"type": "string", "title": "P Val Alias"}, "required": True,
} "schema": {"type": "string", "title": "P Val Alias"},
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -295,14 +301,16 @@ 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", {
"in": "header", "name": "p_val_alias",
"required": True, "in": "header",
"schema": {"type": "string", "title": "P Val Alias"}, "required": True,
} "schema": {"type": "string", "title": "P Val Alias"},
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

92
tests/test_request_params/test_query/test_list.py

@ -32,14 +32,16 @@ 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", {
"in": "query", "name": "p",
"required": True, "in": "query",
"schema": {"type": "array", "items": {"type": "string"}, "title": "P"}, "required": True,
} "schema": {"type": "array", "items": {"type": "string"}, "title": "P"},
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -98,14 +100,20 @@ 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", {
"in": "query", "name": "p_alias",
"required": True, "in": "query",
"schema": {"type": "array", "items": {"type": "string"}, "title": "P Alias"}, "required": True,
} "schema": {
]) "type": "array",
"items": {"type": "string"},
"title": "P Alias",
},
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -192,18 +200,20 @@ 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", {
"in": "query", "name": "p_val_alias",
"required": True, "in": "query",
"schema": { "required": True,
"type": "array", "schema": {
"items": {"type": "string"}, "type": "array",
"title": "P Val Alias", "items": {"type": "string"},
}, "title": "P Val Alias",
} },
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -298,18 +308,20 @@ 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", {
"in": "query", "name": "p_val_alias",
"required": True, "in": "query",
"schema": { "required": True,
"type": "array", "schema": {
"items": {"type": "string"}, "type": "array",
"title": "P Val Alias", "items": {"type": "string"},
}, "title": "P Val Alias",
} },
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

116
tests/test_request_params/test_query/test_optional_list.py

@ -35,18 +35,23 @@ 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", {
"in": "query", "name": "p",
"required": False, "in": "query",
"schema": { "required": False,
"anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "null"}], "schema": {
"default": None, "anyOf": [
"title": "P", {"type": "array", "items": {"type": "string"}},
}, {"type": "null"},
} ],
]) "default": None,
"title": "P",
},
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -98,18 +103,23 @@ 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", {
"in": "query", "name": "p_alias",
"required": False, "in": "query",
"schema": { "required": False,
"anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "null"}], "schema": {
"default": None, "anyOf": [
"title": "P Alias", {"type": "array", "items": {"type": "string"}},
}, {"type": "null"},
} ],
]) "default": None,
"title": "P Alias",
},
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -175,18 +185,23 @@ 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", {
"in": "query", "name": "p_val_alias",
"required": False, "in": "query",
"schema": { "required": False,
"anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "null"}], "schema": {
"default": None, "anyOf": [
"title": "P Val Alias", {"type": "array", "items": {"type": "string"}},
}, {"type": "null"},
} ],
]) "default": None,
"title": "P Val Alias",
},
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -257,18 +272,23 @@ 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", {
"in": "query", "name": "p_val_alias",
"required": False, "in": "query",
"schema": { "required": False,
"anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "null"}], "schema": {
"default": None, "anyOf": [
"title": "P Val Alias", {"type": "array", "items": {"type": "string"}},
}, {"type": "null"},
} ],
]) "default": None,
"title": "P Val Alias",
},
}
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

104
tests/test_request_params/test_query/test_optional_str.py

@ -31,18 +31,20 @@ 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", {
"in": "query", "name": "p",
"required": False, "in": "query",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"default": None, "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "P", "default": None,
}, "title": "P",
} },
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -92,18 +94,20 @@ 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", {
"in": "query", "name": "p_alias",
"required": False, "in": "query",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"default": None, "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "P Alias", "default": None,
}, "title": "P Alias",
} },
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -169,18 +173,20 @@ 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", {
"in": "query", "name": "p_val_alias",
"required": False, "in": "query",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"default": None, "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "P Val Alias", "default": None,
}, "title": "P Val Alias",
} },
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -254,18 +260,20 @@ 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", {
"in": "query", "name": "p_val_alias",
"required": False, "in": "query",
"schema": { "required": False,
"anyOf": [{"type": "string"}, {"type": "null"}], "schema": {
"default": None, "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "P Val Alias", "default": None,
}, "title": "P Val Alias",
} },
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

72
tests/test_request_params/test_query/test_required_str.py

@ -32,14 +32,16 @@ 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", {
"in": "query", "name": "p",
"required": True, "in": "query",
"schema": {"type": "string", "title": "P"}, "required": True,
} "schema": {"type": "string", "title": "P"},
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -96,14 +98,16 @@ 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", {
"in": "query", "name": "p_alias",
"required": True, "in": "query",
"schema": {"type": "string", "title": "P Alias"}, "required": True,
} "schema": {"type": "string", "title": "P Alias"},
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -193,14 +197,16 @@ 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", {
"in": "query", "name": "p_val_alias",
"required": True, "in": "query",
"schema": {"type": "string", "title": "P Val Alias"}, "required": True,
} "schema": {"type": "string", "title": "P Val Alias"},
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -298,14 +304,16 @@ 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", {
"in": "query", "name": "p_val_alias",
"required": True, "in": "query",
"schema": {"type": "string", "title": "P Val Alias"}, "required": True,
} "schema": {"type": "string", "title": "P Val Alias"},
]) }
]
)
@pytest.mark.parametrize( @pytest.mark.parametrize(

36
tests/test_schema_extra_examples.py

@ -509,7 +509,9 @@ def test_openapi_schema():
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Data", "anyOf": [{"type": "string"}, {"type": "null"}],
"default": None,
"title": "Data",
}, },
"example": "query1", "example": "query1",
"name": "data", "name": "data",
@ -543,7 +545,9 @@ def test_openapi_schema():
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "Data", "default": None, "examples": ["query1", "query2"], "title": "Data",
"default": None,
"examples": ["query1", "query2"],
}, },
"name": "data", "name": "data",
"in": "query", "in": "query",
@ -576,7 +580,9 @@ def test_openapi_schema():
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "Data", "default": None, "examples": ["query1", "query2"], "title": "Data",
"default": None,
"examples": ["query1", "query2"],
}, },
"example": "query_overridden", "example": "query_overridden",
"name": "data", "name": "data",
@ -609,7 +615,9 @@ def test_openapi_schema():
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Data", "anyOf": [{"type": "string"}, {"type": "null"}],
"default": None,
"title": "Data",
}, },
"example": "header1", "example": "header1",
"name": "data", "name": "data",
@ -643,7 +651,9 @@ def test_openapi_schema():
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "Data", "default": None, "examples": ["header1", "header2"], "title": "Data",
"default": None,
"examples": ["header1", "header2"],
}, },
"name": "data", "name": "data",
"in": "header", "in": "header",
@ -676,7 +686,9 @@ def test_openapi_schema():
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "Data", "default": None, "examples": ["header1", "header2"], "title": "Data",
"default": None,
"examples": ["header1", "header2"],
}, },
"example": "header_overridden", "example": "header_overridden",
"name": "data", "name": "data",
@ -709,7 +721,9 @@ def test_openapi_schema():
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Data", "anyOf": [{"type": "string"}, {"type": "null"}],
"default": None,
"title": "Data",
}, },
"example": "cookie1", "example": "cookie1",
"name": "data", "name": "data",
@ -743,7 +757,9 @@ def test_openapi_schema():
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "Data", "default": None, "examples": ["cookie1", "cookie2"], "title": "Data",
"default": None,
"examples": ["cookie1", "cookie2"],
}, },
"name": "data", "name": "data",
"in": "cookie", "in": "cookie",
@ -776,7 +792,9 @@ def test_openapi_schema():
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "Data", "default": None, "examples": ["cookie1", "cookie2"], "title": "Data",
"default": None,
"examples": ["cookie1", "cookie2"],
}, },
"example": "cookie_overridden", "example": "cookie_overridden",
"name": "data", "name": "data",

4
tests/test_sub_callbacks.py

@ -113,7 +113,9 @@ And this path operation will:
{ {
"required": False, "required": False,
"schema": { "schema": {
"title": "Callback Url", "default": None, "anyOf": [ "title": "Callback Url",
"default": None,
"anyOf": [
{ {
"type": "string", "type": "string",
"format": "uri", "format": "uri",

4
tests/test_tutorial/test_additional_responses/test_tutorial002.py

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

4
tests/test_tutorial/test_additional_responses/test_tutorial004.py

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

4
tests/test_tutorial/test_body/test_tutorial004.py

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

8
tests/test_tutorial/test_body_multiple_params/test_tutorial001.py

@ -106,7 +106,9 @@ def test_openapi_schema(client: TestClient):
{ {
"required": False, "required": False,
"schema": { "schema": {
"anyOf": [{"type": "string"}, {"type": "null"}], "default": None, "title": "Q", "anyOf": [{"type": "string"}, {"type": "null"}],
"default": None,
"title": "Q",
}, },
"name": "q", "name": "q",
"in": "query", "in": "query",
@ -119,7 +121,9 @@ def test_openapi_schema(client: TestClient):
"anyOf": [ "anyOf": [
{"$ref": "#/components/schemas/Item"}, {"$ref": "#/components/schemas/Item"},
{"type": "null"}, {"type": "null"},
], "default": None, "title": "Item", ],
"default": None,
"title": "Item",
} }
} }
} }

4
tests/test_tutorial/test_body_multiple_params/test_tutorial004.py

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

20
tests/test_tutorial/test_cookie_param_models/test_tutorial001.py

@ -92,21 +92,31 @@ 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"}, "example": None}, "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"}], "default": None, "title": "Fatebook Tracker", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "example": None}, "default": None,
"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"}], "default": None, "title": "Googall Tracker", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "example": None}, "default": None,
"title": "Googall Tracker",
},
"example": None,
},
], ],
"responses": { "responses": {
"200": { "200": {

20
tests/test_tutorial/test_cookie_param_models/test_tutorial002.py

@ -99,7 +99,9 @@ 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"}, "example": None}, "schema": {"type": "string", "title": "Session Id"},
"example": None,
},
{ {
"name": "fatebook_tracker", "name": "fatebook_tracker",
"in": "cookie", "in": "cookie",
@ -108,15 +110,23 @@ def test_openapi_schema(client: TestClient):
"anyOf": [ "anyOf": [
{"type": "string"}, {"type": "string"},
{"type": "null"}, {"type": "null"},
], "default": None, "title": "Fatebook Tracker", ],
}, "example": None}, "default": None,
"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"}], "default": None, "title": "Googall Tracker", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "example": None}, "default": None,
"title": "Googall Tracker",
},
"example": None,
},
], ],
"responses": { "responses": {
"200": { "200": {

4
tests/test_tutorial/test_cookie_params/test_tutorial001.py

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

8
tests/test_tutorial/test_dependencies/test_tutorial001_tutorial001_02.py

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

4
tests/test_tutorial/test_dependencies/test_tutorial002_tutorial003_tutorial004.py

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

8
tests/test_tutorial/test_dependencies/test_tutorial005.py

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

28
tests/test_tutorial/test_header_param_models/test_tutorial001.py

@ -111,26 +111,38 @@ def test_openapi_schema(client: TestClient):
"name": "host", "name": "host",
"in": "header", "in": "header",
"required": True, "required": True,
"schema": {"type": "string", "title": "Host"}, "example": None}, "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"}, "example": None}, "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"}], "default": None, "title": "If Modified Since", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "example": None}, "default": None,
"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"}], "default": None, "title": "Traceparent", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "example": None}, "default": None,
"title": "Traceparent",
},
"example": None,
},
{ {
"name": "x-tag", "name": "x-tag",
"in": "header", "in": "header",
@ -140,7 +152,9 @@ def test_openapi_schema(client: TestClient):
"items": {"type": "string"}, "items": {"type": "string"},
"default": [], "default": [],
"title": "X Tag", "title": "X Tag",
}, "example": None}, },
"example": None,
},
], ],
"responses": { "responses": {
"200": { "200": {

28
tests/test_tutorial/test_header_param_models/test_tutorial002.py

@ -108,26 +108,38 @@ def test_openapi_schema(client: TestClient):
"name": "host", "name": "host",
"in": "header", "in": "header",
"required": True, "required": True,
"schema": {"type": "string", "title": "Host"}, "example": None}, "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"}, "example": None}, "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"}], "default": None, "title": "If Modified Since", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "example": None}, "default": None,
"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"}], "default": None, "title": "Traceparent", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "example": None}, "default": None,
"title": "Traceparent",
},
"example": None,
},
{ {
"name": "x-tag", "name": "x-tag",
"in": "header", "in": "header",
@ -137,7 +149,9 @@ def test_openapi_schema(client: TestClient):
"items": {"type": "string"}, "items": {"type": "string"},
"default": [], "default": [],
"title": "X Tag", "title": "X Tag",
}, "example": None}, },
"example": None,
},
], ],
"responses": { "responses": {
"200": { "200": {

28
tests/test_tutorial/test_header_param_models/test_tutorial003.py

@ -148,26 +148,38 @@ def test_openapi_schema(client: TestClient):
"name": "host", "name": "host",
"in": "header", "in": "header",
"required": True, "required": True,
"schema": {"type": "string", "title": "Host"}, "example": None}, "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"}, "example": None}, "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"}], "default": None, "title": "If Modified Since", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "example": None}, "default": None,
"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"}], "default": None, "title": "Traceparent", "anyOf": [{"type": "string"}, {"type": "null"}],
}, "example": None}, "default": None,
"title": "Traceparent",
},
"example": None,
},
{ {
"name": "x_tag", "name": "x_tag",
"in": "header", "in": "header",
@ -177,7 +189,9 @@ def test_openapi_schema(client: TestClient):
"items": {"type": "string"}, "items": {"type": "string"},
"default": [], "default": [],
"title": "X Tag", "title": "X Tag",
}, "example": None}, },
"example": None,
},
], ],
"responses": { "responses": {
"200": { "200": {

4
tests/test_tutorial/test_header_params/test_tutorial001.py

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

4
tests/test_tutorial/test_header_params/test_tutorial002.py

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

4
tests/test_tutorial/test_header_params/test_tutorial003.py

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

4
tests/test_tutorial/test_openapi_callbacks/test_tutorial001.py

@ -78,7 +78,9 @@ And this path operation will:
"maxLength": 2083, "maxLength": 2083,
}, },
{"type": "null"}, {"type": "null"},
], "default": None, "title": "Callback Url", ],
"default": None,
"title": "Callback Url",
}, },
"name": "callback_url", "name": "callback_url",
"in": "query", "in": "query",

4
tests/test_tutorial/test_path_params_numeric_validations/test_tutorial001.py

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

16
tests/test_tutorial/test_query_param_models/test_tutorial001.py

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

16
tests/test_tutorial/test_query_param_models/test_tutorial002.py

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

4
tests/test_tutorial/test_query_params/test_tutorial002.py

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

4
tests/test_tutorial/test_query_params/test_tutorial003.py

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

4
tests/test_tutorial/test_query_params/test_tutorial004.py

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

4
tests/test_tutorial/test_query_params/test_tutorial006.py

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

4
tests/test_tutorial/test_query_params_str_validations/test_tutorial001.py

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

4
tests/test_tutorial/test_query_params_str_validations/test_tutorial002.py

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

4
tests/test_tutorial/test_query_params_str_validations/test_tutorial003.py

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

4
tests/test_tutorial/test_query_params_str_validations/test_tutorial004.py

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

4
tests/test_tutorial/test_query_params_str_validations/test_tutorial007.py

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

4
tests/test_tutorial/test_query_params_str_validations/test_tutorial008.py

@ -95,7 +95,9 @@ 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", "default": None}, "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",
} }

4
tests/test_tutorial/test_query_params_str_validations/test_tutorial009.py

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

4
tests/test_tutorial/test_query_params_str_validations/test_tutorial011.py

@ -72,7 +72,9 @@ 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", ],
"default": None,
"title": "Q",
}, },
"name": "q", "name": "q",
"in": "query", "in": "query",

4
tests/test_tutorial/test_query_params_str_validations/test_tutorial015.py

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

4
tests/test_tutorial/test_server_sent_events/test_tutorial004.py

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

Loading…
Cancel
Save