mirror of
https://github.com/fastapi/fastapi.git
synced 2025-12-31 10:10:51 -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
24 lines
617 B
Python
24 lines
617 B
Python
from fastapi import Depends, FastAPI
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}]
|
|
|
|
|
|
class CommonQueryParams:
|
|
def __init__(self, q: str = None, skip: int = 0, limit: int = 100):
|
|
self.q = q
|
|
self.skip = skip
|
|
self.limit = limit
|
|
|
|
|
|
@app.get("/items/")
|
|
async def read_items(commons: CommonQueryParams = Depends(CommonQueryParams)):
|
|
response = {}
|
|
if commons.q:
|
|
response.update({"q": commons.q})
|
|
items = fake_items_db[commons.skip : commons.skip + commons.limit]
|
|
response.update({"items": items})
|
|
return response
|