Closed griendt closed 4 years ago
I think a single non-array field that is comma-separated is probably the most universal. Adding a key for every individual value isn't very intuitive imo.
Postman does allow for providing a description of the field as well as allows providing example requests so as long as the field has a description with something like "A comma separated list of player ids. ex: 1,2,3" then I think it should be fine.
Closing this issue as it is being discussed in more detail in #28.
Enhancement Description
At the moment there is only one way to properly pass an array of values in a
x-www-form-urlencoded
Content-Type request and that is to add a key-value pair for each value you want to add, e.g.This is apparently common across this content type and Laravel parses them properly. However, we may want to be able to pass just one comma-separated value in the request, like so:
Solution
explode
the value belonging to a key if that key is an array-like. The problem is however that this is not known a priori. Laravel translates the keys as in the first example toparticipants.0
andparticipants.1
which are then no longer arrays themselves. Therefore it seems impossible to implement this in a middleware.However, of course we could do an
explode
in the relevant controller whenever needed. We could then pass an argument as if it were not an array at all, like so:This would be the easiest solution, but it also makes it a bit less obvious in Postman that the field is supposed to be an array.