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

feat: support returning pydantic model as result #1338

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mh-alahdadian
Copy link

@mh-alahdadian mh-alahdadian commented Nov 17, 2024

allow returning pydantic model as result and pass converting and validation

@vitalik
Copy link
Owner

vitalik commented Nov 22, 2024

Hi @mh-alahdadian

could you also add test case for multiple response codes ?

@router.get("/check_pydantic", response={200: UserModel, 201: Message})
def check_pydantic(request):
    if something:
          return 201, {"message": "Created"}
    return 200, UserModel(id=1, user_name="John")

@mh-alahdadian
Copy link
Author

Hi @mh-alahdadian

could you also add test case for multiple response codes ?

@router.get("/check_pydantic", response={200: UserModel, 201: Message})
def check_pydantic(request):
    if something:
          return 201, {"message": "Created"}
    return 200, UserModel(id=1, user_name="John")

done

@vitalik
Copy link
Owner

vitalik commented Dec 6, 2024

well coverage shows that it never actually calls the needed line

@mh-alahdadian
Copy link
Author

well coverage shows that it never actually calls the needed line

fixed it too
I'm not sure why github pipeline is not running on pull request when I push new changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants