Changelog History
Page 1
-
v0.62.0 Changes
November 29, 2020๐ Features
- ๐ฑ โจ Add support for shared/top-level parameters (dependencies, tags, etc). PR #2434 by @tiangolo.
Up to now, for several options, the only way to apply them to a group of path operations was in
include_router
. That works well, but the call toapp.include_router()
orrouter.include_router()
is normally done in another file.That means that, for example, to apply authentication to all the path operations in a router it would end up being done in a different file, instead of keeping related logic together.
๐ง Setting options in
include_router
still makes sense in some cases, for example, to override or increase configurations from a third party router included in an app. But in a router that is part of a bigger application, it would probably make more sense to add those settings when creating theAPIRouter
.In
FastAPI
This allows setting the (mostly new) parameters (additionally to the already existing parameters):
default_response_class
: updated to handle defaults inAPIRouter
andinclude_router
.- ๐ฑ
dependencies
: to include โจ top-level dependencies โจ that apply to the whole application. E.g. to add global authentication. callbacks
: OpenAPI callbacks that apply to all the path operations.deprecated
: to mark all the path operations as deprecated. ๐คทinclude_in_schema
: to allow excluding all the path operations from the OpenAPI schema.responses
: OpenAPI responses that apply to all the path operations.
For example:
from fastapi import FastAPI, Dependsasync def some\_dependency(): returnapp = FastAPI(dependencies=[Depends(some\_dependency)])
In
APIRouter
This allows setting the (mostly new) parameters (additionally to the already existing parameters):
default_response_class
: updated to handle defaults inAPIRouter
andinclude_router
. For example, it's not needed to set it explicitly when creating callbacks.dependencies
: to include โจ router-level dependencies โจ that apply to all the path operations in a router. Up to now, this was only possible withinclude_router
.callbacks
: OpenAPI callbacks that apply to all the path operations in this router.deprecated
: to mark all the path operations in a router as deprecated.include_in_schema
: to allow excluding all the path operations in a router from the OpenAPI schema.responses
: OpenAPI responses that apply to all the path operations in a router.prefix
: to set the path prefix for a router. Up to now, this was only possible when callinginclude_router
.tags
: OpenAPI tags to apply to all the path operations in this router.
For example:
from fastapi import APIRouter, Dependsasync def some\_dependency(): returnrouter = APIRouter(prefix="/users", dependencies=[Depends(some\_dependency)])
In
include_router
๐ Most of these settings are now supported in
APIRouter
, which normally lives closer to the related code, so it is recommended to useAPIRouter
when possible.But
include_router
is still useful to, for example, adding options (likedependencies
,prefix
, andtags
) when including a third party router, or a generic router that is shared between several projects.This PR allows setting the (mostly new) parameters (additionally to the already existing parameters):
default_response_class
: updated to handle defaults inAPIRouter
andFastAPI
.deprecated
: to mark all the path operations in a router as deprecated in OpenAPI.include_in_schema
: to allow disabling all the path operations from showing in the OpenAPI schema.callbacks
: OpenAPI callbacks that apply to all the path operations in this router.
Note: all the previous parameters are still there, so it's still possible to declare
dependencies
ininclude_router
.๐ฅ Breaking Changes
- PR #2434 includes several improvements that shouldn't affect normal use cases, but could affect in advanced scenarios:
- If you are testing the generated OpenAPI (you shouldn't, FastAPI already tests it extensively for you): the order for
tags
ininclude_router
and path operations was updated for consistency, but it's a simple order change. - If you have advanced custom logic to access each route's
route.response_class
, or therouter.default_response_class
, or theapp.default_response_class
: the default value forresponse_class
inAPIRoute
and fordefault_response_class
inAPIRouter
andFastAPI
is now aDefaultPlaceholder
used internally to handle and solve default values and overrides. The actual response class inside theDefaultPlaceholder
is available atroute.response_class.value
.
- If you are testing the generated OpenAPI (you shouldn't, FastAPI already tests it extensively for you): the order for
๐ Docs
โก๏ธ PR #2434 (above) includes new or updated docs:
- Advanced User Guide - OpenAPI Callbacks.
- Tutorial - Bigger Applications.
- Tutorial - Dependencies - Dependencies in path operation decorators.
- Tutorial - Dependencies - Global Dependencies.
๐ฑ ๐ Add FastAPI monitoring blog post to External Links. PR #2324 by @louisguitton.
๐ฑ โ๏ธ Fix typo in Deta tutorial. PR #2320 by @tiangolo.
๐ฑ โจ Add Discord chat. PR #2322 by @tiangolo.
๐ฑ ๐ Fix image links for sponsors. PR #2304 by @tiangolo.
๐ Translations
- ๐ Add Japanese translation for Advanced - Custom Response. PR #2193 by @Attsun1031.
- ๐ Add Chinese translation for Benchmarks. PR #2119 by @spaceack.
- ๐ Add Chinese translation for Tutorial - Body - Nested Models. PR #1609 by @waynerv.
- ๐ Add Chinese translation for Advanced - Custom Response. PR #1459 by @RunningIkkyu.
- ๐ Add Chinese translation for Advanced - Return a Response Directly. PR #1452 by @RunningIkkyu.
- ๐ Add Chinese translation for Advanced - Additional Status Codes. PR #1451 by @RunningIkkyu.
- ๐ Add Chinese translation for Advanced - Path Operation Advanced Configuration. PR #1447 by @RunningIkkyu.
- ๐ Add Chinese translation for Advanced User Guide - Intro. PR #1445 by @RunningIkkyu.
Internal
- โก๏ธ ๐ง Update TestDriven link to course in sponsors section. PR #2435 by @tiangolo.
- โก๏ธ ๐ฑ Update sponsor logos. PR #2418 by @tiangolo.
- ๐ฑ ๐ Fix disabling install of Material for MkDocs Insiders in forks, strike 1 โพ. PR #2340 by @tiangolo.
- ๐ฑ ๐ Fix disabling Material for MkDocs Insiders install in forks. PR #2339 by @tiangolo.
- ๐ฑ โจ Add silver sponsor WeTransfer. PR #2338 by @tiangolo.
- ๐ฑ โจ Set up and enable Material for MkDocs Insiders for the docs. PR #2325 by @tiangolo.
-
v0.61.2 Changes
November 05, 2020๐ Fixes
- ๐ฑ ๐ Relax Swagger UI version pin. PR #2089 by @jmriebold.
- ๐ฑ ๐ Fix bug overriding custom HTTPException and RequestValidationError from exception_handlers. PR #1924 by @uriyyo.
- ๐ฑ โ๏ธ Fix typo on dependencies utils and cleanup unused variable. PR #1912 by @Kludex.
๐ Docs
- ๐ฑ โ๏ธ Fix typo in Tutorial - Path Parameters. PR #2231 by @mariacamilagl.
- ๐ฑ โ Fix a stylistic error in docs. PR #2206 by @ddobrinskiy.
- ๐ฑ โ Fix capitalizaiton typo in docs. PR #2204 by @imba-tjd.
- ๐ฑ โ Fix typo in docs. PR #2179 by @ammarasmro.
- โก๏ธ ๐ Update/fix links in docs to use HTTPS. PR #2165 by @imba-tjd.
- ๐ฑ โ Fix typos and add rewording in docs. PR #2159 by @nukopy.
- ๐ฑ ๐ Fix code consistency in examples for Tutorial - User Guide - Path Parameters. PR #2158 by @nukopy.
- ๐ฑ ๐ Fix renamed parameter
content_type
typo. PR #2135 by @TeoZosa. - ๐ฑ โ Fix minor typos in docs. PR #2122 by @TeoZosa.
- ๐ฑ โ Fix typos in docs and source examples. PR #2102 by @AdrianDeAnda.
- ๐ฑ โ Fix incorrect Celery URLs in docs. PR #2100 by @CircleOnCircles.
- ๐ฑ ๐ Simplify intro to Python Types, all currently supported Python versions include type hints ๐. PR #2085 by @ninjaaron.
- ๐ฑ ๐ Fix example code with sets in Tutorial - Body - Nested Models 3. PR #2054 by @hitrust.
- ๐ฑ ๐ Fix example code with sets in Tutorial - Body - Nested Models 2. PR #2053 by @hitrust.
- ๐ฑ ๐ Fix example code with sets in Tutorial - Body - Nested Models. PR #2052 by @hitrust.
- ๐ฑ โ Fix typo in Benchmarks. PR #1995 by @AlejoAsd.
- ๐ Add note in CORS tutorial about allow_origins with ["*"] and allow_credentials. PR #1895 by @dsmurrell.
- ๐ ๐ Add deployment to Deta, the first gold sponsor ๐. PR #2303 by @tiangolo.
- ๐ฅ Update FastAPI People. PR #2282 by @github-actions[bot].
- ๐ฑ โ๏ธ Fix uppercase in Tutorial - Query parameters. PR #2245 by @mariacamilagl.
- ๐ฑ ๐ Add articles to External Links. PR #2247 by @tiangolo.
- ๐ฑ โ Fix typo in Spanish tutorial index. PR #2020 by @aviloncho.
๐ Translations
- ๐ Add Japanese translation for Advanced Tutorial - Response Directly. PR #2191 by @Attsun1031.
- ๐ ๐ Add Japanese translation for Tutorial - Security - First Steps. PR #2153 by @komtaki.
- ๐ Add Japanese translation for Tutorial - Query Parameters and String Validations. PR #1901 by @SwftAlpc.
- ๐ Add Portuguese translation for External Links. PR #1443 by @Serrones.
- ๐ Add Japanese translation for Tutorial - CORS. PR #2125 by @tokusumi.
- ๐ Add Japanese translation for Contributing. PR #2067 by @komtaki.
- ๐ Add Japanese translation for Project Generation. PR #2050 by @tokusumi.
- ๐ Add Japanese translation for Alternatives. PR #2043 by @Attsun1031.
- ๐ Add Japanese translation for History Design and Future. PR #2002 by @komtaki.
- ๐ Add Japanese translation for Benchmarks. PR #1992 by @komtaki.
- ๐ Add Japanese translation for Tutorial - Header Parameters. PR #1935 by @SwftAlpc.
- ๐ Add Portuguese translation for Tutorial - First Steps. PR #1861 by @jessicapaz.
- ๐ Add Portuguese translation for Python Types. PR #1796 by @izaguerreiro.
- ๐ Add Japanese translation for Help FastAPI. PR #1692 by @tokusumi.
- ๐ Add Japanese translation for Tutorial - Body. PR #1683 by @tokusumi.
- ๐ Add Japanese translation for Tutorial - Query Params. PR #1674 by @tokusumi.
- ๐ Add Japanese translation for tutorial/path-params.md. PR #1671 by @tokusumi.
- ๐ Add Japanese translation for tutorial/first-steps.md. PR #1658 by @tokusumi.
- ๐ Add Japanese translation for tutorial/index.md. PR #1656 by @tokusumi.
- ๐ Add translation to Portuguese for Project Generation. PR #1602 by @Serrones.
- ๐ Add Japanese translation for Features. PR #1625 by @tokusumi.
- ๐ Initialize new language Korean for translations. PR #2018 by @hard-coders.
- ๐ Add Portuguese translation of Deployment. PR #1374 by @Serrones.
Internal
- โฌ๏ธ ๐ฅ Cleanup after upgrade for Docs Previews GitHub Action. PR #2248 by @tiangolo.
- ๐ท ๐ Fix CI docs preview, unzip docs. PR #2246 by @tiangolo.
- ๐ โจ Add instant docs deploy previews for PRs from forks. PR #2244 by @tiangolo.
- ๐ โก๏ธ Build docs for languages in parallel in subprocesses to speed up CI. PR #2242 by @tiangolo.
- ๐ ๐ Fix docs order generation for partial translations. PR #2238 by @tiangolo.
- ๐ฅ Update FastAPI People. PR #2202 by @github-actions[bot].
- โก๏ธ โป๏ธ Update FastAPI People GitHub Action to send the PR as github-actions. PR #2201 by @tiangolo.
- โก๏ธ ๐ง Update FastAPI People GitHub Action config, run monthly. PR #2199 by @tiangolo.
- ๐ณ ๐ Fix FastAPI People GitHub Action Docker dependency, strike 1 โพ. PR #2198 by @tiangolo.
- ๐ณ ๐ Fix FastAPI People GitHub Action Docker dependencies. PR #2197 by @tiangolo.
- ๐ฑ ๐ Fix FastAPI People GitHub Action when there's nothing to change. PR #2196 by @tiangolo.
- ๐ฅ Add new section FastAPI People. PR #2195 by @tiangolo.
- โฌ๏ธ โฌ๏ธ Upgrade GitHub Action Latest Changes. PR #2190 by @tiangolo.
- โฌ๏ธ โฌ๏ธ Upgrade GitHub Action Label Approved. PR #2189 by @tiangolo.
- โก๏ธ ๐ง Update GitHub Action Label Approved, run at 12:00. PR #2185 by @tiangolo.
- โฌ๏ธ ๐ท Upgrade GitHub Action Latest Changes. PR #2184 by @tiangolo.
- ๐ฑ ๐ท Set GitHub Action Label Approved to run daily, not every minute. PR #2163 by @tiangolo.
- ๐ฑ ๐ฅ Remove pr-approvals GitHub Action as it's not compatible with forks. Use the new one. PR #2162 by @tiangolo.
- ๐ฑ ๐ท Add GitHub Action Latest Changes. PR #2160.
- ๐ฑ ๐ท Add GitHub Action Label Approved. PR #2161.
-
v0.61.1 Changes
August 29, 2020๐ Fixes
- ๐ Fix issues using
jsonable_encoder
with SQLAlchemy models directly. PR #1987.
๐ Docs
- ๐ Fix typo in NoSQL docs. PR #1980 by @facundojmaero.
๐ Translations
- โ Add translation for main page to Japanese PR #1571 by @ryuckel.
- ๐ Initialize French translations. PR #1975 by @JulianMaurin-BM.
- ๐ Initialize Turkish translations. PR #1905 by @ycd.
Internal
- ๐ Fix issues using
-
v0.61.0 Changes
August 09, 2020๐ Features
- โ Add support for injecting
HTTPConnection
(asRequest
andWebSocket
). Useful for sharing app state in dependencies. PR #1827 by @nsidnev. - ๐ Export
WebSocketDisconnect
and add example handling WebSocket disconnections to docs. PR #1822 by @rkbeatss.
๐ฅ Breaking Changes
- Require Pydantic >
1.0.0
.- Remove support for deprecated Pydantic
0.32.2
. This improves maintainability and allows new features. - In
FastAPI
andAPIRouter
: - Remove path operation decorators related/deprecated parameter
response_model_skip_defaults
(useresponse_model_exclude_unset
instead). - Change path operation decorators parameter default for
response_model_exclude
fromset()
toNone
(as is in Pydantic). - In
encoders.jsonable_encoder
: - Remove deprecated
skip_defaults
, use insteadexclude_unset
. - Set default of
exclude
fromset()
toNone
(as is in Pydantic). - PR #1862.
- Remove support for deprecated Pydantic
- ๐ In
encoders.jsonable_encoder
remove parametersqlalchemy_safe
.- It was an early hack to allow returning SQLAlchemy models, but it was never documented, and the recommended way is using Pydantic's
orm_mode
as described in the tutorial: SQL (Relational) Databases. - PR #1864.
- It was an early hack to allow returning SQLAlchemy models, but it was never documented, and the recommended way is using Pydantic's
๐ Docs
- โ Add link to the course by TestDriven.io: Test-Driven Development with FastAPI and Docker. PR #1860.
- ๐ Fix empty log message in docs example about handling errors. PR #1815 by @manlix.
- Reword text to reduce ambiguity while not being gender-specific. PR #1824 by @Mause.
Internal
- โ Add Flake8 linting. Original PR #1774 by @MashhadiNima.
- Disable Gitter bot, as it's currently broken, and Gitter's response doesn't show the problem. PR #1853.
- โ Add support for injecting
-
v0.60.2 Changes
August 08, 2020- ๐ Fix typo in docs for query parameters. PR #1832 by @ycd.
- โ Add docs about Async Tests. PR #1619 by @empicano.
- ๐ป Raise an exception when using form data (
Form
,File
) without havingpython-multipart
installed.- Up to now the application would run, and raise an exception only when receiving a request with form data, the new behavior, raising early, will prevent from deploying applications with broken dependencies.
- It also detects if the correct package
python-multipart
is installed instead of the incorrectmultipart
(both importable asmultipart
). - PR #1851 based on original PR #1627 by @chrisngyn, @YKo20010, @kx-chen.
- ๐ Re-enable Gitter releases bot. PR #1831.
- โ Add link to async SQL databases tutorial from main SQL tutorial. PR #1813 by @short2strings.
- ๐ Fix typo in tutorial about behind a proxy. PR #1807 by @toidi.
- ๐ Fix typo in Portuguese docs. PR #1795 by @izaguerreiro.
- โ Add translations setup for Ukrainian. PR #1830.
- โ Add external link Build And Host Fast Data Science Applications Using FastAPI. PR #1786 by @Kludex.
- ๐ Fix encoding of Pydantic models that inherit from others models with custom
json_encoders
. PR #1769 by @henrybetts. - Simplify and improve
jsonable_encoder
. PR #1754 by @MashhadiNima. - Simplify internal code syntax in several points. PR #1753 by @uriyyo.
- ๐ Improve internal typing, declare
Optional
parameters. PR #1731 by @MashhadiNima. - โ Add external link Deploy FastAPI on Azure App Service to docs. PR #1726 by @windson.
- โ Add link to Starlette docs about WebSocket testing. PR #1717 by @hellocoldworld.
- ๐จ Refactor generating dependant, merge for loops. PR #1714 by @Bloodielie.
- โก๏ธ Update example for templates with Jinja to include HTML media type. PR #1690 by @frafra.
- ๐ Fix typos in docs for security. PR #1678 by @nilslindemann.
- ๐ Fix typos in docs for dependencies. PR #1675 by @nilslindemann.
- ๐ Fix type annotation for
**extra
parameters inFastAPI
. PR #1659 by @bharel. - โฌ๏ธ Bump MkDocs Material to fix docs in browsers with dark mode. PR #1789 by @adriencaccia.
- โ Remove docs preview comment from each commit. PR #1826.
- โก๏ธ Update GitHub context extraction for Gitter notification bot. PR #1766.
-
v0.60.1 Changes
July 22, 2020- โ Add debugging logs for GitHub actions to introspect GitHub hidden context. PR #1764.
- ๐ Use OS preference theme for online docs. PR #1760 by @adriencaccia.
- โฌ๏ธ Upgrade Starlette to version
0.13.6
to handle a vulnerability when using static files in Windows. PR #1759 by @jamesag26. - ๐ Pin Swagger UI temporarily, waiting for a fix for swagger-api/swagger-ui#6249. PR #1763.
- โก๏ธ Update GitHub Actions, use commit from PR for docs preview, not commit from pre-merge. PR #1761.
- ๐จ Update GitHub Actions, refactor Gitter bot. PR #1746.
-
v0.60.0 Changes
July 20, 2020- โ Add GitHub Action to watch for missing preview docs and trigger a preview deploy. PR #1740.
- โ Add custom GitHub Action to get artifact with docs preview. PR #1739.
- โ Add new GitHub Actions to preview docs from PRs. PR #1738.
- โ Add XML test coverage to support GitHub Actions. PR #1737.
- โก๏ธ Update badges and remove Travis now that GitHub Actions is the main CI. PR #1736.
- โ Add GitHub Actions for CI, move from Travis. PR #1735.
- โ Add support for adding OpenAPI schema for GET requests with a body. PR #1626 by @victorphoenix3.
-
v0.59.0 Changes
July 10, 2020- ๐ Fix typo in docstring for OAuth2 utils. PR #1621 by @tomarv2.
- โก๏ธ Update JWT docs to use Python-jose instead of PyJWT. Initial PR #1610 by @asheux.
- ๐ Fix/re-enable search bar in docs. PR #1703.
- Auto-generate a "server" in OpenAPI
servers
when there's aroot_path
instead of prefixing all thepaths
:- Add a new parameter for
FastAPI
classes:root_path_in_servers
to disable the auto-generation ofservers
. - New docs about
root_path
andservers
in Additional Servers. - Update OAuth2 examples to use a relative URL for
tokenUrl="token"
to make sure those examples keep working as-is even when behind a reverse proxy. - Initial PR #1596 by @rkbeatss.
- Add a new parameter for
- ๐ Fix typo/link in External Links. PR #1702.
- โก๏ธ Update handling of External Links to use a data file and allow translating the headers without becoming obsolete quickly when new links are added. PR #https://github.com/tiangolo/fastapi/pull/1701.
- โ Add external link Machine learning model serving in Python using FastAPI and Streamlit to docs. PR #1669 by @davidefiocco.
- โ Add note in docs on order in Pydantic Unions. PR #1591 by @kbanc.
- ๐ Improve support for tests in editor. PR #1699.
- ๐ Pin dependencies. PR #1697.
- โก๏ธ Update isort to version 5.x.x. PR #1670 by @asheux.
-
v0.58.1 Changes
June 28, 2020- โ Add link in docs to Pydantic data types. PR #1612 by @tayoogunbiyi.
- ๐ Fix link in warning logs for
openapi_prefix
. PR #1611 by @bavaria95. - ๐ Fix bad link in docs. PR #1603 by @molto0504.
- โ Add Vim temporary files to
.gitignore
for contributors using Vim. PR #1590 by @asheux. - ๐ Fix typo in docs for sub-applications. PR #1578 by @schlpbch.
- โก๏ธ Use
Optional
in all the examples in the docs. Original PR #1574 by @chrisngyn, @kx-chen, @YKo20010. Updated and merged PR #1644. - Update tests and handling of
response_model_by_alias
. PR #1642. - โ Add translation to Chinese for Body - Fields - ่ฏทๆฑไฝ - ๅญๆฎต. PR #1569 by @waynerv.
- โก๏ธ Update Chinese translation of main page. PR #1564 by @waynerv.
- โ Add translation to Chinese for Body - Multiple Parameters - ่ฏทๆฑไฝ - ๅคไธชๅๆฐ. PR #1532 by @waynerv.
- โ Add translation to Chinese for Path Parameters and Numeric Validations - ่ทฏๅพๅๆฐๅๆฐๅผๆ ก้ช. PR #1506 by @waynerv.
- โ Add GitHub action to auto-label approved PRs (mainly for translations). PR #1638.
-
v0.58.0 Changes
June 15, 2020- ๐ Deep merge OpenAPI responses to preserve all the additional metadata. PR #1577.
- ๐ Mention in docs that only main app events are run (not sub-apps). PR #1554 by @amacfie.
- ๐ Fix body validation error response, do not include body variable when it is not embedded. PR #1553 by @amacfie.
- ๐ Fix testing OAuth2 security scopes when using dependency overrides. PR #1549 by @amacfie.
- ๐ Fix Model for JSON Schema keyword
not
as a JSON Schema instead of a list. PR #1548 by @v-do. - โ Add support for OpenAPI
servers
. PR #1547 by @mikaello.