swagger-api / swagger-api/swagger-codegen

[Typecscript-angular2] import Injection Token for BASE_PATH not correct [2.2.3-SNAPSHOT]

Open
#5,652 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Hi,

I use swagger-codegen 2.2.3-SNAPSHOT and I have an issue with typescript-angular2 generated client. In the file variable.ts I have the following :

`import { InjectionToken } from '@angular/core';

export const BASE_PATH = new InjectionToken('basePath');
export const COLLECTION_FORMATS = {
'csv': ',',
'tsv': ' ',
'ssv': ' ',
'pipes': '|'
}`

The first line is not correct and should be import { InjectionToken } from '@angular/core';

To fix this, I think that we need to change:

  • In file TypeScriptAngular2ClientCodegen line 35 protected String injectionToken = "InjectionToken<string>"; to protected String injectionToken = "InjectionToken";
  • And file \typescript-angular2\variables.mustache should be:
    `import { {{{injectionToken}}} } from '@angular/core';

export const BASE_PATH = new {{{injectionToken}}}('basePath');
export const COLLECTION_FORMATS = {
'csv': ',',
'tsv': ' ',
'ssv': ' ',
'pipes': '|'
}`

Could you have a look ?

Many thanks :)
Simon

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in TypeScriptAngular2ClientCodegen around the injectionToken setting and inspect typescript-angular2/variables.mustache. Generate a TypeScript Angular client to verify the import in variable.ts, then run the relevant code-generation tests if available; done means the import and InjectionToken usage are valid TypeScript.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, java, typescript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.