Open dcasado opened 3 years ago
I'd add the same for typescript-axios.
Something like
{{#isExplode}}
{{#isModel}}
for (let key of Object.keys({{paramName}})) {
localVarQueryParameter[key] = ({{paramName}} as any)[key];
}
{{/isModel}}
{{#isPrimitiveType}}
localVarQueryParameter['{{baseName}}'] = {{paramName}};
{{/isPrimitiveType}}
{{/isExplode}}
{{^isExplode}}
localVarQueryParameter['{{baseName}}'] = {{paramName}};
{{/isExplode}}
seem to work, but I'd like generate mapping statically in template rather than dynamically with ts, but {{vars}}
is empty.
Unfortunately, I got the same error and was confused that it stopped working after the following closed issue https://github.com/OpenAPITools/openapi-generator/issues/15633
But afterwards I found out that the merge unfortunately only fixed the "typescript-axios" not the "typescript-fetch" client. Is it possible to merge the same fix into this client as well?
Any updates on this? 😥
Can somebody fixed it for typescript-fetch please?
Bug Report Checklist
Description
The generated code does not take into account the field
explode: true
. It should generate separate parameters for each key-value pair of the map for the request as the specification says.Passing an object to a query parameter that has the property
explode: true
eg"filters":{"lang": "en", "scope":"mobile"}
the expected behavior is to generate?lang=en&scope=mobile
but the actual generated query is?filters[lang]=en&filters[scope]=mobile
openapi-generator version
5.2.1
OpenAPI declaration file content or url
Generation Details
Use generator [typescript-fetch] with default options
Steps to reproduce
await DefaultApi().resourceGet({filters:{lang: "en", scope: "mobile"}})
filters[lang]=en&filters[scope]=mobile
as query parametersRelated issues/PRs
Suggest a fix
The template code it does not take into account if the parameter has
explode: true
to assign it to the query parameters. https://github.com/OpenAPITools/openapi-generator/blob/ef0186c9cff7a14f7af6e1e7b6efc0a44b049a18/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache#L117We can add another case to check if the parameter is an object and has explode to true and generate the necessary code accordingly.