Use Pydantic BaseModel for QueryParameters doesn't work? #1315
Labels
enhancement
New feature or request
fix confirmation pending
issue has been fixed and confirmation from issue reporter is pending
Describe the bug
I can get both responses and requests to work fine using pydantic by simply using a pydantic BaseModel instead of a
rest_framework.serializers.Serializer
. However, when I try to do the same for Parameters in a GET-function it doesn't work. I have tried many ways, but either there is no result showing it the Schema generation fails.I'm currently using:
To Reproduce
Working good:
But if I change from
QueryParamsSerializer
toQueryParams
, I first of all get a type error and it is not possible to generate any schema when I try to open up theSpectacularAPIView.as_view()
orSpectacularSwaggerView.as_view()
.I can use the same pydantic class as a response serializer, but not for parameters.
If I try to use a POST-function everything works fine as well.
I have also tried to search the documentation about this and also for issues here in the Github repo, as well as extensively trying to interrogate various AI resources and searching on Google.
To be honest, I don't know if this is a bug or if I am doing it wrong, but I honestly feel a bit lost here on how to do in that case. Can anyone please advise?
Expected behavior
That using a pydantic model for query parameters generate the correct schema and swagger view as using a
rest_framework.serializers.Serializer
.The text was updated successfully, but these errors were encountered: