Browse Source

Merge d695c1e521 into 6df50d40fe

pull/13650/merge
Timon 4 days ago
committed by GitHub
parent
commit
a9ba1fea6c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 14
      docs/en/docs/advanced/additional-responses.md

14
docs/en/docs/advanced/additional-responses.md

@ -191,6 +191,20 @@ But if you have specified a custom response class with `None` as its media type,
///
## Global Responses
You can also register responses at the application level.
This automatically adds the specified response models to every endpoint, without needing to define them individually.
Use the same syntax as demonstrated above.
```Python
class MyErrorModel(BaseModel):
message: str
code: str
app = FastAPI(responses={"default": {"model": MyErrorModel, "description": "Error response"}})
```
## Combining information
You can also combine response information from multiple places, including the `response_model`, `status_code`, and `responses` parameters.

Loading…
Cancel
Save