swagger-api / swagger-api/swagger-ui
filtering with multiple values not working
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Hello,
I'm currently using Swagger with Django to test my data but the filter doesn't seem to work.
Indeed, i want to filter by the field 'number' which is an int and i'm using the parameter 'in'.
It seems like swagger doesn't recognize comma separators because it works with one value like 1 or 1.2 but not with 1,2 or 1,2,3.
It seems it is expecting int values so thats why it doesn't work with 1,2.
I'm pretty sure the problem is from Swagger because the filtering with multiple parameters works fine via url.
Here is the structure of my model:
class GSClass(models.Model):
number = models.IntegerField(
unique=True,
help_text="number of the class."
)
heading = models.TextField(
max_length=4092,
help_text="heading of the class.")
Here is my view:
class ClassList(generics.ListCreateAPIView):
queryset = GSClass.objects.all()
serializer_class = GSClassSerializer
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
filter_backends = [filters.SearchFilter, django_filters.rest_framework.DjangoFilterBackend]
filterset_class = GSClassFilter
search_fields = ['heading','note','terms__text']
def perform_create(self, serializer):
serializer.save(owner=self.request.user)
And my filter:
class GSClassFilter(rest_framework.FilterSet):
class Meta:
model = GSClass
fields = {
'number':['in'],
}
Thank you for your help.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named. Start by reproducing the Django filter case in Swagger UI and inspect the generated request for the number[in] parameter with one value versus comma-separated values. Done means the multi-value request matches the behavior that already works when called directly by URL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100