@@ -139,7 +139,7 @@ def _handle_response(self, *, route: Route, response: Response):
139139 # Check if we have a return type defined
140140 if route .dependant .return_param :
141141 try :
142- # Validate all responses , including None
142+ # Validate and serialize the response , including None
143143 response .body = self ._serialize_response (
144144 field = route .dependant .return_param ,
145145 response_content = response .body ,
@@ -154,15 +154,18 @@ def _handle_response(self, *, route: Route, response: Response):
154154 def _serialize_response (
155155 self ,
156156 * ,
157- field : Any = None ,
157+ field : ModelField | None = None ,
158158 response_content : Any ,
159159 include : IncEx | None = None ,
160160 exclude : IncEx | None = None ,
161- by_alias : bool = False ,
161+ by_alias : bool = True ,
162162 exclude_unset : bool = False ,
163163 exclude_defaults : bool = False ,
164164 exclude_none : bool = False ,
165165 ) -> Any :
166+ """
167+ Serialize the response content according to the field type.
168+ """
166169 if field :
167170 errors : list [dict [str , Any ]] = []
168171 value = _validate_field (field = field , value = response_content , loc = ("response" ,), existing_errors = errors )
0 commit comments