Conversation
Interesting. What is the best practice here? I would imagine that if you had an empty array, you wouldn't send the query parameter at all. Can you describe your use case? It looks like we need to flush out some more tests out around this as well, as there isn't array specific tests for parameter encoding. |
My opinion is that being able to distinguish between nil, not provided, and an empty array, provided but empty, seems like a useful thing to be able to communicate as part of an API interaction. |
Any spec's out there that show best practices for this? |
We already have quite a few tests around most of the mentioned cases here @kcharwood in Alamofire. Maybe some of those could lend a hand here. Also, the public docstring for the URL case points out that there aren't any RFC specs published around query string collection types. Here are a couple other issues with some additional details. |
That explains why I can't find anything :) Making this change would be considered a breaking change IMO, since anyone using the current version of the library would get different behavior if they are currently passing in an empty array. In light of that, I would be hesitant to merge this in without strong consensus from the community that this should be the preferred way of dealing with an empty array. |
We do need to get some tests around this though. I'd like to get that merged in. |
I'm also not able to find anything. With respect to it being a breaking change, I agree. |
First off, if we did change this, it should only be changed with a MAJOR version bump and called out in the migration guide. I'd also say we should keep AFN and AF using the same approach. With that said, I'm a bit torn on this. It seems fairly logical that a server would I've literally written this response three different times with a different opinion each time. I'd say that I feel it should probably remain unchanged. I'm really interested to see what @kylef thinks. |
My preference would be to leave the behavior as is. If you need to provide custom serialization, you can do so by using |
ok, i see. thanks. may i close this PR? |
Yes I'm going to close this one out. Thanks! 🍻 |
Sorry if it is by design🙇🏻