mirror of
https://github.com/fastapi/fastapi.git
synced 2026-07-19 03:13:11 -04:00
✨ Add support for adding OpenAPI schema for GET requests with a body (#1626)
* add test for get request body's openapi schema * 📝 Update docs note for GET requests with body * ✅ Update test for GET request with body, test it receives the body * 🔇 Temporary type ignore while it's handled in Pydantic Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
committed by
GitHub
parent
d60dd1b60e
commit
2b47f3e56b
@@ -9,9 +9,11 @@ Your API almost always has to send a **response** body. But clients don't necess
|
||||
To declare a **request** body, you use <a href="https://pydantic-docs.helpmanual.io/" class="external-link" target="_blank">Pydantic</a> models with all their power and benefits.
|
||||
|
||||
!!! info
|
||||
You cannot send a request body using a `GET` operation (HTTP method).
|
||||
To send data, you should use one of: `POST` (the more common), `PUT`, `DELETE` or `PATCH`.
|
||||
|
||||
To send data, you have to use one of: `POST` (the more common), `PUT`, `DELETE` or `PATCH`.
|
||||
Sending a body with a `GET` request has an undefined behavior in the specifications, nevertheless, it is supported by FastAPI, only for very complex/extreme use cases.
|
||||
|
||||
As it is discouraged, the interactive docs with Swagger UI won't show the documentation for the body when using `GET`, and proxies in the middle might not support it.
|
||||
|
||||
## Import Pydantic's `BaseModel`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user