[BUG][TYPESCRIPT/ANGULAR] Using wrong keyword in generated AngularService (localVarHeaders instead of headers)
Created by: Schmitda
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output?
Description
Since the use of Version 5.2.1 (last Version used before was 5.0.0) we encounter a issue with the generation of Angular Service code. According to this https://github.com/OpenAPITools/openapi-generator/pull/10091 variables have been renamed for the generation of the Angular - Services.
Unfortunately on Line https://github.com/OpenAPITools/openapi-generator/commit/664aa2d946236ce327cf56256947baeb68f828e4#diff-7de15eed36eb15ed45aef205826063248eaddf2b11511db6a4bb2679c2aca851R361 there seemed to went something wrong. The property "headers" which is part of the HTTPClient Options has also been renamed instead of the value. This should stay headers.
This will cause a compilation error in angular and won't work as header information is not submitted.
So the code should be:
{
...
headers: localVarHeaders,
...
}
But unfortunately the code generated is:
{
...
localVarHeaders: localVarHeaders,
...
}
openapi-generator version
I am using the "@openapitools/openapi-generator-cli": "2.3.10"
with version-manager 5.2.1
.
Reverting to Version 5.0.0 in the version-manager works.
OpenAPI declaration file content or url
You may use the example schema to regenerate the issue: https://petstore.swagger.io/v2/swagger.json.
Generation Details
Can be generated with the following line:
openapi-generator-cli generate -i https://petstore.swagger.io/v2/swagger.json -g typescript-angular -o src/app/swagger --type-mappings=object=any --skip-validate-spec
Steps to reproduce
- Create an Angular App
- Install openapi-cli.
https://www.npmjs.com/package/@openapitools/openapi-generator-cli
- Set version in openapitools.json to 5.2.1 Here is my example:
{
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "5.2.1"
}
}
-
Generate Services for angular as described above
openapi-generator-cli generate -i https://petstore.swagger.io/v2/swagger.json -g typescript-angular -o src/app/swagger --type-mappings=object=any --skip-validate-spec
-
Use petService via Dependency Injection in app.component.ts
-
Try compiling.
npm run start
The pet.service.ts will cause a compilation error because localVarHeaders is not a known key for the httpClient options.
Related issues/PRs
No related issue found yet.
Suggest a fix
https://github.com/OpenAPITools/openapi-generator/commit/664aa2d946236ce327cf56256947baeb68f828e4#diff-7de15eed36eb15ed45aef205826063248eaddf2b11511db6a4bb2679c2aca851R361 So the code should be:
{
...
headers: localVarHeaders,
...
}
But unfortunately the code generated is:
{
...
localVarHeaders: localVarHeaders,
...
}
Thanks for any comment on this issue. Best regards Schmitda