orval
orval copied to clipboard
Add support for CSV/explode=false query parameters "styles"
There is a feature of OpenAPI 3 that lets you change the style of how repeated parameters are specified https://spec.openapis.org/oas/v3.0.3#parameterStyle and https://spec.openapis.org/oas/v3.0.3#style-examples
The particular use case I have is to set explode=false to have CSV parameters rather than multiple query params.
Minimal spec file:
{
"info": {
"title": "My API",
"version": "1.0.0"
},
"openapi": "3.0.3",
"paths": {
"/test/": {
"get": {
"parameters": [
{
"in": "query",
"explode": false,
"name": "parameter",
"required": true,
"schema": {
"items": {
"type": "string"
},
"type": "array"
}
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
}
}
}
When called with multiple params this should result in ?parameter=a,b,c but it always/only produces ?parameter=a¶meter=b¶meter=c.
Tested with version 6.25.0
Note there also how arrays should be handled according to OpenApi spec
color=blue&color=black&color=brown
But Orval will do
color[]=blue&color[]=black&color[]=brown
Which I've never seen mentioned in the OpenApi spec. Which I guess is fine if we could just turn it off.
@programm-ingovals that is an axios feature that can be configured by adding the request key to the options parameter or the output override object:
request: {
paramsSerializer: {
indexes: null
}
}
@programm-ingovals that is an axios feature that can be configured by adding the request key to the options parameter or the output override object:
request: { paramsSerializer: { indexes: null } }
Thanks, will check that out.
i think fix by #1580 so related.
I close this issue.
When you use axios as a client, use paramsSerializer. and when you use fetch as a client, it can be controlled by the explode property in OpenAPI.