there is any way to change pydantic body base incoming request?
See original GitHub issuein django rest framework we use get_serializer_class
in GenericAPIView
to change serializer base incoming request .
I use multiple type user and base on each user needs different pydantic body. for solve and handling i use multiple route. there is any way to change pydantic body base incoming request?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
A Guide to FastAPI Request Body Using Pydantic BaseModel
Learn how to use FastAPI Request Body by leveraging the power of Pydantic BaseModel class to convert and validate incoming requests.
Read more >How to use a Pydantic model with Form data in FastAPI?
The first step to working out what's going wrong is to inspect the POST request and see what's being submitted. – SColvin. Feb...
Read more >Body - Nested Models - FastAPI
With FastAPI, you can define, validate, document, and use arbitrarily deeply nested models (thanks to Pydantic). List fields¶. You can define an attribute...
Read more >The Ultimate FastAPI Tutorial Part 4 - Pydantic Schemas
By specifying a Pydantic schema, we are able to automatically validate incoming requests, ensuring that their bodies adhere to our schema. To ...
Read more >How we validate input data using pydantic
This is quite similar to how FastAPI uses pydantic for input validation: the input to the API call is json, which in Python...
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 Free
Top 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
@insomnes as far as i understand from the example he gave above, the fields are the same, but he wants to use different serializer for same fields with different types.
Can you rephrase this?
@zedrood hello! You can try to use
def handler(user: Union[UserModelA, UserModelB, UserModelC]):
if you have different user models which have some distinct fields.