From 8a0de971e46736b35b763d6967c8b6fa15617b53 Mon Sep 17 00:00:00 2001 From: topce Date: Fri, 24 Nov 2017 06:24:47 +0100 Subject: [PATCH] Remove rxjs operators (#6989) * do not import rxjs-operators if using HttpClinet * generate code * do not import operators if they are not needed --- .../resources/typescript-angular/api.service.mustache | 2 ++ .../typescript-angular/rxjs-operators.mustache | 6 ++++++ .../typescript-angular-v2/default/rxjs-operators.ts | 1 + .../typescript-angular-v2/npm/rxjs-operators.ts | 1 + .../with-interfaces/rxjs-operators.ts | 1 + .../typescript-angular-v4.3/npm/api/pet.service.ts | 1 - .../typescript-angular-v4.3/npm/api/store.service.ts | 1 - .../typescript-angular-v4.3/npm/api/user.service.ts | 1 - .../typescript-angular-v4.3/npm/rxjs-operators.ts | 11 +---------- .../typescript-angular-v4/npm/rxjs-operators.ts | 1 + 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/api.service.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/api.service.mustache index 8d032b7616..c8c8df6c0d 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/api.service.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/api.service.mustache @@ -15,7 +15,9 @@ import { CustomQueryEncoderHelper } from '../encoder'; {{/useHttpClient}} import { Observable } from 'rxjs/Observable'; +{{^useHttpClient}} import '../rxjs-operators'; +{{/useHttpClient}} {{#imports}} import { {{classname}} } from '../{{filename}}'; diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/rxjs-operators.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/rxjs-operators.mustache index 5659cd0694..49e265860b 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/rxjs-operators.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/rxjs-operators.mustache @@ -1,3 +1,8 @@ +{{#useHttpClient}} +// RxJS imports are not needed for Angular 4.3 and later +{{/useHttpClient}} + +{{^useHttpClient}} // RxJS imports according to https://angular.io/docs/ts/latest/guide/server-communication.html#!#rxjs // See node_module/rxjs/Rxjs.js @@ -9,3 +14,4 @@ import 'rxjs/add/observable/throw'; // Operators import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/map'; +{{/useHttpClient}} \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular-v2/default/rxjs-operators.ts b/samples/client/petstore/typescript-angular-v2/default/rxjs-operators.ts index 5659cd0694..2e79f87151 100644 --- a/samples/client/petstore/typescript-angular-v2/default/rxjs-operators.ts +++ b/samples/client/petstore/typescript-angular-v2/default/rxjs-operators.ts @@ -1,3 +1,4 @@ + // RxJS imports according to https://angular.io/docs/ts/latest/guide/server-communication.html#!#rxjs // See node_module/rxjs/Rxjs.js diff --git a/samples/client/petstore/typescript-angular-v2/npm/rxjs-operators.ts b/samples/client/petstore/typescript-angular-v2/npm/rxjs-operators.ts index 5659cd0694..2e79f87151 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/rxjs-operators.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/rxjs-operators.ts @@ -1,3 +1,4 @@ + // RxJS imports according to https://angular.io/docs/ts/latest/guide/server-communication.html#!#rxjs // See node_module/rxjs/Rxjs.js diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/rxjs-operators.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/rxjs-operators.ts index 5659cd0694..2e79f87151 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/rxjs-operators.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/rxjs-operators.ts @@ -1,3 +1,4 @@ + // RxJS imports according to https://angular.io/docs/ts/latest/guide/server-communication.html#!#rxjs // See node_module/rxjs/Rxjs.js diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts index 687f5995c9..40fb7221bd 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts @@ -17,7 +17,6 @@ import { HttpClient, HttpHeaders, HttpParams, import { CustomHttpUrlEncodingCodec } from '../encoder'; import { Observable } from 'rxjs/Observable'; -import '../rxjs-operators'; import { ApiResponse } from '../model/apiResponse'; import { Pet } from '../model/pet'; diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts index bb17d74e4f..7c5364e471 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts @@ -17,7 +17,6 @@ import { HttpClient, HttpHeaders, HttpParams, import { CustomHttpUrlEncodingCodec } from '../encoder'; import { Observable } from 'rxjs/Observable'; -import '../rxjs-operators'; import { Order } from '../model/order'; diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts index 1a237e81a4..edc7a4b429 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts @@ -17,7 +17,6 @@ import { HttpClient, HttpHeaders, HttpParams, import { CustomHttpUrlEncodingCodec } from '../encoder'; import { Observable } from 'rxjs/Observable'; -import '../rxjs-operators'; import { User } from '../model/user'; diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/rxjs-operators.ts b/samples/client/petstore/typescript-angular-v4.3/npm/rxjs-operators.ts index 5659cd0694..ae0d4c491d 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/rxjs-operators.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/rxjs-operators.ts @@ -1,11 +1,2 @@ -// RxJS imports according to https://angular.io/docs/ts/latest/guide/server-communication.html#!#rxjs +// RxJS imports are not needed for Angular 4.3 and later -// See node_module/rxjs/Rxjs.js -// Import just the rxjs statics and operators we need for THIS app. - -// Statics -import 'rxjs/add/observable/throw'; - -// Operators -import 'rxjs/add/operator/catch'; -import 'rxjs/add/operator/map'; diff --git a/samples/client/petstore/typescript-angular-v4/npm/rxjs-operators.ts b/samples/client/petstore/typescript-angular-v4/npm/rxjs-operators.ts index 5659cd0694..2e79f87151 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/rxjs-operators.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/rxjs-operators.ts @@ -1,3 +1,4 @@ + // RxJS imports according to https://angular.io/docs/ts/latest/guide/server-communication.html#!#rxjs // See node_module/rxjs/Rxjs.js