mirror of https://github.com/tiangolo/fastapi.git
Create response field with proper mode
Which should be "serialization" also for custom response models defined in the `responses` option. The same way we do that for the "main" response model on line 475. This fixes issue 1. mentioned in https://github.com/tiangolo/fastapi/discussions/10697
This commit is contained in:
parent
5cdecf2e7c
commit
f1eace7523
|
|
@ -502,7 +502,11 @@ class APIRoute(routing.Route):
|
|||
additional_status_code
|
||||
), f"Status code {additional_status_code} must not have a response body"
|
||||
response_name = f"Response_{additional_status_code}_{self.unique_id}"
|
||||
response_field = create_response_field(name=response_name, type_=model)
|
||||
response_field = create_response_field(
|
||||
name=response_name,
|
||||
type_=model,
|
||||
mode="serialization",
|
||||
)
|
||||
response_fields[additional_status_code] = response_field
|
||||
if response_fields:
|
||||
self.response_fields: Dict[Union[int, str], ModelField] = response_fields
|
||||
|
|
|
|||
Loading…
Reference in New Issue