[REQ] Typescript-axios : Serialize array/multivalue parameters as repeat params, not CSV
Is your feature request related to a problem? Please describe.
I have a defined OpenApi spec with a PUT method that takes an array of Strings as one of its request body parameters. The server that is accepting the request expects the parameters to be passed like:
param=Value1¶m=Value2¶m=Value3
The typescript-axios generator, however, serializes the request body parameters for an Array to a CSV format. As a result, the server receives a value like:
param=Value1%2CValue2%2CValue3
As a result, the parameters are not being deserialized and read properly on the server side
Describe the solution you'd like
A configuration parameter that would allow the Array to be serializes as a multi-valued parameter for both query parameters or form body parameters
Hi, if I'm not mistaken, you should be able to accomplish this behavior via the axios configuration, specifically via the paramsSerializer option:
axios.get('/myController/myAction', {
params: { storeIds: [1,2,3] },
paramsSerializer: {
indexes: null, // no brackets at all
}
)
// /myController/myAction?storeIds=1&storeIds=2&storeIds=3
Source: https://stackoverflow.com/a/76517213
That's not true: paramsSerializer works with axios but not with the typescript-axios generator (despite passing an axios instance with paramsSerializer).
What you're looking for is the explode parameter: https://swagger.io/docs/specification/serialization/