fix(deps): update dependency fastapi to ^0.115.0
This MR contains the following updates:
Package | Type | Update | Change |
---|---|---|---|
fastapi (changelog) | dependencies | minor |
^0.112.0 -> ^0.115.0
|
Release Notes
fastapi/fastapi (fastapi)
v0.115.0
Highlights
Now you can declare Query
, Header
, and Cookie
parameters with Pydantic models.
Query
Parameter Models
Use Pydantic models for Query
parameters:
from typing import Annotated, Literal
from fastapi import FastAPI, Query
from pydantic import BaseModel, Field
app = FastAPI()
class FilterParams(BaseModel):
limit: int = Field(100, gt=0, le=100)
offset: int = Field(0, ge=0)
order_by: Literal["created_at", "updated_at"] = "created_at"
tags: list[str] = []
@​app.get("/items/")
async def read_items(filter_query: Annotated[FilterParams, Query()]):
return filter_query
Read the new docs: Query Parameter Models.
Header
Parameter Models
Use Pydantic models for Header
parameters:
from typing import Annotated
from fastapi import FastAPI, Header
from pydantic import BaseModel
app = FastAPI()
class CommonHeaders(BaseModel):
host: str
save_data: bool
if_modified_since: str | None = None
traceparent: str | None = None
x_tag: list[str] = []
@​app.get("/items/")
async def read_items(headers: Annotated[CommonHeaders, Header()]):
return headers
Read the new docs: Header Parameter Models.
Cookie
Parameter Models
Use Pydantic models for Cookie
parameters:
from typing import Annotated
from fastapi import Cookie, FastAPI
from pydantic import BaseModel
app = FastAPI()
class Cookies(BaseModel):
session_id: str
fatebook_tracker: str | None = None
googall_tracker: str | None = None
@​app.get("/items/")
async def read_items(cookies: Annotated[Cookies, Cookie()]):
return cookies
Read the new docs: Cookie Parameter Models.
Forbid Extra Query (Cookie, Header) Parameters
Use Pydantic models to restrict extra values for Query
parameters (also applies to Header
and Cookie
parameters).
To achieve it, use Pydantic's model_config = {"extra": "forbid"}
:
from typing import Annotated, Literal
from fastapi import FastAPI, Query
from pydantic import BaseModel, Field
app = FastAPI()
class FilterParams(BaseModel):
model_config = {"extra": "forbid"}
limit: int = Field(100, gt=0, le=100)
offset: int = Field(0, ge=0)
order_by: Literal["created_at", "updated_at"] = "created_at"
tags: list[str] = []
@​app.get("/items/")
async def read_items(filter_query: Annotated[FilterParams, Query()]):
return filter_query
This applies to Query
, Header
, and Cookie
parameters, read the new docs:
Features
-
✨ Add support for Pydantic models for parameters usingQuery
,Cookie
,Header
. MR #12199 by @tiangolo.
Translations
-
🌐 Add Portuguese translation fordocs/pt/docs/advanced/security/http-basic-auth.md
. MR #12195 by @ceb10n.
Internal
-
⬆ [pre-commit.ci] pre-commit autoupdate. MR #12204 by @pre-commit-ci[bot].
v0.114.2
Fixes
-
🐛 Fix form field regression withalias
. MR #12194 by @Wurstnase.
Translations
-
🌐 Add Portuguese translation fordocs/pt/docs/tutorial/request-form-models.md
. MR #12175 by @ceb10n. -
🌐 Add Chinese translation fordocs/zh/docs/project-generation.md
. MR #12170 by @waketzheng. -
🌐 Add Dutch translation fordocs/nl/docs/python-types.md
. MR #12158 by @maxscheijen.
Internal
-
💡 Add comments with instructions for Playwright screenshot scripts. MR #12193 by @tiangolo. -
➕ Add inline-snapshot for tests. MR #12189 by @tiangolo.
v0.114.1
Refactors
-
⚡ ️ Improve performance in request body parsing with a cache for internal model fields. MR #12184 by @tiangolo.
Docs
-
📝 Remove duplicate line in docs fordocs/en/docs/environment-variables.md
. MR #12169 by @prometek.
Translations
-
🌐 Add Portuguese translation fordocs/pt/docs/virtual-environments.md
. MR #12163 by @marcelomarkus. -
🌐 Add Portuguese translation fordocs/pt/docs/environment-variables.md
. MR #12162 by @marcelomarkus. -
🌐 Add Portuguese translation fordocs/pt/docs/tutorial/testing.md
. MR #12164 by @marcelomarkus. -
🌐 Add Portuguese translation fordocs/pt/docs/tutorial/debugging.md
. MR #12165 by @marcelomarkus. -
🌐 Add Korean translation fordocs/ko/docs/project-generation.md
. MR #12157 by @BORA040126.
Internal
-
⬆ Bump tiangolo/issue-manager from 0.5.0 to 0.5.1. MR #12173 by @dependabot[bot]. -
⬆ [pre-commit.ci] pre-commit autoupdate. MR #12176 by @pre-commit-ci[bot]. -
👷 Updateissue-manager.yml
. MR #12159 by @tiangolo. -
✏ ️ Fix typo infastapi/params.py
. MR #12143 by @surreal30.
v0.114.0
You can restrict form fields to only include those declared in a Pydantic model and forbid any extra field sent in the request using Pydantic's model_config = {"extra": "forbid"}
:
from typing import Annotated
from fastapi import FastAPI, Form
from pydantic import BaseModel
app = FastAPI()
class FormData(BaseModel):
username: str
password: str
model_config = {"extra": "forbid"}
@​app.post("/login/")
async def login(data: Annotated[FormData, Form()]):
return data
Read the new docs: Form Models - Forbid Extra Form Fields.
Features
-
✨ Add support for forbidding extra form fields with Pydantic models. MR #12134 by @tiangolo.
Docs
-
📝 Update docs, Form Models section title, to match config name. MR #12152 by @tiangolo.
Internal
-
✅ Update internal tests for latest Pydantic, including CI tweaks to install the latest Pydantic. MR #12147 by @tiangolo.
v0.113.0
Now you can declare form fields with Pydantic models:
from typing import Annotated
from fastapi import FastAPI, Form
from pydantic import BaseModel
app = FastAPI()
class FormData(BaseModel):
username: str
password: str
@​app.post("/login/")
async def login(data: Annotated[FormData, Form()]):
return data
Read the new docs: Form Models.
Features
-
✨ Add support for Pydantic models inForm
parameters. MR #12129 by @tiangolo.
Internal
-
🔧 Update sponsors: Coherence link. MR #12130 by @tiangolo.
v0.112.4
This release is mainly a big internal refactor to enable adding support for Pydantic models for Form
fields, but that feature comes in the next release.
This release shouldn't affect apps using FastAPI in any way. You don't even have to upgrade to this version yet. It's just a checkpoint.
Refactors
-
♻ ️ Refactor deciding ifembed
body fields, do not overwrite fields, compute once per router, refactor internals in preparation for Pydantic models inForm
,Query
and others. MR #12117 by @tiangolo.
Internal
-
⏪ ️ Temporarily revert "✨ Add support for Pydantic models inForm
parameters" to make a checkpoint release. MR #12128 by @tiangolo. -
✨ Add support for Pydantic models inForm
parameters. MR #12127 by @tiangolo. Reverted to make a checkpoint release with only refactors.
v0.112.3
This release is mainly internal refactors, it shouldn't affect apps using FastAPI in any way. You don't even have to upgrade to this version yet. There are a few bigger releases coming right after.
Refactors
-
♻ ️ Refactor internalcheck_file_field()
, rename toensure_multipart_is_installed()
to clarify its purpose. MR #12106 by @tiangolo. -
♻ ️ Rename internalcreate_response_field()
tocreate_model_field()
as it's used for more than response models. MR #12103 by @tiangolo. -
♻ ️ Refactor and simplify internal data fromsolve_dependencies()
using dataclasses. MR #12100 by @tiangolo. -
♻ ️ Refactor and simplify internalanalyze_param()
to structure data with dataclasses instead of tuple. MR #12099 by @tiangolo. -
♻ ️ Refactor and simplify dependencies data structures with dataclasses. MR #12098 by @tiangolo.
Docs
-
📝 Add External Link: Techniques and applications of SQLAlchemy global filters in FastAPI. MR #12109 by @TheShubhendra. -
📝 Add note abouttime.perf_counter()
in middlewares. MR #12095 by @tiangolo. -
📝 Tweak middleware code sampletime.time()
totime.perf_counter()
. MR #11957 by @domdent. -
🔧 Update sponsors: Coherence. MR #12093 by @tiangolo. -
📝 Fix async test example not to trigger DeprecationWarning. MR #12084 by @marcinsulikowski. -
📝 Updatedocs_src/path_params_numeric_validations/tutorial006.py
. MR #11478 by @MuhammadAshiqAmeer. -
📝 Update comma indocs/en/docs/async.md
. MR #12062 by @Alec-Gillis. -
📝 Update docs about serving FastAPI: ASGI servers, Docker containers, etc.. MR #12069 by @tiangolo. -
📝 Clarifyresponse_class
parameter, validations, and returning a response directly. MR #12067 by @tiangolo. -
📝 Fix minor typos and issues in the documentation. MR #12063 by @svlandeg. -
📝 Add note in Docker docs about ensuring graceful shutdowns and lifespan events withCMD
exec form. MR #11960 by @GPla.
Translations
-
🌐 Add Dutch translation fordocs/nl/docs/features.md
. MR #12101 by @maxscheijen. -
🌐 Add Portuguese translation fordocs/pt/docs/advanced/testing-events.md
. MR #12108 by @ceb10n. -
🌐 Add Portuguese translation fordocs/pt/docs/advanced/security/index.md
. MR #12114 by @ceb10n. -
🌐 Add Dutch translation fordocs/nl/docs/index.md
. MR #12042 by @svlandeg. -
🌐 Update Chinese translation fordocs/zh/docs/how-to/index.md
. MR #12070 by @synthpop123.
Internal
-
⬆ [pre-commit.ci] pre-commit autoupdate. MR #12115 by @pre-commit-ci[bot]. -
⬆ Bump pypa/gh-action-pypi-publish from 1.10.0 to 1.10.1. MR #12120 by @dependabot[bot]. -
⬆ Bump pillow from 10.3.0 to 10.4.0. MR #12105 by @dependabot[bot]. -
💚 Setinclude-hidden-files
toTrue
when using theupload-artifact
GH action. MR #12118 by @svlandeg. -
⬆ Bump pypa/gh-action-pypi-publish from 1.9.0 to 1.10.0. MR #12112 by @dependabot[bot]. -
🔧 Update sponsors link: Coherence. MR #12097 by @tiangolo. -
🔧 Update labeler config to handle sponsorships data. MR #12096 by @tiangolo. -
🔧 Update sponsors, remove Kong. MR #12085 by @tiangolo. -
⬆ [pre-commit.ci] pre-commit autoupdate. MR #12076 by @pre-commit-ci[bot]. -
👷 Updatelatest-changes
GitHub Action. MR #12073 by @tiangolo.
v0.112.2
Fixes
-
🐛 Fixallow_inf_nan
option for Param and Body classes. MR #11867 by @giunio-prc. -
🐛 Ensure thatapp.include_router
merges nested lifespans. MR #9630 by @Lancetnik.
Refactors
-
🎨 Fix typing annotation for semi-internalFastAPI.add_api_route()
. MR #10240 by @ordinary-jamie. -
⬆ ️ Upgrade version of Ruff and reformat. MR #12032 by @tiangolo.
Docs
-
📝 Fix a typo indocs/en/docs/virtual-environments.md
. MR #12064 by @aymenkrifa. -
📝 Add docs about Environment Variables and Virtual Environments. MR #12054 by @tiangolo. -
📝 Add Asyncer mention in async docs. MR #12037 by @tiangolo. -
📝 Move the Features docs to the top level to improve the main page menu. MR #12036 by @tiangolo. -
✏ ️ Fix import typo in reference example forSecurity
. MR #11168 by @0shah0. -
📝 Highlight correct line in tutorialdocs/en/docs/tutorial/body-multiple-params.md
. MR #11978 by @svlandeg. -
🔥 Remove Sentry link from Advanced Middleware docs. MR #12031 by @alejsdev. -
📝 Clarify management tasks for translations, multiples files in one MR. MR #12030 by @tiangolo. -
📝 Edit the link to the OpenAPI "Responses Object" and "Response Object" sections in the "Additional Responses in OpenAPI" section. MR #11996 by @VaitoSoi. -
🔨 Specifyemail-validator
dependency with dash. MR #11515 by @jirikuncar. -
🌐 Add Spanish translation fordocs/es/docs/project-generation.md
. MR #11947 by @alejsdev. -
📝 Fix minor typo. MR #12026 by @MicaelJarniac. -
📝 Several docs improvements, tweaks, and clarifications. MR #11390 by @nilslindemann. -
📝 Add missingcompresslevel
parameter on docs forGZipMiddleware
. MR #11350 by @junah201. -
📝 Fix inconsistent response code when item already exists in docs for testing. MR #11818 by @lokomilo. -
📝 Updatedocs/en/docs/tutorial/body.md
with Python 3.10 union type example. MR #11415 by @rangzen.
Translations
-
🌐 Add Portuguese translation fordocs/pt/docs/tutorial/request_file.md
. MR #12018 by @Joao-Pedro-P-Holanda. -
🌐 Add Japanese translation fordocs/ja/docs/learn/index.md
. MR #11592 by @ukwhatn. -
📝 Update Spanish translation docs for consistency. MR #12044 by @alejsdev. -
🌐 Update Chinese translation fordocs/zh/docs/tutorial/dependencies/dependencies-with-yield.md
. MR #12028 by @xuvjso. -
📝 Update FastAPI People, do not translate to have the most recent info. MR #12034 by @tiangolo. -
🌐 Update Urdu translation fordocs/ur/docs/benchmarks.md
. MR #10046 by @AhsanSheraz.
Internal
-
⬆ [pre-commit.ci] pre-commit autoupdate. MR #12046 by @pre-commit-ci[bot]. -
🔧 Update coverage config files. MR #12035 by @tiangolo. -
🔨 Standardize shebang across shell scripts. MR #11942 by @gitworkflows. -
⬆ Update sqlalchemy requirement from <1.4.43,>=1.3.18 to >=1.3.18,<2.0.33. MR #11979 by @dependabot[bot]. -
🔊 Remove old ignore warnings. MR #11950 by @tiangolo. -
⬆ ️ Upgrade griffe-typingdoc for the docs. MR #12029 by @tiangolo. -
🙈 Add .coverage* to.gitignore
. MR #11940 by @gitworkflows. -
⚙ ️ Record and show test coverage contexts (what test covers which line). MR #11518 by @slafs.
Configuration
-
If you want to rebase/retry this MR, check this box
This MR has been generated by Renovate Bot.