diff --git a/docs/release-notes/changelog.rst b/docs/release-notes/changelog.rst index 67023148a3..c03374a813 100644 --- a/docs/release-notes/changelog.rst +++ b/docs/release-notes/changelog.rst @@ -3,6 +3,184 @@ 2.x Changelog ============= +.. changelog:: 2.12.0 + :date: 2024-09-21 + + .. change:: Fix overzealous warning for greedy middleware ``exclude`` pattern + :type: bugfix + :pr: 3712 + + Fix a bug introduced in ``2.11.0`` (https://github.com/litestar-org/litestar/pull/3700), + where the added warning for a greedy pattern use for the middleware ``exclude`` + parameter was itself greedy, and would warn for non-greedy patterns, e.g. + ``^/$``. + + .. change:: Fix dangling coroutines in request extraction handling cleanup + :type: bugfix + :pr: 3735 + :issue: 3734 + + Fix a bug where, when a required header parameter was defined for a request that + also expects a request body, failing to provide the header resulted in a + :exc:`RuntimeWarning`. + + .. code-block:: python + + @post() + async def handler(data: str, secret: Annotated[str, Parameter(header="x-secret")]) -> None: + return None + + If the ``x-secret`` header was not provided, warning like this would be seen: + + .. code-block:: + + RuntimeWarning: coroutine 'json_extractor' was never awaited + + + .. change:: OpenAPI: Correctly handle ``type`` keyword + :type: bugfix + :pr: 3715 + :issue: 3714 + + Fix a bug where a type alias created with the ``type`` keyword would create an + empty OpenAPI schema entry for that parameter + + .. change:: OpenAPI: Ensure valid schema keys + :type: bugfix + :pr: 3635 + :issue: 3630 + + Ensure that generated schema component keys are always valid according to + `ยง 4.8.7.1 `_ of the + OpenAPI specification. + + + .. change:: OpenAPI: Correctly handle ``msgspec.Struct`` tagged unions + :type: bugfix + :pr: 3742 + :issue: 3659 + + Fix a bug where the OpenAPI schema would not include the struct fields + implicitly generated by msgspec for its + `tagged union `_ + support. + + The tag field of the struct will now be added as a ``const`` of the appropriate + type to the schema. + + + .. change:: OpenAPI: Fix Pydantic 1 constrained string with default factory + :type: bugfix + :pr: 3721 + :issue: 3710 + + Fix a bug where using a Pydantic model with a ``default_factory`` set for a + constrained string field would raise a :exc:`SerializationException`. + + .. code-block:: python + + class Model(BaseModel): + field: str = Field(default_factory=str, max_length=600) + + + .. change:: OpenAPI/DTO: Fix missing Pydantic 2 computed fields + :type: bugfix + :pr: 3721 + :issue: 3656 + + Fix a bug that would lead to Pydantic computed fields to be ignored during + schema generation when the model was using a + :class:`~litestar.contrib.pydantic.PydanticDTO`. + + .. code-block:: python + :caption: Only the ``foo`` field would be included in the schema + + class MyModel(BaseModel): + foo: int + + @computed_field + def bar(self) -> int: + return 123 + + @get(path="/", return_dto=PydanticDTO[MyModel]) + async def test() -> MyModel: + return MyModel.model_validate({"foo": 1}) + + .. change:: OpenAPI: Fix Pydantic ``json_schema_extra`` overrides only being merged partially + :type: bugfix + :pr: 3721 + :issue: 3656 + + Fix a bug where ``json_schema_extra`` were not reliably extracted from Pydantic + models and included in the OpenAPI schema. + + .. code-block:: python + :caption: Only the title set directly on the field would be used for the schema + + class Model(pydantic.BaseModel): + with_title: str = pydantic.Field(title="new_title") + with_extra_title: str = pydantic.Field(json_schema_extra={"title": "more_new_title"}) + + + @get("/example") + async def example_route() -> Model: + return Model(with_title="1", with_extra_title="2") + + + .. change:: Support strings in ``media_type`` for ``ResponseSpec`` + :type: feature + :pr: 3729 + :issue: 3728 + + Accept strings for the ``media_type`` parameter of :class:`~litestar.openapi.datastructures.ResponseSpec`, + making it behave the same way as :paramref:`~litestar.response.Response.media_type`. + + + .. change:: OpenAPI: Allow customizing schema component keys + :type: feature + :pr: 3738 + + Allow customizing the schema key used for a component in the OpenAPI schema. + The supplied keys are enforced to be unique, and it is checked that they won't + be reused across different types. + + The keys can be set with the newly introduced ``schema_component_key`` parameter, + which is available on :class:`~litestar.params.KwargDefinition`, + :func:`~litestar.params.Body` and :func:`~litestar.params.Parameter`. + + .. code-block:: python + :caption: Two components will be generated: ``Data`` and ``not_data`` + + @dataclass + class Data: + pass + + @post("/") + def handler( + data: Annotated[Data, Parameter(schema_component_key="not_data")], + ) -> Data: + return Data() + + @get("/") + def handler_2() -> Annotated[Data, Parameter(schema_component_key="not_data")]: + return Data() + + .. change:: Raise exception when body parameter is annotated with non-bytes type + :type: feature + :pr: 3740 + + Add an informative error message to help avoid the common mistake of attempting + to use the ``body`` parameter to receive validated / structured data by + annotating it with a type such as ``list[str]``, instead of ``bytes``. + + + .. change:: OpenAPI: Default to ``latest`` scalar version + :type: feature + :pr: 3747 + + Change the default version of the scalar OpenAPI renderer to ``latest`` + + .. changelog:: 2.11.0 :date: 2024-08-27 diff --git a/pyproject.toml b/pyproject.toml index 78a34ef862..0a52cefcbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,7 @@ maintainers = [ name = "litestar" readme = "README.md" requires-python = ">=3.8,<4.0" -version = "2.11.0" +version = "2.12.0" [project.urls] Blog = "https://blog.litestar.dev" diff --git a/tools/prepare_release.py b/tools/prepare_release.py index c0cee01765..53018a6fa6 100644 --- a/tools/prepare_release.py +++ b/tools/prepare_release.py @@ -313,7 +313,7 @@ def build_changelog_entry(release_info: ReleaseInfo, interactive: bool = False) for prs in release_info.pull_requests.values(): for pr in prs: cc_type = pr.cc_type - if cc_type in change_types or (interactive and click.confirm(f"Ignore PR #{pr.number} {pr.title!r}?")): + if cc_type in change_types or (interactive and click.confirm(f"Include PR #{pr.number} {pr.title!r}?")): doc.add_change(pr) else: click.secho(f"Ignoring change with type {cc_type}", fg="yellow")