Browse Source

🎨 [pre-commit.ci] Auto format from pre-commit.com hooks

pull/4042/head
pre-commit-ci[bot] 3 days ago
parent
commit
a71bc2cecc
  1. 2
      fastapi/openapi/models.py
  2. 12
      fastapi/openapi/utils.py

2
fastapi/openapi/models.py

@ -227,11 +227,13 @@ class Example(TypedDict, total=False):
class Config:
extra = "allow"
class DefaultErrorSchema(BaseModel):
status: int
description: Optional[str] = None
model: BaseModel
class ParameterInType(Enum):
query = "query"
header = "header"

12
fastapi/openapi/utils.py

@ -419,14 +419,16 @@ def get_openapi_path(
openapi_response["description"] = description
http422 = str(HTTP_422_UNPROCESSABLE_ENTITY)
all_route_params = get_flat_params(route.dependant)
if(default_error_schema is not None):
if default_error_schema is not None:
operation["responses"][default_error_schema["status"]] = {
"description": default_error_schema["description"],
"content": {
"application/json": {
"schema": {"$ref": REF_PREFIX + default_error_schema["name"] }
"schema": {
"$ref": REF_PREFIX + default_error_schema["name"]
}
},
}
},
}
definitions.update(
{
@ -434,7 +436,7 @@ def get_openapi_path(
"title": default_error_schema["name"],
"type": "object",
"properties": default_error_schema["properties"],
"required": default_error_schema["required"]
"required": default_error_schema["required"],
}
}
)
@ -547,7 +549,7 @@ def get_openapi(
model_name_map=model_name_map,
field_mapping=field_mapping,
separate_input_output_schemas=separate_input_output_schemas,
default_error_schema=default_error_schema
default_error_schema=default_error_schema,
)
if result:
path, security_schemes, path_definitions = result

Loading…
Cancel
Save