django-ninja
django-ninja copied to clipboard
feat: support returning pydantic model as result
allow returning pydantic model as result and pass converting and validation
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")
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
well coverage shows that it never actually calls the needed line
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?
could we merge it ?
@vitalik , I have some more ideas to implement, but I think you are so busy to maintain and accept PRs , do you have any substitute ?