-
-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rework and simplify DTOs (#2088)
* feat(internal): reworked DTO logic * feat(internal): cleanup listeners * chore(compat): python 3.8 fixes * feat: update plugins access to use registry * fix(dto): resolve issue 1929 * Update tests/unit/test_contrib/test_sqlalchemy/test_serialization_plugin.py * Update tests/unit/test_contrib/test_sqlalchemy/test_serialization_plugin.py * chore(dead code): cleanup * Update litestar/dto/base_dto.py Co-authored-by: Janek Nouvertné <25355197+provinzkraut@users.noreply.github.com> * chore: address review comments * Update litestar/handlers/base.py Co-authored-by: Janek Nouvertné <25355197+provinzkraut@users.noreply.github.com> * chore: address review comments * chore: make handler_id unique --------- Co-authored-by: Janek Nouvertné <25355197+provinzkraut@users.noreply.github.com> Co-authored-by: Cody Fincher <204685+cofin@users.noreply.github.com>
- Loading branch information
1 parent
fc6ed28
commit b9814c2
Showing
100 changed files
with
1,551 additions
and
2,256 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
base_dto | ||
======== | ||
|
||
.. automodule:: litestar.dto.base_dto | ||
:members: |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
dataclass_dto | ||
============= | ||
|
||
.. automodule:: litestar.dto.dataclass_dto | ||
:members: |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
msgspec_dto | ||
=========== | ||
|
||
.. automodule:: litestar.dto.msgspec_dto | ||
:members: |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
docs/usage/dto/1-dto-factory.rst → docs/usage/dto/1-abstract-dto.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Implementing Cusotm DTO Classes | ||
=============================== | ||
|
||
While Litestar maintains a suite of DTO factories, it is possible to create your own DTOs. To do so, you must implement | ||
the :class:`AbstractDTO <litestar.dto.base_dto.AbstractDTO>` abc. | ||
|
||
The following is a description of the methods of the protocol, and how they are used by Litestar. For detailed | ||
information on the signature of each method, see the :class:`reference docs <litestar.dto.base_dto.AbstractDTO>`. | ||
|
||
Abstract Methods | ||
~~~~~~~~~~~~~~~~ | ||
|
||
These methods must be implemented on any :class:`AbstractDTO <litestar.dto.base_dto.AbstractDTO>` subtype. | ||
|
||
``generate_field_definitions`` | ||
------------------------------ | ||
|
||
This method receives the model type for the DTO and it should return a generator yielding | ||
:class:`DTOFieldDefinition<litestar.dto.data_structures.DTOFieldDefinition>` instances corresponding with | ||
the model fields. | ||
|
||
``detect_nested_field`` | ||
----------------------- | ||
|
||
This method receives a :class:`FieldDefinition<litestar.typing.FieldDefinition>` instance it it should return a boolean | ||
indicating whether the field is a nested model field. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,5 +79,5 @@ Contents | |
.. toctree:: | ||
|
||
0-basic-use | ||
1-dto-factory | ||
2-dto-interface | ||
1-abstract-dto | ||
2-creating-custom-dto-classes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.