fix(deps): update dependency fastapi to ^0.83.0
This MR contains the following updates:
Package | Change | Age | Adoption | Passing | Confidence |
---|---|---|---|---|---|
fastapi |
^0.71.0 -> ^0.83.0
|
Release Notes
tiangolo/fastapi
v0.83.0
Python 3.6 reached the end-of-life and is no longer supported by Python since around a year ago.
You hopefully updated to a supported version of Python a while ago. If you haven't, you really should.
Features
-
✨ Add support injsonable_encoder
for include and exclude with dataclasses. MR #4923 by @DCsunset.
Fixes
-
🐛 FixRuntimeError
raised whenHTTPException
has a status code with no content. MR #5365 by @iudeen. -
🐛 Fix empty reponse body when defaultstatus_code
is empty but the aResponse
parameter withresponse.status_code
is set. MR #5360 by @tmeckel.
Docs
Internal
-
⬆ [pre-commit.ci] pre-commit autoupdate. MR #5352 by @pre-commit-ci[bot].
v0.82.0
Python 3.6 reached the end-of-life and is no longer supported by Python since around a year ago.
You hopefully updated to a supported version of Python a while ago. If you haven't, you really should.
Features
-
✨ ExportWebSocketState
infastapi.websockets
. MR #4376 by @matiuszka. -
✨ Support Python internal description on Pydantic model's docstring. MR #3032 by @Kludex. -
✨ UpdateORJSONResponse
to support nonstr
keys and serializing Numpy arrays. MR #3892 by @baby5.
Fixes
-
🐛 Allow exit code for dependencies withyield
to always execute, by removing capacity limiter for them, to e.g. allow closing DB connections without deadlocks. MR #5122 by @adriangb. -
🐛 Fix FastAPI People GitHub Action: set HTTPX timeout for GraphQL query request. MR #5222 by @iudeen. -
🐛 Make sure a parameter defined as required is kept required in OpenAPI even if defined as optional in another dependency. MR #4319 by @cd17822. -
🐛 Fix support for path parameters in WebSockets. MR #3879 by @davidbrochart.
Docs
-
✏ Update Hypercorn link, now pointing to GitHub. MR #5346 by @baconfield. -
✏ Tweak wording indocs/en/docs/advanced/dataclasses.md
. MR #3698 by @pfackeldey. -
📝 Add note about Python 3.10X | Y
operator in explanation about Response Models. MR #5307 by @MendyLanda. -
📝 Add link to New Relic article: "How to monitor FastAPI application performance using Python agent". MR #5260 by @sjyothi54. -
📝 Update docs forORJSONResponse
with details about improving performance. MR #2615 by @falkben. -
📝 Add docs for creating a custom Response class. MR #5331 by @tiangolo. -
📝 Add tip about using alias for form data fields. MR #5329 by @tiangolo.
Translations
-
🌐 Add Russian translation fordocs/ru/docs/features.md
. MR #5315 by @Xewus. -
🌐 Update Chinese translation fordocs/zh/docs/tutorial/request-files.md
. MR #4529 by @ASpathfinder. -
🌐 Add Chinese translation fordocs/zh/docs/tutorial/encoder.md
. MR #4969 by @Zssaer. -
🌐 Fix MkDocs file line for Portuguese translation ofbackground-task.md
. MR #5242 by @ComicShrimp.
Internal
-
👥 Update FastAPI People. MR #5347 by @github-actions[bot]. -
⬆ Bump dawidd6/action-download-artifact from 2.22.0 to 2.23.0. MR #5321 by @dependabot[bot]. -
⬆ [pre-commit.ci] pre-commit autoupdate. MR #5318 by @pre-commit-ci[bot]. -
✏ Fix a small code highlight line error. MR #5256 by @hjlarry. -
♻ Internal small refactor, moveoperation_id
parameter position in delete method for consistency with the code. MR #4474 by @hiel. -
🔧 Update sponsors, disable ImgWhale. MR #5338 by @tiangolo.
v0.81.0
Features
-
✨ Add ReDoc<noscript>
warning when JS is disabled. MR #5074 by @evroon. -
✨ Add support forFrozenSet
in parameters (e.g. query). MR #2938 by @juntatalor. -
✨ Allow custom middlewares to raiseHTTPException
s and propagate them. MR #2036 by @ghandic. -
✨ Preservejson.JSONDecodeError
information when handling invalid JSON in request body, to support custom exception handlers that use its information. MR #4057 by @UKnowWhoIm.
Fixes
-
🐛 Fixjsonable_encoder
for dataclasses with pydantic-compatible fields. MR #3607 by @himbeles. -
🐛 Fix support for extendingopenapi_extras
with parameter lists. MR #4267 by @orilevari.
Docs
-
✏ Fix a simple typo indocs/en/docs/python-types.md
. MR #5193 by @GlitchingCore. -
✏ Fix typos intests/test_schema_extra_examples.py
. MR #5126 by @supraaxdd. -
✏ Fix typos indocs/en/docs/tutorial/path-params-numeric-validations.md
. MR #5142 by @invisibleroads. -
📝 Add step about upgrading pip in the venv to avoid errors when installing dependenciesdocs/en/docs/contributing.md
. MR #5181 by @edisnake. -
✏ Reword and clarify text in tutorialdocs/en/docs/tutorial/body-nested-models.md
. MR #5169 by @papb. -
✏ Fix minor typo indocs/en/docs/features.md
. MR #5206 by @OtherBarry. -
✏ Fix minor typos indocs/en/docs/async.md
. MR #5125 by @Ksenofanex. -
📝 Add external link to docs: "Fastapi, Docker(Docker compose) and Postgres". MR #5033 by @krishnardt. -
📝 Simplify example for docs for Additional Responses, remove unnecessaryelse
. MR #4693 by @adriangb. -
📝 Update docs, compare enums with identity instead of equality. MR #4905 by @MicaelJarniac. -
✏ Fix typo indocs/en/docs/python-types.md
. MR #4886 by @MicaelJarniac. -
🎨 Fix syntax highlighting in docs for OpenAPI Callbacks. MR #4368 by @xncbf. -
✏ Reword confusing sentence in docs filetypo-fix-path-params-numeric-validations.md
. MR #3219 by @ccrenfroe. -
📝 Update docs for handling HTTP Basic Auth withsecrets.compare_digest()
to account for non-ASCII characters. MR #3536 by @lewoudar. -
📝 Update docs for testing, fix examples with relative imports. MR #5302 by @tiangolo.
Translations
-
🌐 Add Russian translation fordocs/ru/docs/index.md
. MR #5289 by @impocode. -
🌐 Add Russian translation fordocs/ru/docs/deployment/versions.md
. MR #4985 by @emp7yhead. -
🌐 Add Portuguese translation fordocs/pt/docs/tutorial/header-params.md
. MR #4921 by @batlopes. -
🌐 Updateko/mkdocs.yml
for a missing link. MR #5020 by @dalinaum.
Internal
-
⬆ Bump dawidd6/action-download-artifact from 2.21.1 to 2.22.0. MR #5258 by @dependabot[bot]. -
⬆ [pre-commit.ci] pre-commit autoupdate. MR #5196 by @pre-commit-ci[bot]. -
🔥 Delete duplicated tests intests/test_tutorial/test_sql_databases/test_sql_databases.py
. MR #5040 by @raccoonyy. -
♻ Simplify internal RegEx infastapi/utils.py
. MR #5057 by @pylounge. -
🔧 Fix Type hint ofauto_error
which does not need to beOptional[bool]
. MR #4933 by @DavidKimDY. -
🔧 Update mypy config, usestrict = true
instead of manual configs. MR #4605 by @michaeloliverx. -
♻ Change adict()
for{}
infastapi/utils.py
. MR #3138 by @ShahriyarR. -
♻ Move internal variable for errors injsonable_encoder
to put related code closer. MR #4560 by @GuilleQP. -
♻ Simplify conditional assignment infastapi/dependencies/utils.py
. MR #4597 by @cikay. -
⬆ Upgrade version pin accepted for Flake8, for internal code, toflake8 >=3.8.3,<6.0.0
. MR #4097 by @jamescurtin. -
🍱 Update Jina banner, fix typo. MR #5301 by @tiangolo.
v0.80.0
Breaking Changes - Fixes
If you are using response_model
with some type that doesn't include None
but the function is returning None
, it will now raise an internal server error, because you are returning invalid data that violates the contract in response_model
. Before this release it would allow breaking that contract returning None
.
For example, if you have an app like this:
from fastapi import FastAPI
from pydantic import BaseModel
class Item(BaseModel):
name: str
price: Optional[float] = None
owner_ids: Optional[List[int]] = None
app = FastAPI()
@​app.get("/items/invalidnone", response_model=Item)
def get_invalid_none():
return None
...calling the path /items/invalidnone
will raise an error, because None
is not a valid type for the response_model
declared with Item
.
You could also be implicitly returning None
without realizing, for example:
from fastapi import FastAPI
from pydantic import BaseModel
class Item(BaseModel):
name: str
price: Optional[float] = None
owner_ids: Optional[List[int]] = None
app = FastAPI()
@​app.get("/items/invalidnone", response_model=Item)
def get_invalid_none():
if flag:
return {"name": "foo"}
### if flag is False, at this point the function will implicitly return None
If you have path operations using response_model
that need to be allowed to return None
, make it explicit in response_model
using Union[Something, None]
:
from typing import Union
from fastapi import FastAPI
from pydantic import BaseModel
class Item(BaseModel):
name: str
price: Optional[float] = None
owner_ids: Optional[List[int]] = None
app = FastAPI()
@​app.get("/items/invalidnone", response_model=Union[Item, None])
def get_invalid_none():
return None
This way the data will be correctly validated, you won't have an internal server error, and the documentation will also reflect that this path operation could return None
(or null
in JSON).
Fixes
-
⬆ Upgrade Swagger UI copy ofoauth2-redirect.html
to include fixes for flavors of authorization code flows in Swagger UI. MR #3439 initial MR by @koonpeng. -
♻ Strip empty whitespace from description extracted from docstrings. MR #2821 by @and-semakin. -
🐛 Fix cached dependencies when using a dependency inSecurity()
and other places (e.g.Depends()
) with different OAuth2 scopes. MR #2945 by @laggardkernel. -
🎨 Update type annotations forresponse_model
, allow things likeUnion[str, None]
. MR #5294 by @tiangolo.
Translations
-
🌐 Fix typos in German translation fordocs/de/docs/features.md
. MR #4533 by @0xflotus. -
🌐 Add missing navigator forencoder.md
in Korean translation. MR #5238 by @joonas-yoon. - (Empty MR merge by accident) #4913.
v0.79.1
Fixes
-
🐛 Fixjsonable_encoder
usinginclude
andexclude
parameters for non-Pydantic objects. MR #2606 by @xaviml. -
🐛 Fix edge case with repeated aliases names not shown in OpenAPI. MR #2351 by @klaa97. -
📝 Add misc dependency installs to tutorial docs. MR #2126 by @TeoZosa.
Docs
-
📝 Add note giving credit for illustrations to Ketrina Thompson. MR #5284 by @tiangolo. -
✏ Fix typo inpython-types.md
. MR #5116 by @Kludex. -
✏ Fix typo indocs/en/docs/python-types.md
. MR #5007 by @atiabbz. -
📝 Remove unneeded Django/Flask references from async topic intro. MR #5280 by @carltongibson. -
✨ Add illustrations for Concurrent burgers and Parallel burgers. MR #5277 by @tiangolo. Updated docs at: Concurrency and Burgers.
Translations
-
🌐 Add Portuguese translation fordocs/pt/docs/tutorial/query-params.md
. MR #4775 by @batlopes. -
🌐 Add Portuguese translation fordocs/pt/docs/tutorial/security/first-steps.md
. MR #4954 by @FLAIR7. -
🌐 Add translation fordocs/zh/docs/advanced/response-cookies.md
. MR #4638 by @zhangbo2012. -
🌐 Add French translation fordocs/fr/docs/deployment/index.md
. MR #3689 by @rjNemo. -
🌐 Add Portuguese translation fortutorial/handling-errors.md
. MR #4769 by @frnsimoes. -
🌐 Add French translation fordocs/fr/docs/history-design-future.md
. MR #3451 by @rjNemo. -
🌐 Add Russian translation fordocs/ru/docs/tutorial/background-tasks.md
. MR #4854 by @AdmiralDesu. -
🌐 Add Chinese translation fordocs/tutorial/security/first-steps.md
. MR #3841 by @jaystone776. -
🌐 Add Japanese translation fordocs/ja/docs/advanced/nosql-databases.md
. MR #4205 by @sUeharaE4. -
🌐 Add Indonesian translation fordocs/id/docs/tutorial/index.md
. MR #4705 by @bas-baskara. -
🌐 Add Persian translation fordocs/fa/docs/index.md
and tweak right-to-left CSS. MR #2395 by @mohsen-mahmoodi.
Internal
-
🔧 Update Jina sponsorship. MR #5283 by @tiangolo. -
🔧 Update Jina sponsorship. MR #5272 by @tiangolo. -
🔧 Update sponsors, Striveworks badge. MR #5179 by @tiangolo.
v0.79.0
Fixes - Breaking Changes
-
🐛 Fix removing body from status codes that do not support it. MR #5145 by @tiangolo.- Setting
status_code
to204
,304
, or any code below200
(1xx) will remove the body from the response. - This fixes an error in Uvicorn that otherwise would be thrown:
RuntimeError: Response content longer than Content-Length
. - This removes
fastapi.openapi.constants.STATUS_CODES_WITH_NO_BODY
, it is replaced by a function in utils.
- Setting
Translations
-
🌐 Start of Hebrew translation. MR #5050 by @itay-raveh. -
🔧 Add config for Swedish translations notification. MR #5147 by @tiangolo. -
🌐 Start of Swedish translation. MR #5062 by @MrRawbin. -
🌐 Add Japanese translation fordocs/ja/docs/advanced/index.md
. MR #5043 by @wakabame. -
🌐 🇵🇱 Add Polish translation fordocs/pl/docs/tutorial/first-steps.md
. MR #5024 by @Valaraucoo.
Internal
-
🔧 Update translations notification for Hebrew. MR #5158 by @tiangolo. -
🔧 Update Dependabot commit message. MR #5156 by @tiangolo. -
⬆ Bump actions/upload-artifact from 2 to 3. MR #5148 by @dependabot[bot]. -
⬆ Bump actions/cache from 2 to 3. MR #5149 by @dependabot[bot]. -
🔧 Update sponsors badge configs. MR #5155 by @tiangolo. -
👥 Update FastAPI People. MR #5154 by @tiangolo. -
🔧 Update Jina sponsor badges. MR #5151 by @tiangolo. -
⬆ Bump actions/checkout from 2 to 3. MR #5133 by @dependabot[bot]. -
⬆ [pre-commit.ci] pre-commit autoupdate. MR #5030 by @pre-commit-ci[bot]. -
⬆ Bump nwtgck/actions-netlify from 1.1.5 to 1.2.3. MR #5132 by @dependabot[bot]. -
⬆ Bump codecov/codecov-action from 2 to 3. MR #5131 by @dependabot[bot]. -
⬆ Bump dawidd6/action-download-artifact from 2.9.0 to 2.21.1. MR #5130 by @dependabot[bot]. -
⬆ Bump actions/setup-python from 2 to 4. MR #5129 by @dependabot[bot]. -
👷 Add Dependabot. MR #5128 by @tiangolo. -
♻ ️ Move fromOptional[X]
toUnion[X, None]
for internal utils. MR #5124 by @tiangolo. -
🔧 Update sponsors, remove Dropbase, add Doist. MR #5096 by @tiangolo. -
🔧 Update sponsors, remove Classiq, add ImgWhale. MR #5079 by @tiangolo.
v0.78.0
Features
-
✨ Add support for omitting...
as default value when declaring required parameters with: -
Path()
-
Query()
-
Header()
-
Cookie()
-
Body()
-
Form()
-
File()
New docs at Tutorial - Query Parameters and String Validations - Make it required. MR #4906 by @tiangolo.
Up to now, declaring a required parameter while adding additional validation or metadata needed using ...
(Ellipsis).
For example:
from fastapi import Cookie, FastAPI, Header, Path, Query
app = FastAPI()
@​app.get("/items/{item_id}")
def main(
item_id: int = Path(default=..., gt=0),
query: str = Query(default=..., max_length=10),
session: str = Cookie(default=..., min_length=3),
x_trace: str = Header(default=..., title="Tracing header"),
):
return {"message": "Hello World"}
...all these parameters are required because the default value is ...
(Ellipsis).
But now it's possible and supported to just omit the default value, as would be done with Pydantic fields, and the parameters would still be required.
from fastapi import Cookie, FastAPI, Header, Path, Query
app = FastAPI()
@​app.get("/items/{item_id}")
def main(
item_id: int = Path(gt=0),
query: str = Query(max_length=10),
session: str = Cookie(min_length=3),
x_trace: str = Header(title="Tracing header"),
):
return {"message": "Hello World"}
To declare parameters as optional (not required), you can set a default value as always, for example using None
:
from typing import Union
from fastapi import Cookie, FastAPI, Header, Path, Query
app = FastAPI()
@​app.get("/items/{item_id}")
def main(
item_id: int = Path(gt=0),
query: Union[str, None] = Query(default=None, max_length=10),
session: Union[str, None] = Cookie(default=None, min_length=3),
x_trace: Union[str, None] = Header(default=None, title="Tracing header"),
):
return {"message": "Hello World"}
Docs
-
📝 Add docs recommendingUnion
overOptional
and migrate source examples. New docs at Python Types Intro - UsingUnion
orOptional
. MR #4908 by @tiangolo. -
🎨 Fix default value as set in tutorial for Path Operations Advanced Configurations. MR #4899 by @tiangolo. -
📝 Add documentation for redefined path operations. MR #4864 by @madkinsz. -
📝 Updates links for Celery documentation. MR #4736 by @sammyzord. -
✏ Fix example code with sets in tutorial for body nested models. MR #3030 by @hitrust. -
✏ Fix links to Pydantic docs. MR #4670 by @kinuax. -
📝 Update docs about Swagger UI self-hosting with newer source links. MR #4813 by @Kastakin. -
📝 Add link to external article: Building the Poll App From Django Tutorial With FastAPI And React. MR #4778 by @jbrocher. -
📝 Add OpenAPI warning to "Body - Fields" docs with extra schema extensions. MR #4846 by @ml-evs.
Translations
-
🌐 Fix code examples in Japanese translation fordocs/ja/docs/tutorial/testing.md
. MR #4623 by @hirotoKirimaru.
Internal
-
♻ Refactor dict value extraction to minimize key lookupsfastapi/utils.py
. MR #3139 by @ShahriyarR. -
✅ Add tests for required nonable parameters and body fields. MR #4907 by @tiangolo. -
👷 Fix installing Material for MkDocs Insiders in CI. MR #4897 by @tiangolo. -
👷 Add pre-commit CI instead of custom GitHub Action. MR #4896 by @tiangolo. -
👷 Add pre-commit GitHub Action workflow. MR #4895 by @tiangolo. -
📝 Add dark mode auto switch to docs based on OS preference. MR #4869 by @ComicShrimp. -
🔥 Remove un-used old pending tests, already covered in other places. MR #4891 by @tiangolo. -
🔧 Add Python formatting hooks to pre-commit. MR #4890 by @tiangolo. -
🔧 Add pre-commit with first config and first formatting pass. MR #4888 by @tiangolo. -
👷 Disable CI installing Material for MkDocs in forks. MR #4410 by @dolfinus.
v0.77.1
Upgrades
Docs
-
📝 Add link to german article: REST-API Programmieren mittels Python und dem FastAPI Modul. MR #4624 by @fschuermeyer. -
📝 Add external link: PyCharm Guide to FastAPI. MR #4512 by @mukulmantosh. -
📝 Add external link to article: Building an API with FastAPI and Supabase and Deploying on Deta. MR #4440 by @aUnicornDev. -
✏ Fix small typo indocs/en/docs/tutorial/security/first-steps.md
. MR #4515 by @KikoIlievski.
Translations
-
🌐 Add Polish translation fordocs/pl/docs/tutorial/index.md
. MR #4516 by @MKaczkow. -
✏ Fix typo in deployment. MR #4629 by @raisulislam541. -
🌐 Add Portuguese translation fordocs/pt/docs/help-fastapi.md
. MR #4583 by @mateusjs.
Internal
-
🔧 Add notifications in issue for Uzbek translations. MR #4884 by @tiangolo.
v0.77.0
Upgrades
-
⬆ Upgrade Starlette from 0.18.0 to 0.19.0. MR #4488 by @Kludex.- When creating an explicit
JSONResponse
thecontent
argument is now required.
- When creating an explicit
Docs
-
📝 Add external link to article: Seamless FastAPI Configuration with ConfZ. MR #4414 by @silvanmelchior. -
📝 Add external link to article: 5 Advanced Features of FastAPI You Should Try. MR #4436 by @kaustubhgupta. -
✏ Reword to improve legibility of docs aboutTestClient
. MR #4389 by @rgilton. -
📝 Add external link to blog post about Kafka, FastAPI, and Ably. MR #4044 by @Ugbot. -
✏ Fix typo indocs/en/docs/tutorial/sql-databases.md
. MR #4875 by @wpyoga. -
✏ Fix typo indocs/en/docs/async.md
. MR #4726 by @Prezu.
Translations
-
🌐 Update source example highlights fordocs/zh/docs/tutorial/query-params-str-validations.md
. MR #4237 by @caimaoy. -
🌐 Remove translation docs references to aiofiles as it's no longer needed since AnyIO. MR #3594 by @alonme. -
✏ 🌐 Fix typo in Portuguese translation fordocs/pt/docs/tutorial/path-params.md
. MR #4722 by @CleoMenezesJr. -
🌐 Fix live docs server for translations for some languages. MR #4729 by @wakabame. -
🌐 Add Portuguese translation fordocs/pt/docs/tutorial/cookie-params.md
. MR #4112 by @lbmendes. -
🌐 Fix French translation fordocs/tutorial/body.md
. MR #4332 by @Smlep. -
🌐 Add Japanese translation fordocs/ja/docs/advanced/conditional-openapi.md
. MR #2631 by @sh0nk. -
🌐 Fix Japanese translation ofdocs/ja/docs/tutorial/body.md
. MR #3062 by @a-takahashi223. -
🌐 Add Portuguese translation fordocs/pt/docs/tutorial/background-tasks.md
. MR #2170 by @izaguerreiro. -
🌐 Add Portuguese translation fordocs/deployment/deta.md
. MR #4442 by @lsglucas. -
🌐 Add Russian translation fordocs/async.md
. MR #4036 by @Winand. -
🌐 Add Portuguese translation fordocs/tutorial/body.md
. MR #3960 by @leandrodesouzadev. -
🌐 Add Portuguese translation oftutorial/extra-data-types.md
. MR #4077 by @luccasmmg. -
🌐 Update German translation fordocs/features.md
. MR #3905 by @jomue.
v0.76.0
Upgrades
Internal
-
👥 Update FastAPI People. MR #4847 by @github-actions[bot]. -
🔧 Add Budget Insight sponsor. MR #4824 by @tiangolo. -
🍱 Update sponsor, ExoFlare badge. MR #4822 by @tiangolo. -
🔧 Update sponsors, enable Dropbase again, update TalkPython link. MR #4821 by @tiangolo.
v0.75.2
This release includes upgrades to third-party packages that handle security issues. Although there's a chance these issues don't affect you in particular, please upgrade as soon as possible.
Fixes
-
✅ Fix new/recent tests with new fixedValidationError
JSON Schema. MR #4806 by @tiangolo. -
🐛 Fix JSON Schema forValidationError
at fieldloc
. MR #3810 by @dconathan. -
🐛 Fix support for prefix on APIRouter WebSockets. MR #2640 by @Kludex.
Upgrades
-
⬆ ️ Update ujson ranges for CVE-2021-45958. MR #4804 by @tiangolo. -
⬆ ️ Upgrade dependencies upper range for extras "all". MR #4803 by @tiangolo. -
⬆ Upgrade Swagger UI - swagger-ui-dist@4. This handles a security issue in Swagger UI itself where it could be possible to inject HTML into Swagger UI. Please upgrade as soon as you can, in particular if you expose your Swagger UI (/docs
) publicly to non-expert users. MR #4347 by @RAlanWright.
Internal
-
🔧 Update sponsors, add: ExoFlare, Ines Course; remove: Dropbase, Vim.so, Calmcode; update: Striveworks, TalkPython and TestDriven.io. MR #4805 by @tiangolo. -
⬆ ️ Upgrade Codecov GitHub Action. MR #4801 by @tiangolo.
v0.75.1
Translations
-
🌐 Start Dutch translations. MR #4703 by @tiangolo. -
🌐 Start Persian/Farsi translations. MR #4243 by @aminalaee. -
✏ Reword sentence about handling errors. MR #1993 by @khuhroproeza.
Internal
-
👥 Update FastAPI People. MR #4752 by @github-actions[bot]. -
➖ Temporarily remove typer-cli from dependencies and upgrade Black to unblock Pydantic CI. MR #4754 by @tiangolo. -
🔧 Add configuration to notify Dutch translations. MR #4702 by @tiangolo. -
👥 Update FastAPI People. MR #4699 by @github-actions[bot]. -
🐛 Fix FastAPI People generation to include missing file in commit. MR #4695 by @tiangolo. -
🔧 Update Classiq sponsor links. MR #4688 by @tiangolo. -
🔧 Add Classiq sponsor. MR #4671 by @tiangolo. -
📝 Add Jina's QA Bot to the docs to help people that want to ask quick questions. MR #4655 by @tiangolo based on original MR #4626 by @hanxiao.
v0.75.0
Features
-
✨ Add support for customgenerate_unique_id_function
and docs for generating clients. New docs: Advanced - Generate Clients. MR #4650 by @tiangolo.
v0.74.1
Features
-
✨ Include route in scope to allow middleware and other tools to extract its information. MR #4603 by @tiangolo.
v0.74.0
Breaking Changes
-
✨ Update internalAsyncExitStack
to fix context for dependencies withyield
. MR #4575 by @tiangolo.
Dependencies with yield
can now catch HTTPException
and custom exceptions. For example:
async def get_database():
with Session() as session:
try:
yield session
except HTTPException:
session.rollback()
raise
finally:
session.close()
After the dependency with yield
handles the exception (or not) the exception is raised again. So that any exception handlers can catch it, or ultimately the default internal ServerErrorMiddleware
.
If you depended on exceptions not being received by dependencies with yield
, and receiving an exception breaks the code after yield
, you can use a block with try
and finally
:
async def do_something():
try:
yield something
finally:
some_cleanup()
...that way the finally
block is run regardless of any exception that might happen.
Features
- The same MR #4575 from above also fixes the
contextvars
context for the code before and afteryield
. This was the main objective of that MR.
This means that now, if you set a value in a context variable before yield
, the value would still be available after yield
(as you would intuitively expect). And it also means that you can reset the context variable with a token afterwards.
For example, this works correctly now:
from contextvars import ContextVar
from typing import Any, Dict, Optional
legacy_request_state_context_var: ContextVar[Optional[Dict[str, Any]]] = ContextVar(
"legacy_request_state_context_var", default=None
)
async def set_up_request_state_dependency():
request_state = {"user": "deadpond"}
contextvar_token = legacy_request_state_context_var.set(request_state)
yield request_state
legacy_request_state_context_var.reset(contextvar_token)
...before this change it would raise an error when resetting the context variable, because the contextvars
context was different, because of the way it was implemented.
Note: You probably don't need contextvars
, and you should probably avoid using them. But they are powerful and useful in some advanced scenarios, for example, migrating from code that used Flask's g
semi-global variable.
Technical Details: If you want to know more of the technical details you can check out the MR description #4575.
Internal
-
🔧 Add Striveworks sponsor. MR #4596 by @tiangolo. -
💚 Only build docs on push when on master to avoid duplicate runs from MRs. MR #4564 by @tiangolo. -
👥 Update FastAPI People. MR #4502 by @github-actions[bot].
v0.73.0
Features
-
✨ Add support for declaringUploadFile
parameters without explicitFile()
. MR #4469 by @tiangolo. New docs: Request Files - File Parameters with UploadFile. -
✨ Add support for tags with Enums. MR #4468 by @tiangolo. New docs: Path Operation Configuration - Tags with Enums. -
✨ Allow hiding from OpenAPI (and Swagger UI)Query
,Cookie
,Header
, andPath
parameters. MR #3144 by @astraldawn. New docs: Query Parameters and String Validations - Exclude from OpenAPI.
Docs
-
📝 Tweak and improve docs for Request Files. MR #4470 by @tiangolo.
Fixes
-
🐛 Fix bug preventing to use OpenAPI when using tuples. MR #3874 by @victorbenichoux. -
🐛 Prefer custom encoder over defaults if specified injsonable_encoder
. MR #2061 by @viveksunder.-
💚 Duplicate MR to trigger CI. MR #4467 by @tiangolo.
-
Internal
-
🐛 Fix docs dependencies cache, to get the latest Material for MkDocs. MR #4466 by @tiangolo. -
🔧 Add sponsor Dropbase. MR #4465 by @tiangolo.
v0.72.0
Features
-
✨ Enable configuring Swagger UI parameters. Original MR #2568 by @jmriebold. Here are the new docs: Configuring Swagger UI.
Docs
-
📝 Update Python Types docs, add missing 3.6 / 3.9 example. MR #4434 by @tiangolo.
Translations
-
🌐 Update Chinese translation fordocs/help-fastapi.md
. MR #3847 by @jaystone776. -
🌐 Fix Korean translation fordocs/ko/docs/index.md
. MR #4195 by @kty4119. -
🌐 Add Polish translation fordocs/pl/docs/index.md
. MR #4245 by @MicroPanda123. -
🌐 Add Chinese translation fordocs\tutorial\path-operation-configuration.md
. MR #3312 by @jaystone776.
Internal
-
🔧 Enable MkDocs Material Insiders'content.tabs.link
. MR #4399 by @tiangolo.
Configuration
-
If you want to rebase/retry this MR, click this checkbox.
This MR has been generated by Renovate Bot.