Skip to content

Commit 7c25540

Browse files
committed
chore: Prepare release 2.24.0
1 parent 80eccf4 commit 7c25540

4 files changed

Lines changed: 57 additions & 3 deletions

File tree

docs/release-notes/changelog.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,58 @@
33
Litestar 2 Changelog
44
====================
55

6+
.. changelog:: 2.24.0
7+
:date: 2026-06-11
8+
9+
.. change:: Fix OpenAPI schema incorrectly marking nullable required fields as not required
10+
:type: bugfix
11+
:pr: 4687
12+
:issue: 4673
13+
14+
Fields typed as ``T | None`` (nullable) without a default value are now correctly
15+
included in the OpenAPI schema's ``required`` array. Previously, Litestar conflated
16+
nullability (the type can be ``None``) with optionality (having a default value),
17+
causing the generated schema to diverge from the OpenAPI 3.1.0 specification.
18+
19+
This affected all model types: dataclasses, msgspec Structs, attrs classes, and
20+
Pydantic models. For example, a field ``name: int | None`` with no default was
21+
previously excluded from ``required``; it is now correctly included.
22+
23+
Runtime request validation behavior is unchanged; nullable parameters without
24+
defaults were already enforced as required at the validation layer.
25+
26+
.. change:: ``data`` declared in dependency only not included in OpenAPI schema
27+
:type: bugfix
28+
:pr: 4833
29+
30+
When ``data`` was declared in a dependency function but not in the handler, the
31+
request body was missing from the OpenAPI schema:
32+
33+
.. code-block:: python
34+
35+
from litestar import post, Litestar
36+
37+
async def some_dependency(data: list[str]) -> list[str]:
38+
return data
39+
40+
@post("/", dependencies={"some_data": some_dependency})
41+
async def handler(some_data: list[str]) -> None:
42+
43+
Ensure ``data`` is always documented, and ensure that ``data`` annotations are
44+
compatible between dependencies and handler functions.
45+
46+
.. change:: Deprecate implicitly declared dependencies
47+
:type: feature
48+
:pr: 4824
49+
50+
Deprecate implicitly declaring dependencies. Instead, dependencies should be
51+
explicitly declared with :data:`~litestar.di.NamedDependency`. Not doing so
52+
will raise a :exc:`DeprecationWarning`. Implicitly declared dependencies will be
53+
removed in Litestar 3.0
54+
55+
.. seealso:: :doc:`/topics/explicit_declarations`
56+
57+
658
.. changelog:: 2.23.0
759
:date: 2026-05-29
860

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ maintainers = [
6565
name = "litestar"
6666
readme = "docs/PYPI_README.md"
6767
requires-python = ">=3.8,<4.0"
68-
version = "2.23.0"
68+
version = "2.24.0"
6969

7070
[project.urls]
7171
Blog = "https://blog.litestar.dev"

tests/unit/test_openapi/conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ def get_persons(
3737
# required query parameters below
3838
page: FromQuery[int],
3939
name: FromQuery[Optional[Union[str, List[str]]]], # intentionally without default
40-
lucky_number: Annotated[Optional[LuckyNumber], QueryParameter(examples=[Example(value=LuckyNumber.SEVEN)])] = 1,
40+
lucky_number: Annotated[
41+
Optional[LuckyNumber], QueryParameter(examples=[Example(value=LuckyNumber.SEVEN)])
42+
] = 1,
4143
# header parameter
4244
secret_header: Annotated[str, HeaderParameter(name="secret")],
4345
# cookie parameter

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)