Skip to content

[BUG][TYPESCRIPT/ANGULAR] Using wrong keyword in generated AngularService (localVarHeaders instead of headers) #10182

@Schmitda

Description

@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 #10091 variables have been renamed for the generation of the Angular - Services.

Unfortunately on Line 664aa2d#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
  1. Create an Angular App
  2. Install openapi-cli. https://www.npmjs.com/package/@openapitools/openapi-generator-cli
  3. 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"
  }
}
  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

  2. Use petService via Dependency Injection in app.component.ts

  3. 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

664aa2d#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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions