Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: let's improve "DTO: basic use" page #3800

Open
sobolevn opened this issue Oct 15, 2024 · 2 comments
Open

Docs: let's improve "DTO: basic use" page #3800

sobolevn opened this issue Oct 15, 2024 · 2 comments
Labels
Documentation 📚 This is related to documentation DTOs This is related to our DTO feature

Comments

@sobolevn
Copy link
Member

sobolevn commented Oct 15, 2024

Summary

Right now https://docs.litestar.dev/latest/usage/dto/0-basic-use.html starts with:

Снимок экрана 2024-10-15 в 14 51 26

and I was like: wait a second!

Here we demonstrate how to declare DTO types to your route handlers.
For demonstration purposes, we assume that we are working with a data model User, and already have two DTO types created in our application, UserDTO, and UserReturnDTO.

So, do we demonstrate how to declare them? Or do we have them already declared?

Let's go further: https://docs.litestar.dev/latest/usage/dto/0-basic-use.html#defining-dtos-on-handlers

What does this example show users?

from litestar import post

from .models import User, UserDTO

@post(dto=UserDTO)
def create_user(data: User) -> User:
    return data

When I was reading it - I had no idea what User is, what UserDTO is, why do I need to use dto= at all.

I propose to refactor the first half of this guide, because right now it is really hard to understand.


Note

While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar
@sobolevn sobolevn added the Documentation 📚 This is related to documentation label Oct 15, 2024
@Alc-Alc
Copy link
Contributor

Alc-Alc commented Oct 15, 2024

I do not mean to dismiss the issue, but for anyone who stumbles upon this, I would like to point out this tutorial.

As a start (until its decided how best to reword it), maybe the tutorial can be linked in the "basic use" page so it at least provides some context?

@sobolevn
Copy link
Member Author

Yes, this one is really clear! 👏

(I did read all lines really, but the structure looks very promising)

@sobolevn sobolevn added the DTOs This is related to our DTO feature label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation 📚 This is related to documentation DTOs This is related to our DTO feature
Projects
Status: Triage
Development

No branches or pull requests

2 participants