Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[typescript-angular] Support rxjs 6 #8856

Open
Fredx87 opened this issue Oct 25, 2018 · 4 comments · May be fixed by swagger-api/swagger-codegen-generators#236
Open

[typescript-angular] Support rxjs 6 #8856

Fredx87 opened this issue Oct 25, 2018 · 4 comments · May be fixed by swagger-api/swagger-codegen-generators#236

Comments

@Fredx87
Copy link

Fredx87 commented Oct 25, 2018

Description

The import of Observable in rxjs 6 is changed from previous versions. The typescript-angular generator should support the new version

Swagger-codegen version

3.0.2

Suggest a fix/enhancement

Taking any definition, the created services imports rxjs in this way:

import { Observable }                                        from 'rxjs/Observable';

With rxjs 6, the correct way to import Observable is:

import { Observable }                                        from 'rxjs';

This should be supported with a specific configuration flag, or when ngVersion is greater than 6.

@britvik
Copy link

britvik commented Nov 5, 2018

This has already been fixed and merged into master, but sadly it didn't make it to the v3.
887afa8#diff-5bdae26ba753c4986ceb5af35bada047

@andrewryan1906
Copy link

Any update on when this might get merged to master?

@MikeKovetsky
Copy link

Please take a look at the issue. This does not let me remove rxjs-compat from dependencies.
Moreover, this will become a bigger problem after rxjs-compat deprecation.

@dennisameling
Copy link

For swagger-codegen >=3.0.0

The PR that @britvik mentioned is indeed in the master branch only (<3.0.0). I've created a separate issue for the 3.0.0 branch (in the swagger-codegen-generators repo) to get these commits to the 3.0.0+ version as well.

For swagger-codegen <3.0.0

Please be aware that the default Angular build still runs for Angular 4.3.0 (see TypeScriptAngularClientCodegen.java):

SemVer ngVersion;
if (additionalProperties.containsKey(NG_VERSION)) {
   ngVersion = new SemVer(additionalProperties.get(NG_VERSION).toString());
} else {
   ngVersion = new SemVer("4.3.0");
   LOGGER.info("generating code for Angular {} ...", ngVersion);
   LOGGER.info("  (you can select the angular version by setting the additionalProperty ngVersion)");
}

You can run the build script for Angular 6 with the --additional-properties ngVersion=6 command:

Linux:

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
   -i http://petstore.swagger.io/v2/swagger.json \
   -l typescript-angular \
   -o /var/tmp/angular_api_client \
   --additional-properties ngVersion=6

Windows:

java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l typescript-angular -o c:\temp\angular_api_client --additional-properties ngVersion=6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants