Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #10182
Closed
Open
Issue created Aug 18, 2021 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

[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
  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

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

Assignee
Assign to
Time tracking