fastapi
♻️ Return status_code 409 when item already exists
#11504
Closed

♻️ Return status_code 409 when item already exists #11504

hongjiaherng wants to merge 3 commits into fastapi:master from hongjiaherng:docs-typo-fix
hongjiaherng
hongjiaherng1 year ago

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
hongjiaherng Fix typo: return status_code 409 when item already exists
c9d15a29
tiangolo
tiangolo1 year ago👍 1

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

hongjiaherng Merge branch 'master' into docs-typo-fix
b2a88e3d
tiangolo
tiangolo1 year ago

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

alejsdev alejsdev added refactor
alejsdev alejsdev changed the title Fix typo: return status_code 409 when item already exists ♻️ Return status_code 409 when item already exists 1 year ago
Kludex
Kludex approved these changes on 2024-07-13
tiangolo Merge branch 'master' into docs-typo-fix
fe9c0b16
tiangolo tiangolo removed refactor
tiangolo tiangolo added docs
tiangolo
tiangolo276 days ago

Thanks @hongjiaherng! This was covered in another PR, so I'll close this one, but thanks for the effort! ☕

tiangolo tiangolo closed this 276 days ago

Login to write a write a comment.

Login via GitHub

Reviewers
Assignees
No one assigned
Labels
Milestone