Overview

FastAPI 0.90, released on March 9, 2022, introduces a new documentation UI and improves the developer experience.

Main Features

New documentation UI

The Swagger UI is updated with a modernized design and better navigation between API endpoints.

python
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI(
    title='My API',
    description='FastAPI 0.90 demo API',
    version='0.1.0',
)

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

@app.post('/items/', response_model=Item)
async def create_item(item: Item):
    return item
# Auto docs at /docs

Developer experience improvements

Validation error messages are clearer and error responses include more context to make debugging easier.

python
from fastapi import FastAPI, HTTPException

app = FastAPI()

items_db = {'1': 'Book', '2': 'Pen'}

@app.get('/items/{item_id}')
async def read_item(item_id: str):
    if item_id not in items_db:
        raise HTTPException(
            status_code=404,
            detail=f'Item {item_id} not found',
        )
    return {'id': item_id, 'name': items_db[item_id]}

Sources