Closed marlier closed 2 years ago
Hi,
you threw me off there for a second. So if I get it right everything in @extend_schema
is ignored and only the attr serializer_class
is considered. the core issue is this:
so change create
to post
and it will work.
fyi: this is a third party lib and thus we provide functionality through extensions. Though they do not trigger on subclasses by default, but generally extensions do take precedence over decoration. Since you are subclassing, decoration is fine but you might want to have a look at how the response serializer is estimated. Also notice that we decorate the post
in the extension for exactly the same reason as above.
Gotcha -- that makes sense, and adding a post method (that just calls super().post()
) with the annotation did, indeed, fix it. Appreciate the help!
Description
I have a custom Registration view, which derives from dj_rest_auth's RegisterView. The
create()
method is over-ridden, and takes and returns custom objects, which have appropriate serializers.I have annotated the
create()
method with @extend_schema, but neither therequest=
norresponses={...}
parameters are being respected.To Reproduce The code looks like this:
On running
python manage.py spectacular --file openapi-schema.json
, the following openapi schema is generated:As you can see, the serializer provided in the @extend_schema
request=
parameter is not being respected.If I instead set serializer_class to the body parameter value:
Then the resulting schema is:
Finally, if I remove the serializer_class parameter entirely:
the generated schema uses the Register serializer, which is what is set on the dj_rest_auth RegisterView:
Expected behavior Expected behavior is that the settings in @extend_schema will be respected, meaning that this code:
Will result in this schema: