[FEATURE REQUEST] Return pydantic model directly and skip validation
See original GitHub issueHi,
Is there any way to return pydantic models directly, or to skip the validation?
I tend to do something like
@v.get('/echo')
@api.validate(query=m.EchoReq, resp=Response(HTTP_200=m.EchoRes), tags=['example'])
def echo():
"""Replies with the queried text value"""
message = request.context.query.text
result = m.EchoRes(result=message)
return result.json()
This doesn’t play nicely with pydantic alias
-es though.
I think the issue is that my model returns the real name and then the spectree validation fails since pydantic expected the alias name.
Can I skip the validation part but keep the route-to-model association for the doc generation?
Thanks
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Is it possible to skip validation in ORM mode? #1212 - GitHub
There is documentation for the construct classmethod that is much faster due to bypassing validation. I am now wondering if a similar thing ......
Read more >Pydantic V2 Plan
pydantic -core operates on a tree of validators with no "model" type required at the base of that tree. It can therefore validate...
Read more >How to Validate Your Data with Custom Validators of Pydantic ...
First, let's create a standard pydantic model and use the default validators to validate and normalize our data. A pydantic model is simply ......
Read more >How we validate input data using pydantic
Pydantic raises a ValidationError when the validation of the model fails, stating which field, i.e. attribute, raised the error and why. In this ......
Read more >Validators - pydantic
Custom validation and complex relationships between objects can be achieved using the validator decorator. Python 3.7 and above. from pydantic import BaseModel ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah, sure.
Sure. Take your time.