mirror of
https://github.com/fastapi/fastapi.git
synced 2026-03-04 06:58:42 -05:00
* 🌐 Refactor file structure to support internationalization * ✅ Update tests changed after i18n * 🔀 Merge Typer style from master * 🔧 Update MkConfig with Typer-styles * 🎨 Format mkdocs.yml with cannonical form * 🎨 Format mkdocs.yml * 🔧 Update MkDocs config * ➕ Add docs translation scripts dependencies * ✨ Add Typer scripts to handle translations * ✨ Add missing translation snippet to include * ✨ Update contributing docs, add docs for translations * 🙈 Add docs_build to gitignore * 🔧 Update scripts with new locations and docs scripts * 👷 Update docs deploy action with translations * 📝 Add note about languages not supported in the theme * ✨ Add first translation, for Spanish
25 lines
615 B
Python
25 lines
615 B
Python
from fastapi import APIRouter, HTTPException
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/")
|
|
async def read_items():
|
|
return [{"name": "Item Foo"}, {"name": "item Bar"}]
|
|
|
|
|
|
@router.get("/{item_id}")
|
|
async def read_item(item_id: str):
|
|
return {"name": "Fake Specific Item", "item_id": item_id}
|
|
|
|
|
|
@router.put(
|
|
"/{item_id}",
|
|
tags=["custom"],
|
|
responses={403: {"description": "Operation forbidden"}},
|
|
)
|
|
async def update_item(item_id: str):
|
|
if item_id != "foo":
|
|
raise HTTPException(status_code=403, detail="You can only update the item: foo")
|
|
return {"item_id": item_id, "name": "The Fighters"}
|