diff --git a/fastapi/openapi/utils.py b/fastapi/openapi/utils.py index 947eca948..6489441d8 100644 --- a/fastapi/openapi/utils.py +++ b/fastapi/openapi/utils.py @@ -345,11 +345,15 @@ def get_openapi_path( ) else: response_schema = {} - operation.setdefault("responses", {}).setdefault( - status_code, {} - ).setdefault("content", {}).setdefault(route_response_media_type, {})[ - "schema" - ] = response_schema + + route_responses = dict((str(k), v) for k, v in route.responses.items()) + if status_code not in route_responses or not route_responses.get(status_code).get('superimpose'): + operation.setdefault("responses", {}).setdefault( + status_code, {} + ).setdefault("content", {}).setdefault(route_response_media_type, {})[ + "schema" + ] = response_schema + if route.responses: operation_responses = operation.setdefault("responses", {}) for ( @@ -358,6 +362,7 @@ def get_openapi_path( ) in route.responses.items(): process_response = additional_response.copy() process_response.pop("model", None) + process_response.pop("superimpose", None) status_code_key = str(additional_status_code).upper() if status_code_key == "DEFAULT": status_code_key = "default"