openapistack / openapi-client-axios

JavaScript client library for consuming OpenAPI-enabled APIs with axios
https://openapistack.co
MIT License
550 stars 67 forks source link

Single-element array params not passed as array anymore (5.1.0) #111

Closed jfpimentel closed 2 years ago

jfpimentel commented 2 years ago

Hey @anttiviljami,

After updating to version 5.1.0, I noticed that an array param with a single element is NOT passed as an array anymore.

This means that an array param may be passed as ids: [1,2] or ids: 1.

Is this really okay or is it a bug?

Thanks! Joao

gterral commented 2 years ago

Hello @anttiviljami, the array param is currently blocking the library update on our side. We find it really weird to expect the param to be an array and then because there is only element the param might becoming a string or a number.

Would you be ok to revert it, or did you make this change on purpose ? We can, of course, suggest a PR to fix the issue if you don't have the time to look at it :)

We located the problem on this line : https://github.com/anttiviljami/openapi-client-axios/blob/master/packages/openapi-client-axios/src/client.ts#L482

Please let us know your thoughts on this topic, Thank you again for this great library, Have a good day :)

anttiviljami commented 2 years ago

Hi @gterral @jfpimentel indeed this is not a good behaviour.

Can we find a way to fix this but still retain the use of the native URLSearchParameters ? The intent was to get rid of unnecessary 3rd party dependencies for query param handling

jfpimentel commented 2 years ago

@anttiviljami Thank you for getting back to us 🙂

I opened this PR to fix the issue: https://github.com/anttiviljami/openapi-client-axios/pull/112

anttiviljami commented 2 years ago

The fix released as part of openapi-client-axios@5.2.0. 🙏

Thanks @jfpimentel !

jfpimentel commented 2 years ago

Great! Thank you @anttiviljami 😉