From 7966152c30e8530f7878520f5d602ba3e1b3fd12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjarni=20=C3=9E=C3=B3r=20J=C3=B3nsson=20=40bjarnitj?= Date: Mon, 12 Mar 2018 15:49:52 +0000 Subject: [PATCH 1/3] Explicitly define the undefined discriminator as any To get rid of the `[ts] Member 'discriminator' implicitly has an 'any' type.` error message from the TypeScript compiler when `noImplicitAny` is set to true. --- .../main/resources/typescript-node/api.mustache | 2 +- .../default/.swagger-codegen/VERSION | 2 +- .../client/petstore/typescript-node/default/api.ts | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache index 58cd4b31bf1..8d414efafdd 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache @@ -148,7 +148,7 @@ export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ static discriminator = {{discriminator}}; {{/discriminator}} {{^discriminator}} - static discriminator = undefined; + static discriminator : any = undefined; {{/discriminator}} static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ diff --git a/samples/client/petstore/typescript-node/default/.swagger-codegen/VERSION b/samples/client/petstore/typescript-node/default/.swagger-codegen/VERSION index a6254504e40..855ff9501eb 100644 --- a/samples/client/petstore/typescript-node/default/.swagger-codegen/VERSION +++ b/samples/client/petstore/typescript-node/default/.swagger-codegen/VERSION @@ -1 +1 @@ -2.3.1 \ No newline at end of file +2.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-node/default/api.ts b/samples/client/petstore/typescript-node/default/api.ts index 1e75275a066..bbbb7b9962b 100644 --- a/samples/client/petstore/typescript-node/default/api.ts +++ b/samples/client/petstore/typescript-node/default/api.ts @@ -144,7 +144,7 @@ export class ApiResponse { 'type': string; 'message': string; - static discriminator = undefined; + static discriminator : any = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { @@ -175,7 +175,7 @@ export class Category { 'id': number; 'name': string; - static discriminator = undefined; + static discriminator : any = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { @@ -208,7 +208,7 @@ export class Order { 'status': Order.StatusEnum; 'complete': boolean; - static discriminator = undefined; + static discriminator : any = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { @@ -268,7 +268,7 @@ export class Pet { */ 'status': Pet.StatusEnum; - static discriminator = undefined; + static discriminator : any = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { @@ -321,7 +321,7 @@ export class Tag { 'id': number; 'name': string; - static discriminator = undefined; + static discriminator : any = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { @@ -356,7 +356,7 @@ export class User { */ 'userStatus': number; - static discriminator = undefined; + static discriminator : any = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { @@ -1507,7 +1507,7 @@ export class UserApi { /** * * @summary Get user by user name - * @param username The name that needs to be fetched. Use user1 for testing. + * @param username The name that needs to be fetched. Use user1 for testing. */ public getUserByName (username: string) : Promise<{ response: http.ClientResponse; body: User; }> { const localVarPath = this.basePath + '/user/{username}' From d4e5b87d920fcf09a78f07e0e5b4dbadcc80d766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjarni=20=C3=9E=C3=B3r=20J=C3=B3nsson=20=40bjarnitj?= Date: Mon, 12 Mar 2018 15:54:17 +0000 Subject: [PATCH 2/3] Adding missing quotes around the name of the discriminator Otherwise the code wouldn't work probably and the TypeScript compiler didn't even compile it without errors. The Petstore client sample only contains undefined discriminators so this change does not affect the code generation of the Petstore client sample. --- .../src/main/resources/typescript-node/api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache index 8d414efafdd..e01d743d541 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache @@ -145,7 +145,7 @@ export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ {{/vars}} {{#discriminator}} - static discriminator = {{discriminator}}; + static discriminator = '{{discriminator}}'; {{/discriminator}} {{^discriminator}} static discriminator : any = undefined; From d4594b0316cdec21a43dd1a9f7a5203090318bad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjarni=20=C3=9E=C3=B3r=20J=C3=B3nsson=20=40bjarnitj?= Date: Wed, 14 Mar 2018 16:09:19 +0000 Subject: [PATCH 3/3] Discriminator is of type string. Remove space to match code style --- .../main/resources/typescript-node/api.mustache | 2 +- .../client/petstore/typescript-node/default/api.ts | 12 ++++++------ .../typescript-node/npm/.swagger-codegen/VERSION | 2 +- samples/client/petstore/typescript-node/npm/api.ts | 14 +++++++------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache index e01d743d541..bbf1ef66c9b 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache @@ -148,7 +148,7 @@ export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ static discriminator = '{{discriminator}}'; {{/discriminator}} {{^discriminator}} - static discriminator : any = undefined; + static discriminator: string = undefined; {{/discriminator}} static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ diff --git a/samples/client/petstore/typescript-node/default/api.ts b/samples/client/petstore/typescript-node/default/api.ts index bbbb7b9962b..963cdc0717a 100644 --- a/samples/client/petstore/typescript-node/default/api.ts +++ b/samples/client/petstore/typescript-node/default/api.ts @@ -144,7 +144,7 @@ export class ApiResponse { 'type': string; 'message': string; - static discriminator : any = undefined; + static discriminator: string = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { @@ -175,7 +175,7 @@ export class Category { 'id': number; 'name': string; - static discriminator : any = undefined; + static discriminator: string = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { @@ -208,7 +208,7 @@ export class Order { 'status': Order.StatusEnum; 'complete': boolean; - static discriminator : any = undefined; + static discriminator: string = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { @@ -268,7 +268,7 @@ export class Pet { */ 'status': Pet.StatusEnum; - static discriminator : any = undefined; + static discriminator: string = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { @@ -321,7 +321,7 @@ export class Tag { 'id': number; 'name': string; - static discriminator : any = undefined; + static discriminator: string = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { @@ -356,7 +356,7 @@ export class User { */ 'userStatus': number; - static discriminator : any = undefined; + static discriminator: string = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { diff --git a/samples/client/petstore/typescript-node/npm/.swagger-codegen/VERSION b/samples/client/petstore/typescript-node/npm/.swagger-codegen/VERSION index a6254504e40..855ff9501eb 100644 --- a/samples/client/petstore/typescript-node/npm/.swagger-codegen/VERSION +++ b/samples/client/petstore/typescript-node/npm/.swagger-codegen/VERSION @@ -1 +1 @@ -2.3.1 \ No newline at end of file +2.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-node/npm/api.ts b/samples/client/petstore/typescript-node/npm/api.ts index 1e75275a066..963cdc0717a 100644 --- a/samples/client/petstore/typescript-node/npm/api.ts +++ b/samples/client/petstore/typescript-node/npm/api.ts @@ -144,7 +144,7 @@ export class ApiResponse { 'type': string; 'message': string; - static discriminator = undefined; + static discriminator: string = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { @@ -175,7 +175,7 @@ export class Category { 'id': number; 'name': string; - static discriminator = undefined; + static discriminator: string = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { @@ -208,7 +208,7 @@ export class Order { 'status': Order.StatusEnum; 'complete': boolean; - static discriminator = undefined; + static discriminator: string = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { @@ -268,7 +268,7 @@ export class Pet { */ 'status': Pet.StatusEnum; - static discriminator = undefined; + static discriminator: string = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { @@ -321,7 +321,7 @@ export class Tag { 'id': number; 'name': string; - static discriminator = undefined; + static discriminator: string = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { @@ -356,7 +356,7 @@ export class User { */ 'userStatus': number; - static discriminator = undefined; + static discriminator: string = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { @@ -1507,7 +1507,7 @@ export class UserApi { /** * * @summary Get user by user name - * @param username The name that needs to be fetched. Use user1 for testing. + * @param username The name that needs to be fetched. Use user1 for testing. */ public getUserByName (username: string) : Promise<{ response: http.ClientResponse; body: User; }> { const localVarPath = this.basePath + '/user/{username}'