pypi fastapi 0.89.0

latest releases: 0.115.5, 0.115.4, 0.115.3...
22 months ago

Features

  • ✨ Add support for function return type annotations to declare the response_model. Initial PR #1436 by @uriyyo.

Now you can declare the return type / response_model in the function return type annotation:

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()


class Item(BaseModel):
    name: str
    price: float


@app.get("/items/")
async def read_items() -> list[Item]:
    return [
        Item(name="Portal Gun", price=42.0),
        Item(name="Plumbus", price=32.0),
    ]

FastAPI will use the return type annotation to perform:

  • Data validation
  • Automatic documentation
    • It could power automatic client generators
  • Data filtering

Before this version it was only supported via the response_model parameter.

Read more about it in the new docs: Response Model - Return Type.

Docs

Translations

  • 🌐 Add Russian translation for docs/ru/docs/fastapi-people.md. PR #5577 by @Xewus.
  • 🌐 Fix typo in Chinese translation for docs/zh/docs/benchmarks.md. PR #4269 by @15027668g.
  • 🌐 Add Korean translation for docs/tutorial/cors.md. PR #3764 by @NinaHwang.

Internal

Don't miss a new fastapi release

NewReleases is sending notifications on new releases.