7373_DEFAULT_OPENAPI_RESPONSE_DESCRIPTION = "Successful Response"
7474_ROUTE_REGEX = "^{}$"
7575_JSON_DUMP_CALL = partial (json .dumps , separators = ("," , ":" ), cls = Encoder )
76+ _DEFAULT_CONTENT_TYPE = "application/json"
7677
7778ResponseEventT = TypeVar ("ResponseEventT" , bound = BaseProxyEvent )
7879ResponseT = TypeVar ("ResponseT" )
@@ -265,7 +266,7 @@ def __init__(
265266 self ,
266267 body : Any = None ,
267268 status_code : int = 200 ,
268- content_type : str = "application/json" ,
269+ content_type : str = _DEFAULT_CONTENT_TYPE ,
269270 session_attributes : dict [str , Any ] | None = None ,
270271 prompt_session_attributes : dict [str , Any ] | None = None ,
271272 knowledge_bases_configuration : list [dict [str , Any ]] | None = None ,
@@ -329,7 +330,7 @@ def is_json(self) -> bool:
329330 content_type = self .headers .get ("Content-Type" , "" )
330331 if isinstance (content_type , list ):
331332 content_type = content_type [0 ]
332- return content_type .startswith ("application/json" )
333+ return content_type .startswith (_DEFAULT_CONTENT_TYPE )
333334
334335
335336class Route :
@@ -601,7 +602,7 @@ def _get_openapi_path(
601602 operation_responses : dict [int , OpenAPIResponse ] = {
602603 422 : {
603604 "description" : "Validation Error" ,
604- "content" : {"application/json" : {"schema" : {"$ref" : f"{ COMPONENT_REF_PREFIX } HTTPValidationError" }}},
605+ "content" : {_DEFAULT_CONTENT_TYPE : {"schema" : {"$ref" : f"{ COMPONENT_REF_PREFIX } HTTPValidationError" }}},
605606 },
606607 }
607608
@@ -610,7 +611,9 @@ def _get_openapi_path(
610611 http_code = self .custom_response_validation_http_code .value
611612 operation_responses [http_code ] = {
612613 "description" : "Response Validation Error" ,
613- "content" : {"application/json" : {"schema" : {"$ref" : f"{ COMPONENT_REF_PREFIX } ResponseValidationError" }}},
614+ "content" : {
615+ _DEFAULT_CONTENT_TYPE : {"schema" : {"$ref" : f"{ COMPONENT_REF_PREFIX } ResponseValidationError" }},
616+ },
614617 }
615618 # Add model definition
616619 definitions ["ResponseValidationError" ] = response_validation_error_response_definition
@@ -623,7 +626,7 @@ def _get_openapi_path(
623626 # Case 1: there is not 'content' key
624627 if "content" not in response :
625628 response ["content" ] = {
626- "application/json" : self ._openapi_operation_return (
629+ _DEFAULT_CONTENT_TYPE : self ._openapi_operation_return (
627630 param = dependant .return_param ,
628631 model_name_map = model_name_map ,
629632 field_mapping = field_mapping ,
@@ -674,7 +677,7 @@ def _get_openapi_path(
674677 # Add the response schema to the OpenAPI 200 response
675678 operation_responses [200 ] = {
676679 "description" : self .response_description or _DEFAULT_OPENAPI_RESPONSE_DESCRIPTION ,
677- "content" : {"application/json" : response_schema },
680+ "content" : {_DEFAULT_CONTENT_TYPE : response_schema },
678681 }
679682
680683 operation ["responses" ] = operation_responses
@@ -1664,7 +1667,7 @@ def _add_resolver_response_validation_error_response_to_route(
16641667 response_validation_error_response = {
16651668 "description" : "Response Validation Error" ,
16661669 "content" : {
1667- "application/json" : {
1670+ _DEFAULT_CONTENT_TYPE : {
16681671 "schema" : {"$ref" : f"{ COMPONENT_REF_PREFIX } ResponseValidationError" },
16691672 },
16701673 },
@@ -2183,7 +2186,7 @@ def swagger_handler():
21832186 if query_params .get ("format" ) == "json" :
21842187 return Response (
21852188 status_code = 200 ,
2186- content_type = "application/json" ,
2189+ content_type = _DEFAULT_CONTENT_TYPE ,
21872190 body = escaped_spec ,
21882191 )
21892192
0 commit comments