django-rest-swagger
django-rest-swagger copied to clipboard
swagger UI not able to generate URL like /api/v1/foo/?bar=one&bar=two&bar=three
I am using
window.swaggerUi.api.swaggerVersion "2.0"
I have written a detailed description of the problem on SO. Only one person has commented on my post. They also seem to believe that the problem is a bug.
I'll repeat the details here.
I am using django-rest-swagger==2.1.2 and djangorestframework==3.7.7 and I have a view that looks like this:
class PendingRequests(generics.GenericAPIView):
...
filter_backends = (PendingRequestsFilter,)
def get(self, request):
...
request_status = request.GET.getlist('status')
request_start_date = request.GET.get('start_date')
request_end_date = request.GET.get('end_date')
...
and I have defined a filter like so:
class PendingRequestsFilter(BaseFilterBackend):
def get_schema_fields(self, view):
fields = [
coreapi.Field(name="status", description="Statuses of the Requests", required=False, location='query', example='active'),
coreapi.Field(name="status", description="Statuses of the Requests", required=False, location='query', example='pending'),
coreapi.Field(name="status", description="Statuses of the Requests", required=False, location='query', example='inactive'),
coreapi.Field(name="start_date", description="Start Date of the Request (YYYY-MM-DD)", required=False, location='query', example='2525-12-25'),
coreapi.Field(name="end_date", description="End Date of the Request (YYYY-MM-DD)", required=False, location='query', example='2525-12-26'),
]
return fields
This results in my swagger UI for this view looking like this:

But when I enter different status like so ...

... and click 'try it out' I get a Request URL that looks like this:
http://myserver:4800/api/v1/sudorequests/requests/?status=pending&status=pending&status=pending
Note that status=pending is repeated three times. I wanted to get a Request URL that looks more like this:
http://myserver:4800/api/v1/sudorequests/requests/?status=inactive&status=active&status=pending