Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to update Path and Body parameters DOC default values examples #4911

Closed
9 tasks done
akash-vns opened this issue May 15, 2022 · 2 comments
Closed
9 tasks done

Need to update Path and Body parameters DOC default values examples #4911

akash-vns opened this issue May 15, 2022 · 2 comments
Labels
question Question or problem question-migrate

Comments

@akash-vns
Copy link

akash-vns commented May 15, 2022

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google "How to X in FastAPI" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.
  • I already checked if it is not related to FastAPI but to ReDoc.

Commit to Help

  • I commit to help with one of those options 👆

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

@akash-vns akash-vns added the question Question or problem label May 15, 2022
@akash-vns akash-vns changed the title Need to update Path and Body parameters DOC default values with (default=... OR default=Required) , Document is not have update that default values is required into the Path and Body like Query Need to update Path and Body parameters DOC default values examples May 15, 2022
@aasiffaizal
Copy link

aasiffaizal commented May 16, 2022

Hi @akash-vns
I think that is because of the new release 0.78.0
... has been omitted as the default value for Path, Body, etc in the new version. Check this PR out. The PR that you have raised is reverting the docs to the older version.

@akash-vns
Copy link
Author

Okay thank you so much @aasiffaizal
will close the PR and issue ,

@tiangolo tiangolo reopened this Feb 27, 2023
Repository owner locked and limited conversation to collaborators Feb 27, 2023
@tiangolo tiangolo converted this issue into discussion #6399 Feb 27, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Question or problem question-migrate
Projects
None yet
Development

No branches or pull requests

3 participants