mirror of https://github.com/tiangolo/fastapi.git
Make the logic more explicit in validation error insertion in get_open_api_path
This commit is contained in:
parent
320e7ce8fd
commit
b88f868e50
|
|
@ -417,10 +417,12 @@ def get_openapi_path(
|
||||||
openapi_response["description"] = description
|
openapi_response["description"] = description
|
||||||
http422 = "422"
|
http422 = "422"
|
||||||
all_route_params = get_flat_params(route.dependant)
|
all_route_params = get_flat_params(route.dependant)
|
||||||
if (all_route_params or route.body_field) and not any(
|
requires_validation_error = bool(all_route_params or route.body_field)
|
||||||
status in operation["responses"]
|
has_validation_response = any(
|
||||||
for status in [http422, "4XX", "default"]
|
status in operation["responses"]
|
||||||
):
|
for status in ("422", "4XX", "default")
|
||||||
|
)
|
||||||
|
if requires_validation_error and not has_validation_response:
|
||||||
operation["responses"][http422] = {
|
operation["responses"][http422] = {
|
||||||
"description": "Validation Error",
|
"description": "Validation Error",
|
||||||
"content": {
|
"content": {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue