Skip to content
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

♻️ Return status_code 409 when item already exists #11504

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hongjiaherng
Copy link

Typo in docs:

Correct references:

Code snapshot:

@app.post("/items/", response_model=Item)
async def create_item(item: Item, x_token: Annotated[str, Header()]):
    if x_token != fake_secret_token:
        raise HTTPException(status_code=400, detail="Invalid X-Token header")
    if item.id in fake_db:
        raise HTTPException(status_code=400, detail="Item already exists") # NOTE: This should return 409 instead
    fake_db[item.id] = item
    return item

@tiangolo
Copy link
Owner

📝 Docs preview for commit c9d15a2 at: https://4cf3287f.fastapitiangolo.pages.dev

@tiangolo
Copy link
Owner

📝 Docs preview for commit b2a88e3 at: https://f7b2513e.fastapitiangolo.pages.dev

@alejsdev alejsdev changed the title Fix typo: return status_code 409 when item already exists ♻️ Return status_code 409 when item already exists May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants