django-rest-swagger
django-rest-swagger copied to clipboard
Primary key is not detected as GET parameter
This is the output:
these are the URLS:
path('items/<int:pk>/', ItemDetail.as_view()),
path('items/<int:pk>/set_rating/', ItemRating.as_view()),
ItemDetail
uses the GenericAPIView
as a base class, with a ModelSerializer
as serializer_class. Here swagger detects that the pk param inside the URL is a UUID.
For ItemRating
, I added get_serializer
manually, and it returns
class MySerializer(serializers.Serializer):
pk = serializers.UUIDField(format='hex_verbose', read_only=True)
rating = serializers.IntegerField()
return MySerializer()
Is there any way to tell swagger that pk
is a UUID primary key for the object in the GET parameter?
(I tried pk, id and uuid as field names for the ItemRating view. No change)
Hey, I am facing the same issue. The only difference is my URL has string and swagger asks me to input int. @y-spreen How could you resolve this?
@ShubhankarKapoor I think I ended up just using the Model Serializer at all times. Simply for the url param, without any additional fields used.