|
|
@ -193,6 +193,7 @@ def get_openapi_path( |
|
|
|
*, route: routing.APIRoute, model_name_map: Dict[type, str], operation_ids: Set[str] |
|
|
|
) -> Tuple[Dict[str, Any], Dict[str, Any], Dict[str, Any]]: |
|
|
|
path = {} |
|
|
|
empty_responses: List[int] = [] |
|
|
|
security_schemes: Dict[str, Any] = {} |
|
|
|
definitions: Dict[str, Any] = {} |
|
|
|
assert route.methods is not None, "Methods must be a list" |
|
|
@ -296,7 +297,7 @@ def get_openapi_path( |
|
|
|
additional_response, |
|
|
|
) in route.responses.items(): |
|
|
|
process_response = additional_response.copy() |
|
|
|
process_response.pop("model", None) |
|
|
|
process_rseponse_model = process_response.pop("model", None) |
|
|
|
status_code_key = str(additional_status_code).upper() |
|
|
|
if status_code_key == "DEFAULT": |
|
|
|
status_code_key = "default" |
|
|
@ -306,6 +307,8 @@ def get_openapi_path( |
|
|
|
assert isinstance( |
|
|
|
process_response, dict |
|
|
|
), "An additional response must be a dict" |
|
|
|
if not process_response and not process_rseponse_model: |
|
|
|
empty_responses.append(additional_status_code) |
|
|
|
field = route.response_fields.get(additional_status_code) |
|
|
|
additional_field_schema: Optional[Dict[str, Any]] = None |
|
|
|
if field: |
|
|
@ -354,6 +357,9 @@ def get_openapi_path( |
|
|
|
) |
|
|
|
if route.openapi_extra: |
|
|
|
deep_dict_update(operation, route.openapi_extra) |
|
|
|
if empty_responses: |
|
|
|
for response_status_code in empty_responses: |
|
|
|
del operation["responses"][str(response_status_code)] |
|
|
|
path[method.lower()] = operation |
|
|
|
return path, security_schemes, definitions |
|
|
|
|
|
|
|