Update dependency fastapi to ~=0.115.0 #17

Merged
profitroll merged 1 commits from renovate/fastapi-0.x into dev 2024-09-18 09:25:03 +03:00
Collaborator

This PR contains the following updates:

Package Update Change
fastapi (changelog) minor ~=0.114.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.

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.

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

Configuration

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

🚦 Automerge: Enabled.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

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


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

This PR has been generated by Renovate Bot.

This PR contains the following updates: | Package | Update | Change | |---|---|---| | [fastapi](https://github.com/fastapi/fastapi) ([changelog](https://fastapi.tiangolo.com/release-notes/)) | minor | `~=0.114.0` -> `~=0.115.0` | --- ### Release Notes <details> <summary>fastapi/fastapi (fastapi)</summary> ### [`v0.115.0`](https://github.com/fastapi/fastapi/releases/tag/0.115.0) [Compare Source](https://github.com/fastapi/fastapi/compare/0.114.2...0.115.0) ##### Highlights Now you can declare `Query`, `Header`, and `Cookie` parameters with Pydantic models. 🎉 ##### `Query` Parameter Models Use Pydantic models for `Query` parameters: ```python 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] = [] @&#8203;app.get("/items/") async def read_items(filter_query: Annotated[FilterParams, Query()]): return filter_query ``` Read the new docs: [Query Parameter Models](https://fastapi.tiangolo.com/tutorial/query-param-models/). ##### `Header` Parameter Models Use Pydantic models for `Header` parameters: ```python 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] = [] @&#8203;app.get("/items/") async def read_items(headers: Annotated[CommonHeaders, Header()]): return headers ``` Read the new docs: [Header Parameter Models](https://fastapi.tiangolo.com/tutorial/header-param-models/). ##### `Cookie` Parameter Models Use Pydantic models for `Cookie` parameters: ```python 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 @&#8203;app.get("/items/") async def read_items(cookies: Annotated[Cookies, Cookie()]): return cookies ``` Read the new docs: [Cookie Parameter Models](https://fastapi.tiangolo.com/tutorial/cookie-param-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"}`: ```python 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] = [] @&#8203;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: - [Forbid Extra Query Parameters](https://fastapi.tiangolo.com/tutorial/query-param-models/#forbid-extra-query-parameters) - [Forbid Extra Headers](https://fastapi.tiangolo.com/tutorial/header-param-models/#forbid-extra-headers) - [Forbid Extra Cookies](https://fastapi.tiangolo.com/tutorial/cookie-param-models/#forbid-extra-cookies) ##### Features - ✨ Add support for Pydantic models for parameters using `Query`, `Cookie`, `Header`. PR [#&#8203;12199](https://github.com/fastapi/fastapi/pull/12199) by [@&#8203;tiangolo](https://github.com/tiangolo). ##### Translations - 🌐 Add Portuguese translation for `docs/pt/docs/advanced/security/http-basic-auth.md`. PR [#&#8203;12195](https://github.com/fastapi/fastapi/pull/12195) by [@&#8203;ceb10n](https://github.com/ceb10n). ##### Internal - ⬆ \[pre-commit.ci] pre-commit autoupdate. PR [#&#8203;12204](https://github.com/fastapi/fastapi/pull/12204) by [@&#8203;pre-commit-ci\[bot\]](https://github.com/apps/pre-commit-ci). </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4zNS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMzUuMCIsInRhcmdldEJyYW5jaCI6ImRldiJ9-->
Renovate added 1 commit 2024-09-17 22:30:32 +03:00
Renovate scheduled this pull request to auto merge when all checks succeed 2024-09-17 22:30:33 +03:00
profitroll merged commit 32bb985f52 into dev 2024-09-18 09:25:03 +03:00
profitroll deleted branch renovate/fastapi-0.x 2024-09-18 09:25:03 +03:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: GarbageReminder/API#17
No description provided.