Open matiasAS opened 1 year ago
screenshots 2 and 3 are identical. what is your @extend_schema()
?
you may want to use this:
@extend_schema(responses=inline_serializer(
name='BusinessSerializer',
fields={
'business': serializers.CharField(),
}
))
#OR
@extend_schema(responses={200:inline_serializer(...)})
@tfranzel sorry, @extend_schema is:
I have made those changes, but what I want to say is that apparently as my response of type JsonResponse comes from the dispatcher, drf-spectacular does not recognize it and asks me to use GenericAPIView or ApiView classes, but I prefer api view function Regards
You can use ApiView
for everything. No problem there. the @extend_schema()
decorator must be above @api_view()
The warning is because some information is missing and spectacular is unable to guess it. When you provide that information manually, it will work.
@tfranzel and these errors: ...../api/v1/views.py: Error [create_irrigation_sector_group]: unable to guess serializer. This is graceful fallback handling for APIViews. Consider using GenericAPIView as view base class, if view is under your control. Either way you may want to add a serializer_class (or method). Ignoring view for now.
what is the solution?
every time you use ApiView
or @api_view
, you must provide all the info through @extend_schema
which would otherwise be available naturally in a ViewSet
.
You did good with the id
param and the responses. That should be fine. Without knowing more, I can only guess this is a POST
and spectacular attempts to retrieve the request
serializer and fails there. try also adding that one with @extend_schema(..., request=...)
.
P.S That many=False
does nothing like that.
@matiasAS
You have to add request=SomeSerializer
in your @extend_schema
decorator.
Hello, my endpoint structure in django is the following:
dispatcher function:
and @extend_schema :
I need you to acknowledge that in my response status code 200 is
how do i do that? please help
Regards Matias