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 angular 9 #5370

Merged
merged 6 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
public static final String TAGGED_UNIONS = "taggedUnions";
public static final String NG_VERSION = "ngVersion";
public static final String PROVIDED_IN_ROOT = "providedInRoot";
public static final String MODULE_WITH_PROVIDERS = "moduleWithProviders";
public static final String API_MODULE_PREFIX = "apiModulePrefix";
public static final String SERVICE_SUFFIX = "serviceSuffix";
public static final String SERVICE_FILE_SUFFIX = "serviceFileSuffix";
Expand All @@ -55,7 +56,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
public static final String STRING_ENUMS = "stringEnums";
public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values.";

protected String ngVersion = "8.0.0";
protected String ngVersion = "9.0.0";
protected String npmRepository = null;
private boolean useSingleRequestParameter = false;
protected String serviceSuffix = "Service";
Expand Down Expand Up @@ -123,7 +124,7 @@ public String getName() {

@Override
public String getHelp() {
return "Generates a TypeScript Angular (2.x - 7.x) client library.";
return "Generates a TypeScript Angular (2.x - 9.x) client library.";
}

@Override
Expand Down Expand Up @@ -192,6 +193,12 @@ public void processOpts() {
additionalProperties.put(PROVIDED_IN_ROOT, false);
}

if (ngVersion.atLeast("9.0.0")) {
additionalProperties.put(MODULE_WITH_PROVIDERS, true);
} else {
additionalProperties.put(MODULE_WITH_PROVIDERS, false);
}

additionalProperties.put(NG_VERSION, ngVersion);
additionalProperties.put("injectionToken", ngVersion.atLeast("4.0.0") ? "InjectionToken" : "OpaqueToken");
additionalProperties.put("injectionTokenTyped", ngVersion.atLeast("4.0.0"));
Expand Down Expand Up @@ -253,7 +260,9 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
}

// Set the typescript version compatible to the Angular version
if (ngVersion.atLeast("8.0.0")) {
if (ngVersion.atLeast("9.0.0")) {
additionalProperties.put("tsVersion", ">=3.6.0 <3.8.0");
} else if (ngVersion.atLeast("8.0.0")) {
additionalProperties.put("tsVersion", ">=3.4.0 <3.6.0");
} else if (ngVersion.atLeast("7.0.0")) {
additionalProperties.put("tsVersion", ">=3.1.1 <3.2.0");
Expand All @@ -267,7 +276,9 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
}

// Set the rxJS version compatible to the Angular version
if (ngVersion.atLeast("8.0.0")) {
if (ngVersion.atLeast("9.0.0")) {
additionalProperties.put("rxjsVersion", "6.5.3");
} else if (ngVersion.atLeast("8.0.0")) {
additionalProperties.put("rxjsVersion", "6.5.0");
} else if (ngVersion.atLeast("7.0.0")) {
additionalProperties.put("rxjsVersion", "6.3.0");
Expand Down Expand Up @@ -297,7 +308,10 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
additionalProperties.put("useOldNgPackagr", !ngVersion.atLeast("5.0.0"));

// Specific ng-packagr configuration
if (ngVersion.atLeast("8.0.0")) {
if (ngVersion.atLeast("9.0.0")) {
additionalProperties.put("ngPackagrVersion", "9.0.1");
additionalProperties.put("tsickleVersion", "0.38.0");
} else if (ngVersion.atLeast("8.0.0")) {
additionalProperties.put("ngPackagrVersion", "5.4.0");
additionalProperties.put("tsickleVersion", "0.35.0");
} else if (ngVersion.atLeast("7.0.0")) {
Expand All @@ -319,6 +333,8 @@ private void addNpmPackageGeneration(SemVer ngVersion) {

// set zone.js version
if (ngVersion.atLeast("8.0.0")) {
additionalProperties.put("zonejsVersion", "0.10.2");
} else if (ngVersion.atLeast("8.0.0")) {
additionalProperties.put("zonejsVersion", "0.9.1");
} else if (ngVersion.atLeast("5.0.0")) {
// compatible versions to Angular 5+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { {{classname}} } from './{{importPath}}';
{{/hasMore}}{{/apis}}{{/apiInfo}} {{/providedInRoot}}]
})
export class {{apiModuleClassName}} {
public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders {
public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders{{#moduleWithProviders}}<{{apiModuleClassName}}>{{/moduleWithProviders}} {
return {
ngModule: {{apiModuleClassName}},
providers: [ { provide: Configuration, useFactory: configurationFactory } ]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
Expand Down
201 changes: 0 additions & 201 deletions samples/client/petstore/typescript-angular-v2/default/LICENSE

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
Expand Down
Loading