question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

there is any way to change pydantic body base incoming request?

See original GitHub issue

in 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:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ycdcommented, Mar 2, 2021

@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.

i use custom pydantic body for each user. any user can send custom pydantic body and we no that user can access on pydantic body. can check permission user before check body and set own custom pydantic body ?

Can you rephrase this?

1reaction
insomnescommented, Mar 2, 2021

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found