Changelogs » Fastapi



* Fix handling of enums with their own schema in path parameters. To support [samuelcolvin/pydantic1432]( in FastAPI. PR [1463](


* Allow enums to allow them to have their own schemas in OpenAPI. To support [samuelcolvin/pydantic1432]( in FastAPI. PR [1461](
* Add links for funding through [GitHub sponsors]( PR [1425](
* Update issue template for for questions. PR [1344]( by [retnikt](
* Update warning about storing passwords in docs. PR [1336]( by [skorokithakis](
* Fix typo. PR [1326]( by [chenl](
* Add translation to Portuguese for [Alternatives, Inspiration and Comparisons - Alternativas, Inspiração e Comparações]( PR [1325]( by [Serrones](
* Fix 2 typos in docs. PR [1324]( by [waynerv](
* Update CORS docs, fix correct default of `max_age=600`. PR [1301]( by [derekbekoe](
* Add translation of [main page to Portuguese]( PR [1300]( by [Serrones](
* Re-word and clarify docs for extra info in fields. PR [1299]( by [chris-allnutt](
* Make sure the `*` in short features in the docs is consistent (after `.`) in all languages. PR [1424](
* Update order of execution for `get_db` in SQLAlchemy tutorial. PR [1293]( by [bcb](
* Fix typos in Async docs. PR [1423](


* Add translation to Spanish for [Concurrency and async / await - Concurrencia y async / await]( PR [1290]( by [alvaropernas](
* Remove obsolete vote link. PR [1289]( by [donhui](
* Allow disabling docs UIs by just disabling OpenAPI with `openapi_url=None`. New example in docs: [Advanced: Conditional OpenAPI]( PR [1421](
* Add translation to Portuguese for [Benchmarks - Comparações]( PR [1274]( by [Serrones](
* Add translation to Portuguese for [Tutorial - User Guide - Intro - Tutorial - Guia de Usuário - Introdução]( PR [1259]( by [marcosmmb](
* Allow using Unicode in MkDocs for translations. PR [1419](
* Add translation to Spanish for [Advanced User Guide - Intro - Guía de Usuario Avanzada - Introducción]( PR [1250]( by [jfunez](
* Add translation to Portuguese for [History, Design and Future - História, Design e Futuro]( PR [1249]( by [marcosmmb](
* Add translation to Portuguese for [Features - Recursos]( PR [1248]( by [marcosmmb](
* Add translation to Spanish for [Tutorial - User Guide - Intro - Tutorial - Guía de Usuario - Introducción]( PR [1244]( by [MartinEliasQ](
* Add translation to Chinese for [Deployment - 部署]( PR [1203]( by [RunningIkkyu](
* Add translation to Chinese for [Tutorial - User Guide - Intro - 教程 - 用户指南 - 简介]( PR [1202]( by [waynerv](
* Add translation to Chinese for [Features - 特性]( PR [1192]( by [Dustyposa](
* Add translation for [main page to Chinese]( PR [1191]( by [waynerv](
* Update docs for project generation. PR [1287](
* Add Spanish translation for [Introducción a los Tipos de Python (Python Types Intro)]( PR [1237]( by [mariacamilagl](
* Add Spanish translation for [Características (Features)]( PR [1220]( by [mariacamilagl](


* Update database test setup. PR [1226](
* Improve test debugging by showing response text in failing tests. PR [1222]( by [samuelcolvin](


* Fix grammatical mistakes in async docs. PR [1188]( by [mickeypash](
* Add support for `response_model_exclude_defaults` and `response_model_exclude_none`:
* Deprecate the parameter `include_none` in `jsonable_encoder` and add the inverted `exclude_none`, to keep in sync with Pydantic.
* PR [1166]( by [voegtlel](
* Add example about [Testing a Database]( Initial PR [1144]( by [duganchen](
* Update docs for [Development - Contributing: Translations]( including note about reviewing translation PRs. [1215](
* Update log style in for GitHub Markdown compatibility. PR [1200]( by [geekgao](
* Add Python venv `env` to `.gitignore`. PR [1212]( by [cassiobotaro](
* Start Portuguese translations. PR [1210]( by [cassiobotaro](
* Update docs for Pydantic's `Settings` using a dependency with `lru_cache()`. PR [1214](
* Add first translation to Spanish [FastAPI]( PR [1201]( by [mariacamilagl](
* Add docs about [Settings and Environment Variables]( Initial PR [1118]( by [alexmitelman](


* Fix automatic embedding of body fields for dependencies and sub-dependencies. Original PR [1079]( by [Toad2186](
* Fix dependency overrides in WebSocket testing. PR [1122]( by [amitlissack](
* Fix docs script to ensure languages are always sorted. PR [1189](
* Start translations for Chinese. PR [1187]( by [RunningIkkyu](
* Add docs for [Schema Extra - Example]( PR [1185](


* Fix included example after translations refactor. PR [1182](
* Add docs example for `example` in `Field`. Docs at [Body - Fields: JSON Schema extras]( PR [1106]( by [JohnPaton](
* Fix using recursive models in `response_model`. PR [1164]( by [voegtlel](
* Add docs for [Pycharm Debugging]( PR [1096]( by [youngquan](
* Fix typo in docs. PR [1148]( by [PLNech](
* Update Windows development environment instructions. PR [1179](


* Update test coverage badge. PR [1175](
* Add `orjson` to `pip install fastapi[all]`. PR [1161]( by [michael0liver](
* Fix included example for `GZipMiddleware`. PR [1138]( by [arimbr](
* Fix class name in docstring for `OAuth2PasswordRequestFormStrict`. PR [1126]( by [adg-mh](
* Clarify function name in example in docs. PR [1121]( by [tmsick](
* Add external link [Apache Kafka producer and consumer with FastAPI and aiokafka]( to docs. PR [1112]( by [iwpnd](
* Fix serialization when using `by_alias` or `exclude_unset` and returning data with Pydantic models. PR [1074]( by [juhovh-aiven](
* Add Gitter chat to docs. PR [1061]( by [aakashnand](
* Update and simplify translations docs. PR [1171](
* Update development of FastAPI docs, set address to `` to improve Windows support. PR [1169]( by [mariacamilagl](
* Add support for docs translations. New docs: [Development - Contributing: Docs: Translations]( PR [1168](
* Update terminal styles in docs and add note about [**Typer**, the FastAPI of CLIs]( PR [1139](


* Add new high-performance JSON response class using `orjson`. New docs: [Custom Response - HTML, Stream, File, others: `ORJSONResponse`]( PR [1065](


* Re-export utils from Starlette:
* This allows using things like `from fastapi.responses import JSONResponse` instead of `from starlette.responses import JSONResponse`.
* It's mainly syntax sugar, a convenience for developer experience.
* Now `Request`, `Response`, `WebSocket`, `status` can be imported directly from `fastapi` as in `from fastapi import Response`. This is because those are frequently used, to use the request directly, to set headers and cookies, to get status codes, etc.
* Documentation changes in many places, but new docs and noticeable improvements:
* [Custom Response - HTML, Stream, File, others](
* [Advanced Middleware](
* [Including WSGI - Flask, Django, others](
* PR [1064](


* Add link to Release Notes from docs about pinning versions for deployment. PR [1058](
* Upgrade code to use the latest version of Starlette, including:
* Several bug fixes.
* Optional redirects of slashes, with or without ending in `/`.
* Events for routers, `"startup"`, and `"shutdown"`.
* PR [1057](
* Add docs about pinning FastAPI versions for deployment: [Deployment: FastAPI versions]( PR [1056](


* Fix links in release notes. PR [1052]( by [sattosan](
* Fix typo in release notes. PR [1051]( by [sattosan](
* Refactor/clarify `serialize_response` parameter name to avoid confusion. PR [1031]( by [patrickmckenna](
* Refactor calling each a path operation's handler function in an isolated function, to simplify profiling. PR [1027]( by [sm-Fifteen](
* Add missing dependencies for testing. PR [1026]( by [sm-Fifteen](
* Fix accepting valid types for response models, including Python types like `List[int]`. PR [1017]( by [patrickmckenna](
* Fix format in SQL tutorial. PR [1015]( by [vegarsti](


* Fix path operation duplicated parameters when used in dependencies and the path operation function. PR [994]( by [merowinger92](
* Update Netlify previews deployment GitHub action as the fix is already merged and there's a new release. PR [1047](
* Move mypy configurations to config file. PR [987]( by [hukkinj1](
* Temporary fix to Netlify previews not deployable from PRs from forks. PR [1046]( by [mariacamilagl](


* Fix encoding of `pathlib` paths in `jsonable_encoder`. PR [978]( by [patrickmckenna](
* Add articles to [External Links]( [PythonのWeb frameworkのパフォーマンス比較 (Django, Flask, responder, FastAPI, japronto)]( and [[FastAPI] Python製のASGI Web フレームワーク FastAPIに入門する]( PR [974]( by [tokusumi](
* Fix broken links in docs. PR [949]( by [tsotnikov](
* Fix small typos. PR [941]( by [NikitaKolesov](
* Update and clarify docs for dependencies with `yield`. PR [986](
* Add Mermaid JS support for diagrams in docs. Add first diagrams to [Dependencies: First Steps]( and [Dependencies with `yield` and `HTTPException`]( PR [985](
* Update CI to run docs deployment in GitHub actions. PR [983](
* Allow `callable`s in *path operation functions*, like functions modified with `functools.partial`. PR [977](


* Run linters first in tests to error out faster. PR [948](
* Log warning about `email-validator` only when used. PR [946](
* Simplify [Peewee docs]( with double dependency with `yield`. PR [947](
* Add article [External Links]( [Create and Deploy FastAPI app to Heroku]( PR [942]( by [windson](
* Update description of Sanic, as it is now ASGI too. PR [932]( by [raphaelauv](
* Fix typo in main page. PR [920]( by [mMarzeta](
* Fix parsing of possibly invalid bodies. PR [918]( by [dmontagu](
* Fix typo [916]( by [adursun](
* Allow `Any` type for enums in OpenAPI. PR [906]( by [songzhi](
* Add article to [External Links]( [How to continuously deploy a FastAPI to AWS Lambda with AWS SAM]( PR [901]( by [iwpnd](
* Add note about using Body parameters without Pydantic. PR [900]( by [pawamoy](
* Fix Pydantic field clone logic. PR [899]( by [deuce2367](
* Fix link in middleware docs. PR [893]( by [linchiwei123](
* Rename default API title from "Fast API" to "FastAPI" for consistency. PR [890](


* Fix model filtering in `response_model`, cloning sub-models. PR [889](
* Fix FastAPI serialization of Pydantic models using ORM mode blocking the event loop. PR [888](


* Refactor documentation to make a simpler and shorter [Tutorial - User Guide]( and an additional [Advanced User Guide]( with all the additional docs. PR [887](
* Tweak external links, Markdown format, typos. PR [881](
* Fix bug in tutorial handling HTTP Basic Auth `username` and `password`. PR [865]( by [isaevpd](
* Fix handling form *path operation* parameters declared with pure classes like `list`, `tuple`, etc. PR [856]( by [nsidnev](
* Add request `body` to `RequestValidationError`, new docs: [Use the `RequestValidationError` body]( Initial PR [853]( by [aviramha](
* Update [External Links]( with new links and dynamic GitHub projects with `fastapi` topic. PR [850](
* Fix Peewee `contextvars` handling in docs: [SQL (Relational) Databases with Peewee]( PR [879](
* Setup development environment with Python's Venv and Flit, instead of requiring the extra Pipenv duplicating dependencies. Updated docs: [Development - Contributing]( PR [877](
* Update docs for [HTTP Basic Auth]( to improve security against timing attacks. Initial PR [807]( by [zwass](


* Fix typos and tweak configs. PR [837](
* Add link to Chinese article in [External Links]( PR [810]( by [wxq0309](
* Implement `OAuth2AuthorizationCodeBearer` class. PR [797]( by [kuwv](
* Update example upgrade in docs main page. PR [795]( by [cdeil](
* Fix callback handling for sub-routers. PR [792]( by [jekirl](
* Fix typos. PR [784]( by [kkinder](
* Add 4 Japanese articles to [External Links]( PR [783]( by [HymanZHAN](
* Add support for subtypes of main types in `jsonable_encoder`, e.g. asyncpg's UUIDs. PR [756]( by [RmStorm](
* Fix usage of Pydantic's `HttpUrl` in docs. PR [832]( by [Dustyposa](
* Fix Twitter links in docs. PR [813]( by [justindujardin](
* Add docs for correctly [using FastAPI with Peewee ORM]( Including how to overwrite parts of Peewee to correctly handle async threads. PR [789](


* Add support for OpenAPI Callbacks:
* New docs: [OpenAPI Callbacks](
* Refactor generation of `operationId`s to be valid Python names (also valid variables in most languages).
* Add `default_response_class` parameter to `APIRouter`.
* Original PR [722]( by [booooh](
* Refactor logging to use the same logger everywhere, update log strings and levels. PR [781](
* Add article to [External Links]( [Почему Вы должны попробовать FastAPI?]( PR [766]( by [prostomarkeloff](
* Remove gender bias in docs for handling errors. PR [780]( Original idea in PR [761]( by [classywhetten](
* Rename docs and references to `body-schema` to `body-fields` to keep in line with Pydantic. PR [746]( by [prostomarkeloff](


* Add GitHub social preview images to git. PR [752](
* Update PyPI "trove classifiers". PR [751](
* Add full support for Python 3.8. Enable Python 3.8 in full in Travis. PR [749](
* Update "new issue" templates. PR [749](
* Fix serialization of errors for exotic Pydantic types. PR [748]( by [dmontagu](


* Add GitHub action [Issue Manager]( PR [742](
* Fix typos in docs. PR [734]( by [bundabrg](
* Fix usage of `custom_encoder` in `jsonable_encoder`. PR [715]( by [matrixise](
* Fix invalid XML example. PR [710]( by [OcasoProtal](
* Fix typos and update wording in deployment docs. PR [700]( by [marier-nico](
* Add note about dependencies in `APIRouter` docs. PR [698]( by [marier-nico](
* Add support for async class methods as dependencies [681]( by [frankie567](
* Add FastAPI with Swagger UI cheatsheet to external links. PR [671]( by [euri10](
* Fix typo in HTTP protocol in CORS example. PR [647]( by [forestmonster](
* Add support for Pydantic versions `1.0.0` and above, with temporary (deprecated) backwards compatibility for Pydantic `0.32.2`. PR [646]( by [dmontagu](


* Update docs to reduce gender bias. PR [645]( by [ticosax](
* Add docs about [overriding the `operationId` for all the *path operations*]( based on their function name. PR [642]( by [SKalt](
* Fix validators in models generating an incorrect key order. PR [637]( by [jaddison](
* Generate correct OpenAPI docs for responses with no content. PR [621]( by [brotskydotcom](
* Remove `$` from Bash code blocks in docs for consistency. PR [613]( by [nstapelbroek](
* Add docs for [self-serving docs' (Swagger UI) static assets](, e.g. to use the docs offline, or without Internet. Initial PR [557]( by [svalouch](
* Fix `black` linting after upgrade. PR [682]( by [frankie567](


* Add dependencies with `yield`, a.k.a. exit steps, context managers, cleanup, teardown, ...
* This allows adding extra code after a dependency is done. It can be used, for example, to close database connections.
* Dependencies with `yield` can be normal or `async`, **FastAPI** will run normal dependencies in a threadpool.
* They can be combined with normal dependencies.
* It's possible to have arbitrary trees/levels of dependencies with `yield` and exit steps are handled in the correct order automatically.
* It works by default in Python 3.7 or above. For Python 3.6, it requires the extra backport dependencies:
* `async-exit-stack`
* `async-generator`
* New docs at [Dependencies with `yield`](
* Updated database docs [SQL (Relational) Databases: Main **FastAPI** app](
* PR [595](
* Fix `sitemap.xml` in website. PR [598]( by [samuelcolvin](


* Upgrade required Starlette to `0.12.9`, the new range is `>=0.12.9,<=0.12.9`.
* Add `State` to FastAPI apps at `app.state`.
* PR [593](
* Improve handling of custom classes for `Request`s and `APIRoute`s.
* This helps to more easily solve use cases like:
* Reading a body before and/or after a request (equivalent to a middleware).
* Run middleware-like code only for a subset of *path operations*.
* Process a request before passing it to a *path operation function*. E.g. decompressing, deserializing, etc.
* Processing a response after being generated by *path operation functions* but before returning it. E.g. adding custom headers, logging, adding extra metadata.
* New docs section: [Custom Request and APIRoute class](
* PR [589]( by [dmontagu](
* Fix preserving custom route class in routers when including other sub-routers. PR [538]( by [dmontagu](


* Add notes to docs about installing `python-multipart` when using forms. PR [574]( by [sliptonic](
* Generate OpenAPI schemas in alphabetical order. PR [554]( by [dmontagu](
* Add support for truncating docstrings from *path operation functions*.
* New docs at [Advanced description from docstring](
* PR [556]( by [svalouch](
* Fix `DOCTYPE` in HTML files generated for Swagger UI and ReDoc. PR [537]( by [Trim21](
* Fix handling `4XX` responses overriding default `422` validation error responses. PR [517]( by [tsouvarev](
* Fix typo in documentation for [Simple HTTP Basic Auth]( PR [514]( by [prostomarkeloff](
* Fix incorrect documentation example in [first steps]( PR [511]( by [IgnatovFedor](
* Add support for Swagger UI [initOauth]( settings with the parameter `swagger_ui_init_oauth`. PR [499]( by [zamiramir](


* Allow path parameters to have default values (e.g. `None`) and discard them instead of raising an error.
* This allows declaring a parameter like `user_id: str = None` that can be taken from a query parameter, but the same path operation can be included in a router with a path `/users/{user_id}`, in which case will be taken from the path and will be required.
* PR [464]( by [jonathanunderwood](
* Add support for setting a `default_response_class` in the `FastAPI` instance or in `include_router`. Initial PR [467]( by [toppk](
* Add support for type annotations using strings and `from __future__ import annotations`. PR [451]( by [dmontagu](


* Fix incorrect `Request` class import. PR [493]( by [kamalgill](


* Add recent articles to [External Links]( and recent opinions. PR [490](
* Upgrade support range for Starlette to include `0.12.8`. The new range is `>=0.11.1,<=0.12.8"`. PR [477]( by [dmontagu](
* Upgrade support to Pydantic version 0.32.2 and update internal code to use it (breaking change). PR [463]( by [dmontagu](


* Add support for custom route classes for advanced use cases. PR [468]( by [dmontagu](
* Allow disabling Google fonts in ReDoc. PR [481]( by [b1-luettje](
* Fix security issue: when returning a sub-class of a response model and using `skip_defaults` it could leak information. PR [485]( by [dmontagu](
* Enable tests for Python 3.8-dev. PR [465]( by [Jamim](
* Add support and tests for Pydantic dataclasses in `response_model`. PR [454]( by [dconathan](
* Fix typo in OAuth2 JWT tutorial. PR [447]( by [pablogamboa](
* Use the `media_type` parameter in `Body()` params to set the media type in OpenAPI for `requestBody`. PR [439]( by [divums](
* Add article [Deploying a scikit-learn model with ONNX and FastAPI]( by [](Nico Axtmann). PR [438]( by [naxty](
* Allow setting custom `422` (validation error) response/schema in OpenAPI.
* And use media type from response class instead of fixed `application/json` (the default).
* PR [437]( by [divums](
* Fix using `"default"` extra response with status codes at the same time. PR [489](
* Allow additional responses to use status code ranges (like `5XX` and `4XX`) and `"default"`. PR [435]( by [divums](

0.36.0 insecure

* Fix implementation for `skip_defaults` when returning a Pydantic model. PR [422]( by [dmontagu](
* Fix OpenAPI generation when using the same dependency in multiple places for the same *path operation*. PR [417]( by [dmontagu](
* Allow having empty paths in *path operations* used with `include_router` and a `prefix`.
* This allows having a router for `/cats` and all its *path operations*, while having one of them for `/cats`.
* Now it doesn't have to be only `/cats/` (with a trailing slash).
* To use it, declare the path in the *path operation* as the empty string (`""`).
* PR [415]( by [vitalik](
* Fix mypy error after merging PR 415. PR [462](