|
3 | 3 | Litestar 2 Changelog |
4 | 4 | ==================== |
5 | 5 |
|
| 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 | + |
6 | 58 | .. changelog:: 2.23.0 |
7 | 59 | :date: 2026-05-29 |
8 | 60 |
|
|
0 commit comments