Skip to content

fix(deps): update dependency fastapi to ^0.115.0

renovate requested to merge renovate/fastapi into master

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

Compare Source

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 using Query, Cookie, Header. MR #​12199 by @​tiangolo.
Translations
  • 🌐 Add Portuguese translation for docs/pt/docs/advanced/security/http-basic-auth.md. MR #​12195 by @​ceb10n.
Internal

v0.114.2

Compare Source

Fixes
Translations
Internal

v0.114.1

Compare Source

Refactors
  • ️ Improve performance in request body parsing with a cache for internal model fields. MR #​12184 by @​tiangolo.
Docs
  • 📝 Remove duplicate line in docs for docs/en/docs/environment-variables.md. MR #​12169 by @​prometek.
Translations
Internal

v0.114.0

Compare Source

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
Docs
Internal
  • Update internal tests for latest Pydantic, including CI tweaks to install the latest Pydantic. MR #​12147 by @​tiangolo.

v0.113.0

Compare Source

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
Internal

v0.112.4

Compare Source

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 if embed body fields, do not overwrite fields, compute once per router, refactor internals in preparation for Pydantic models in Form, Query and others. MR #​12117 by @​tiangolo.
Internal
  • ️ Temporarily revert " Add support for Pydantic models in Form parameters" to make a checkpoint release. MR #​12128 by @​tiangolo.
  • Add support for Pydantic models in Form parameters. MR #​12127 by @​tiangolo. Reverted to make a checkpoint release with only refactors.

v0.112.3

Compare Source

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 internal check_file_field(), rename to ensure_multipart_is_installed() to clarify its purpose. MR #​12106 by @​tiangolo.
  • ️ Rename internal create_response_field() to create_model_field() as it's used for more than response models. MR #​12103 by @​tiangolo.
  • ️ Refactor and simplify internal data from solve_dependencies() using dataclasses. MR #​12100 by @​tiangolo.
  • ️ Refactor and simplify internal analyze_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
Translations
Internal

v0.112.2

Compare Source

Fixes
Refactors
Docs
Translations
Internal

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this MR and you won't be reminded about this update again.


  • If you want to rebase/retry this MR, check this box

This MR has been generated by Renovate Bot.

Edited by renovate

Merge request reports