First check
Example
Here's a self-contained, minimal, reproducible, example with my use case:
import uvicorn
from pydantic import BaseModel
from fastapi import FastAPI
class Item(BaseModel):
name: str
description: str
app = FastAPI()
@app.get("/items")
def create_item(item: Item):
return item
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=5000, debug=True)
You can run and test the above code with this CURL request:
curl -X GET \
http://localhost:5000/items \
-d '{
"name": "test",
"description": "tester"
}
'
Description
FastAPI's documentation seems to suggest that GET requests with a body aren't supported: https://fastapi.tiangolo.com/tutorial/body/
However, running the above example it looks like this is supported, although the auto generated documentation misses documenting the parameters of the body.
Can this be supported in FastAPI? Our use case is that we need to support a GET method that could contain a sizable amount of data in the request. We don't really want to make this a POST method as the endpoint is only for retrieval and isn't modifying any data. Everything appears to be working for us except the auto generated documentation.
Environment
- OS: [e.g. Linux / Windows / macOS]: Windows
- FastAPI Version [e.g. 0.3.0]: 0.54.1
- Python Version: 3.8.2
First check
Example
Here's a self-contained, minimal, reproducible, example with my use case:
You can run and test the above code with this CURL request:
Description
FastAPI's documentation seems to suggest that GET requests with a body aren't supported: https://fastapi.tiangolo.com/tutorial/body/
However, running the above example it looks like this is supported, although the auto generated documentation misses documenting the parameters of the body.
Can this be supported in FastAPI? Our use case is that we need to support a GET method that could contain a sizable amount of data in the request. We don't really want to make this a POST method as the endpoint is only for retrieval and isn't modifying any data. Everything appears to be working for us except the auto generated documentation.
Environment