First Check
Commit to Help
Example Code
from typing import Union
from fastapi import Body, FastAPI, Path
from pydantic import BaseModel, Field
app = FastAPI()
class Item(BaseModel):
name: str
description: Union[str, None] = Field(
default=None, title="The description of the item", max_length=300
)
price: float = Field(gt=0, description="The price must be greater than zero")
tax: Union[float, None] = None
@app.post("/{data_id:str}")
async def index(data_id: int = Path(title="The ID of the item to get", ge=0, le=1000),
data: Item = Body(embed=True)):
if data:
print(data)
return data
Description
Hello Team,
When i try to follow the same steps that are described into the (Body-Fields Doc , and Path-params Doc )
and its give us default values are required error .
(when i try to run above code and that code gave me a default value is required error )
Document is not have update that default values is required into the Path and Body like Query
happy to raise PR for the Doc update.
Operating System
Linux
Operating System Details
No response
FastAPI Version
0.77.1
Python Version
3.8
Additional Context
No response
First Check
Commit to Help
Example Code
Description
Hello Team,
When i try to follow the same steps that are described into the (Body-Fields Doc , and Path-params Doc )
and its give us default values are required error .
(when i try to run above code and that code gave me a default value is required error )
Document is not have update that default values is required into the Path and Body like Query
happy to raise PR for the Doc update.
Operating System
Linux
Operating System Details
No response
FastAPI Version
0.77.1
Python Version
3.8
Additional Context
No response