From f5b7e8f94a4f42431ce4dd2360c49318aaf083b6 Mon Sep 17 00:00:00 2001 From: Bodo Graumann Date: Fri, 6 Sep 2019 11:31:42 +0200 Subject: [PATCH 1/5] [typescript-inversify] Allow falsy parameters A required parameter to an api method must not be `null` or `undefined`. It can be any other falsy value, e.g. `""`, `0` or `false` though. This change makes sure an error is only thrown in the former case and not in the latter. --- .../main/resources/typescript-inversify/api.service.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache b/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache index 547055863b76..41dd52b803f2 100644 --- a/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache @@ -60,7 +60,7 @@ export class {{classname}} { public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}observe: any = 'body', headers: Headers = {}): {{#usePromise}}Promise{{/usePromise}}{{^usePromise}}Observable{{/usePromise}} { {{#allParams}} {{#required}} - if (!{{paramName}}){ + if ({{paramName}} == null){ throw new Error('Required parameter {{paramName}} was null or undefined when calling {{nickname}}.'); } From 136244c012d6e63a1d192b77b2c23b72672920f8 Mon Sep 17 00:00:00 2001 From: Bodo Graumann Date: Fri, 6 Sep 2019 11:34:29 +0200 Subject: [PATCH 2/5] [typescript-inversify] Handle multiple media types The Accept and Content-Type HTTP headers can contain a list of media types. Previously all but the first media type in the api definition were ignored. Now the headers are properly generated. --- .../main/resources/typescript-inversify/api.service.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache b/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache index 41dd52b803f2..bc38b97e612c 100644 --- a/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache @@ -139,7 +139,7 @@ export class {{classname}} { headers['Accept'] = 'application/json'; {{/produces}} {{#produces.0}} - headers['Accept'] = '{{{mediaType}}}'; + headers['Accept'] = '{{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}'; {{/produces.0}} {{#bodyParam}} {{^consumes}} From a2d45fbda682ef5cfbf99223a89392bd05d061e5 Mon Sep 17 00:00:00 2001 From: Bodo Graumann Date: Fri, 6 Sep 2019 14:01:59 +0200 Subject: [PATCH 3/5] [typescript-inversify] Fix http client interface The api service methods allow the `body` parameter to be optional. The parameter is then passed to an `IHttpClient`. So it needs to be optional there as well. Also fixed the sample implementation `HttpClient`. Fixes #3618. --- .../typescript-inversify/HttpClient.mustache | 13 ++++++++----- .../typescript-inversify/IHttpClient.mustache | 6 +++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-inversify/HttpClient.mustache b/modules/openapi-generator/src/main/resources/typescript-inversify/HttpClient.mustache index f6a665e96bef..a44d76453ca8 100644 --- a/modules/openapi-generator/src/main/resources/typescript-inversify/HttpClient.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-inversify/HttpClient.mustache @@ -19,15 +19,15 @@ class HttpClient implements IHttpClient { return this.performNetworkCall(url, "GET", undefined, headers); } - post(url: string, body: {}|FormData, headers?: Headers): Observable { + post(url: string, body?: {}|FormData, headers?: Headers): Observable { return this.performNetworkCall(url, "POST", this.getJsonBody(body), this.addJsonHeaders(headers)); } - put(url: string, body: {}, headers?: Headers): Observable { + put(url: string, body?: {}, headers?: Headers): Observable { return this.performNetworkCall(url, "PUT", this.getJsonBody(body), this.addJsonHeaders(headers)); } - patch(url: string, body: {}, headers?: Headers): Observable { + patch(url: string, body?: {}, headers?: Headers): Observable { return this.performNetworkCall(url, "PATCH", this.getJsonBody(body), this.addJsonHeaders(headers)); } @@ -36,8 +36,11 @@ class HttpClient implements IHttpClient { return this.performNetworkCall(url, "DELETE", undefined, headers); } - private getJsonBody(body: {}|FormData) { - return !(body instanceof FormData) ? JSON.stringify(body) : body; + private getJsonBody(body?: {}|FormData) { + if (body === undefined || body instanceof FormData) { + return body; + } + return JSON.stringify(body); } private addJsonHeaders(headers?: Headers) { diff --git a/modules/openapi-generator/src/main/resources/typescript-inversify/IHttpClient.mustache b/modules/openapi-generator/src/main/resources/typescript-inversify/IHttpClient.mustache index 8f8984819039..211d881ba5eb 100644 --- a/modules/openapi-generator/src/main/resources/typescript-inversify/IHttpClient.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-inversify/IHttpClient.mustache @@ -9,9 +9,9 @@ import { Headers } from "./Headers"; interface IHttpClient { get(url:string, headers?: Headers):Observable - post(url:string, body:{}|FormData, headers?: Headers):Observable - put(url:string, body:{}, headers?: Headers):Observable - patch(url:string, body:{}, headers?: Headers):Observable + post(url:string, body?:{}|FormData, headers?: Headers):Observable + put(url:string, body?:{}, headers?: Headers):Observable + patch(url:string, body?:{}, headers?: Headers):Observable delete(url:string, headers?: Headers):Observable } From c5aaef9b144a4e43086e7295a13f2218b0350bc1 Mon Sep 17 00:00:00 2001 From: Bodo Graumann Date: Fri, 6 Sep 2019 12:14:32 +0200 Subject: [PATCH 4/5] [typescript-inversify] Regenerate Petstore sample --- .../typescript-inversify/HttpClient.ts | 13 ++++++----- .../typescript-inversify/IHttpClient.ts | 6 ++--- .../typescript-inversify/api/pet.service.ts | 22 +++++++++---------- .../typescript-inversify/api/store.service.ts | 10 ++++----- .../typescript-inversify/api/user.service.ts | 22 +++++++++---------- .../model/inlineObject.ts | 2 +- .../model/inlineObject1.ts | 2 +- 7 files changed, 40 insertions(+), 37 deletions(-) diff --git a/samples/client/petstore/typescript-inversify/HttpClient.ts b/samples/client/petstore/typescript-inversify/HttpClient.ts index 3342d786fb82..4a9745c654d1 100644 --- a/samples/client/petstore/typescript-inversify/HttpClient.ts +++ b/samples/client/petstore/typescript-inversify/HttpClient.ts @@ -14,15 +14,15 @@ class HttpClient implements IHttpClient { return this.performNetworkCall(url, "GET", undefined, headers); } - post(url: string, body: {}|FormData, headers?: Headers): Observable { + post(url: string, body?: {}|FormData, headers?: Headers): Observable { return this.performNetworkCall(url, "POST", this.getJsonBody(body), this.addJsonHeaders(headers)); } - put(url: string, body: {}, headers?: Headers): Observable { + put(url: string, body?: {}, headers?: Headers): Observable { return this.performNetworkCall(url, "PUT", this.getJsonBody(body), this.addJsonHeaders(headers)); } - patch(url: string, body: {}, headers?: Headers): Observable { + patch(url: string, body?: {}, headers?: Headers): Observable { return this.performNetworkCall(url, "PATCH", this.getJsonBody(body), this.addJsonHeaders(headers)); } @@ -31,8 +31,11 @@ class HttpClient implements IHttpClient { return this.performNetworkCall(url, "DELETE", undefined, headers); } - private getJsonBody(body: {}|FormData) { - return !(body instanceof FormData) ? JSON.stringify(body) : body; + private getJsonBody(body?: {}|FormData) { + if (body === undefined || body instanceof FormData) { + return body; + } + return JSON.stringify(body); } private addJsonHeaders(headers?: Headers) { diff --git a/samples/client/petstore/typescript-inversify/IHttpClient.ts b/samples/client/petstore/typescript-inversify/IHttpClient.ts index 09f8fff96dbb..51064868934b 100644 --- a/samples/client/petstore/typescript-inversify/IHttpClient.ts +++ b/samples/client/petstore/typescript-inversify/IHttpClient.ts @@ -4,9 +4,9 @@ import { Headers } from "./Headers"; interface IHttpClient { get(url:string, headers?: Headers):Observable - post(url:string, body:{}|FormData, headers?: Headers):Observable - put(url:string, body:{}, headers?: Headers):Observable - patch(url:string, body:{}, headers?: Headers):Observable + post(url:string, body?:{}|FormData, headers?: Headers):Observable + put(url:string, body?:{}, headers?: Headers):Observable + patch(url:string, body?:{}, headers?: Headers):Observable delete(url:string, headers?: Headers):Observable } diff --git a/samples/client/petstore/typescript-inversify/api/pet.service.ts b/samples/client/petstore/typescript-inversify/api/pet.service.ts index 06dbd62cdf39..77d72833d7df 100644 --- a/samples/client/petstore/typescript-inversify/api/pet.service.ts +++ b/samples/client/petstore/typescript-inversify/api/pet.service.ts @@ -46,7 +46,7 @@ export class PetService { public addPet(body: Pet, observe?: 'body', headers?: Headers): Observable; public addPet(body: Pet, observe?: 'response', headers?: Headers): Observable>; public addPet(body: Pet, observe: any = 'body', headers: Headers = {}): Observable { - if (!body){ + if (body == null){ throw new Error('Required parameter body was null or undefined when calling addPet.'); } @@ -80,7 +80,7 @@ export class PetService { public deletePet(petId: number, apiKey?: string, observe?: 'body', headers?: Headers): Observable; public deletePet(petId: number, apiKey?: string, observe?: 'response', headers?: Headers): Observable>; public deletePet(petId: number, apiKey?: string, observe: any = 'body', headers: Headers = {}): Observable { - if (!petId){ + if (petId == null){ throw new Error('Required parameter petId was null or undefined when calling deletePet.'); } @@ -116,7 +116,7 @@ export class PetService { public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, observe?: 'body', headers?: Headers): Observable>; public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, observe?: 'response', headers?: Headers): Observable>>; public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, observe: any = 'body', headers: Headers = {}): Observable { - if (!status){ + if (status == null){ throw new Error('Required parameter status was null or undefined when calling findPetsByStatus.'); } @@ -132,7 +132,7 @@ export class PetService { : this.APIConfiguration.accessToken; headers['Authorization'] = 'Bearer ' + accessToken; } - headers['Accept'] = 'application/xml'; + headers['Accept'] = 'application/xml, application/json'; const response: Observable>> = this.httpClient.get(`${this.basePath}/pet/findByStatus?${queryParameters.join('&')}`, headers); if (observe == 'body') { @@ -153,7 +153,7 @@ export class PetService { public findPetsByTags(tags: Array, observe?: 'body', headers?: Headers): Observable>; public findPetsByTags(tags: Array, observe?: 'response', headers?: Headers): Observable>>; public findPetsByTags(tags: Array, observe: any = 'body', headers: Headers = {}): Observable { - if (!tags){ + if (tags == null){ throw new Error('Required parameter tags was null or undefined when calling findPetsByTags.'); } @@ -169,7 +169,7 @@ export class PetService { : this.APIConfiguration.accessToken; headers['Authorization'] = 'Bearer ' + accessToken; } - headers['Accept'] = 'application/xml'; + headers['Accept'] = 'application/xml, application/json'; const response: Observable>> = this.httpClient.get(`${this.basePath}/pet/findByTags?${queryParameters.join('&')}`, headers); if (observe == 'body') { @@ -190,7 +190,7 @@ export class PetService { public getPetById(petId: number, observe?: 'body', headers?: Headers): Observable; public getPetById(petId: number, observe?: 'response', headers?: Headers): Observable>; public getPetById(petId: number, observe: any = 'body', headers: Headers = {}): Observable { - if (!petId){ + if (petId == null){ throw new Error('Required parameter petId was null or undefined when calling getPetById.'); } @@ -198,7 +198,7 @@ export class PetService { if (this.APIConfiguration.apiKeys && this.APIConfiguration.apiKeys["api_key"]) { headers['api_key'] = this.APIConfiguration.apiKeys["api_key"]; } - headers['Accept'] = 'application/xml'; + headers['Accept'] = 'application/xml, application/json'; const response: Observable> = this.httpClient.get(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, headers); if (observe == 'body') { @@ -219,7 +219,7 @@ export class PetService { public updatePet(body: Pet, observe?: 'body', headers?: Headers): Observable; public updatePet(body: Pet, observe?: 'response', headers?: Headers): Observable>; public updatePet(body: Pet, observe: any = 'body', headers: Headers = {}): Observable { - if (!body){ + if (body == null){ throw new Error('Required parameter body was null or undefined when calling updatePet.'); } @@ -254,7 +254,7 @@ export class PetService { public updatePetWithForm(petId: number, name?: string, status?: string, observe?: 'body', headers?: Headers): Observable; public updatePetWithForm(petId: number, name?: string, status?: string, observe?: 'response', headers?: Headers): Observable>; public updatePetWithForm(petId: number, name?: string, status?: string, observe: any = 'body', headers: Headers = {}): Observable { - if (!petId){ + if (petId == null){ throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.'); } @@ -297,7 +297,7 @@ export class PetService { public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, observe?: 'body', headers?: Headers): Observable; public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, observe?: 'response', headers?: Headers): Observable>; public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, observe: any = 'body', headers: Headers = {}): Observable { - if (!petId){ + if (petId == null){ throw new Error('Required parameter petId was null or undefined when calling uploadFile.'); } diff --git a/samples/client/petstore/typescript-inversify/api/store.service.ts b/samples/client/petstore/typescript-inversify/api/store.service.ts index 778e00e5c3ae..b09cc9061e2a 100644 --- a/samples/client/petstore/typescript-inversify/api/store.service.ts +++ b/samples/client/petstore/typescript-inversify/api/store.service.ts @@ -45,7 +45,7 @@ export class StoreService { public deleteOrder(orderId: string, observe?: 'body', headers?: Headers): Observable; public deleteOrder(orderId: string, observe?: 'response', headers?: Headers): Observable>; public deleteOrder(orderId: string, observe: any = 'body', headers: Headers = {}): Observable { - if (!orderId){ + if (orderId == null){ throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.'); } @@ -94,11 +94,11 @@ export class StoreService { public getOrderById(orderId: number, observe?: 'body', headers?: Headers): Observable; public getOrderById(orderId: number, observe?: 'response', headers?: Headers): Observable>; public getOrderById(orderId: number, observe: any = 'body', headers: Headers = {}): Observable { - if (!orderId){ + if (orderId == null){ throw new Error('Required parameter orderId was null or undefined when calling getOrderById.'); } - headers['Accept'] = 'application/xml'; + headers['Accept'] = 'application/xml, application/json'; const response: Observable> = this.httpClient.get(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`, headers); if (observe == 'body') { @@ -119,11 +119,11 @@ export class StoreService { public placeOrder(body: Order, observe?: 'body', headers?: Headers): Observable; public placeOrder(body: Order, observe?: 'response', headers?: Headers): Observable>; public placeOrder(body: Order, observe: any = 'body', headers: Headers = {}): Observable { - if (!body){ + if (body == null){ throw new Error('Required parameter body was null or undefined when calling placeOrder.'); } - headers['Accept'] = 'application/xml'; + headers['Accept'] = 'application/xml, application/json'; headers['Content-Type'] = 'application/json'; const response: Observable> = this.httpClient.post(`${this.basePath}/store/order`, body , headers); diff --git a/samples/client/petstore/typescript-inversify/api/user.service.ts b/samples/client/petstore/typescript-inversify/api/user.service.ts index f2e8b83c4ab6..830e611f48b4 100644 --- a/samples/client/petstore/typescript-inversify/api/user.service.ts +++ b/samples/client/petstore/typescript-inversify/api/user.service.ts @@ -45,7 +45,7 @@ export class UserService { public createUser(body: User, observe?: 'body', headers?: Headers): Observable; public createUser(body: User, observe?: 'response', headers?: Headers): Observable>; public createUser(body: User, observe: any = 'body', headers: Headers = {}): Observable { - if (!body){ + if (body == null){ throw new Error('Required parameter body was null or undefined when calling createUser.'); } @@ -71,7 +71,7 @@ export class UserService { public createUsersWithArrayInput(body: Array, observe?: 'body', headers?: Headers): Observable; public createUsersWithArrayInput(body: Array, observe?: 'response', headers?: Headers): Observable>; public createUsersWithArrayInput(body: Array, observe: any = 'body', headers: Headers = {}): Observable { - if (!body){ + if (body == null){ throw new Error('Required parameter body was null or undefined when calling createUsersWithArrayInput.'); } @@ -97,7 +97,7 @@ export class UserService { public createUsersWithListInput(body: Array, observe?: 'body', headers?: Headers): Observable; public createUsersWithListInput(body: Array, observe?: 'response', headers?: Headers): Observable>; public createUsersWithListInput(body: Array, observe: any = 'body', headers: Headers = {}): Observable { - if (!body){ + if (body == null){ throw new Error('Required parameter body was null or undefined when calling createUsersWithListInput.'); } @@ -123,7 +123,7 @@ export class UserService { public deleteUser(username: string, observe?: 'body', headers?: Headers): Observable; public deleteUser(username: string, observe?: 'response', headers?: Headers): Observable>; public deleteUser(username: string, observe: any = 'body', headers: Headers = {}): Observable { - if (!username){ + if (username == null){ throw new Error('Required parameter username was null or undefined when calling deleteUser.'); } @@ -148,11 +148,11 @@ export class UserService { public getUserByName(username: string, observe?: 'body', headers?: Headers): Observable; public getUserByName(username: string, observe?: 'response', headers?: Headers): Observable>; public getUserByName(username: string, observe: any = 'body', headers: Headers = {}): Observable { - if (!username){ + if (username == null){ throw new Error('Required parameter username was null or undefined when calling getUserByName.'); } - headers['Accept'] = 'application/xml'; + headers['Accept'] = 'application/xml, application/json'; const response: Observable> = this.httpClient.get(`${this.basePath}/user/${encodeURIComponent(String(username))}`, headers); if (observe == 'body') { @@ -174,11 +174,11 @@ export class UserService { public loginUser(username: string, password: string, observe?: 'body', headers?: Headers): Observable; public loginUser(username: string, password: string, observe?: 'response', headers?: Headers): Observable>; public loginUser(username: string, password: string, observe: any = 'body', headers: Headers = {}): Observable { - if (!username){ + if (username == null){ throw new Error('Required parameter username was null or undefined when calling loginUser.'); } - if (!password){ + if (password == null){ throw new Error('Required parameter password was null or undefined when calling loginUser.'); } @@ -190,7 +190,7 @@ export class UserService { queryParameters.push("password="+encodeURIComponent(String(password))); } - headers['Accept'] = 'application/xml'; + headers['Accept'] = 'application/xml, application/json'; const response: Observable> = this.httpClient.get(`${this.basePath}/user/login?${queryParameters.join('&')}`, headers); if (observe == 'body') { @@ -232,11 +232,11 @@ export class UserService { public updateUser(username: string, body: User, observe?: 'body', headers?: Headers): Observable; public updateUser(username: string, body: User, observe?: 'response', headers?: Headers): Observable>; public updateUser(username: string, body: User, observe: any = 'body', headers: Headers = {}): Observable { - if (!username){ + if (username == null){ throw new Error('Required parameter username was null or undefined when calling updateUser.'); } - if (!body){ + if (body == null){ throw new Error('Required parameter body was null or undefined when calling updateUser.'); } diff --git a/samples/client/petstore/typescript-inversify/model/inlineObject.ts b/samples/client/petstore/typescript-inversify/model/inlineObject.ts index 7ebc2ff49162..0b51164ddb6e 100644 --- a/samples/client/petstore/typescript-inversify/model/inlineObject.ts +++ b/samples/client/petstore/typescript-inversify/model/inlineObject.ts @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * - * OpenAPI spec version: 1.0.0 + * The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/samples/client/petstore/typescript-inversify/model/inlineObject1.ts b/samples/client/petstore/typescript-inversify/model/inlineObject1.ts index 3f35ccedd9be..de83a67ccc31 100644 --- a/samples/client/petstore/typescript-inversify/model/inlineObject1.ts +++ b/samples/client/petstore/typescript-inversify/model/inlineObject1.ts @@ -2,7 +2,7 @@ * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * - * OpenAPI spec version: 1.0.0 + * The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). From ff34ccf1082ca0ac04ca832055f98b8fd1ebfa79 Mon Sep 17 00:00:00 2001 From: Bodo Graumann Date: Mon, 9 Sep 2019 08:40:26 +0200 Subject: [PATCH 5/5] [typescript-inversify] Use more explicit null check This does not change the semantic of the generated code, but makes it more explicit. Co-Authored-By: Esteban Gehring --- .../typescript-inversify/api.service.mustache | 2 +- .../typescript-inversify/api/pet.service.ts | 16 ++++++++-------- .../typescript-inversify/api/store.service.ts | 6 +++--- .../typescript-inversify/api/user.service.ts | 18 +++++++++--------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache b/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache index bc38b97e612c..033de44d80b7 100644 --- a/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache @@ -60,7 +60,7 @@ export class {{classname}} { public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}observe: any = 'body', headers: Headers = {}): {{#usePromise}}Promise{{/usePromise}}{{^usePromise}}Observable{{/usePromise}} { {{#allParams}} {{#required}} - if ({{paramName}} == null){ + if ({{paramName}} === null || {{paramName}} === undefined){ throw new Error('Required parameter {{paramName}} was null or undefined when calling {{nickname}}.'); } diff --git a/samples/client/petstore/typescript-inversify/api/pet.service.ts b/samples/client/petstore/typescript-inversify/api/pet.service.ts index 77d72833d7df..37a5bf4004ca 100644 --- a/samples/client/petstore/typescript-inversify/api/pet.service.ts +++ b/samples/client/petstore/typescript-inversify/api/pet.service.ts @@ -46,7 +46,7 @@ export class PetService { public addPet(body: Pet, observe?: 'body', headers?: Headers): Observable; public addPet(body: Pet, observe?: 'response', headers?: Headers): Observable>; public addPet(body: Pet, observe: any = 'body', headers: Headers = {}): Observable { - if (body == null){ + if (body === null || body === undefined){ throw new Error('Required parameter body was null or undefined when calling addPet.'); } @@ -80,7 +80,7 @@ export class PetService { public deletePet(petId: number, apiKey?: string, observe?: 'body', headers?: Headers): Observable; public deletePet(petId: number, apiKey?: string, observe?: 'response', headers?: Headers): Observable>; public deletePet(petId: number, apiKey?: string, observe: any = 'body', headers: Headers = {}): Observable { - if (petId == null){ + if (petId === null || petId === undefined){ throw new Error('Required parameter petId was null or undefined when calling deletePet.'); } @@ -116,7 +116,7 @@ export class PetService { public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, observe?: 'body', headers?: Headers): Observable>; public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, observe?: 'response', headers?: Headers): Observable>>; public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, observe: any = 'body', headers: Headers = {}): Observable { - if (status == null){ + if (status === null || status === undefined){ throw new Error('Required parameter status was null or undefined when calling findPetsByStatus.'); } @@ -153,7 +153,7 @@ export class PetService { public findPetsByTags(tags: Array, observe?: 'body', headers?: Headers): Observable>; public findPetsByTags(tags: Array, observe?: 'response', headers?: Headers): Observable>>; public findPetsByTags(tags: Array, observe: any = 'body', headers: Headers = {}): Observable { - if (tags == null){ + if (tags === null || tags === undefined){ throw new Error('Required parameter tags was null or undefined when calling findPetsByTags.'); } @@ -190,7 +190,7 @@ export class PetService { public getPetById(petId: number, observe?: 'body', headers?: Headers): Observable; public getPetById(petId: number, observe?: 'response', headers?: Headers): Observable>; public getPetById(petId: number, observe: any = 'body', headers: Headers = {}): Observable { - if (petId == null){ + if (petId === null || petId === undefined){ throw new Error('Required parameter petId was null or undefined when calling getPetById.'); } @@ -219,7 +219,7 @@ export class PetService { public updatePet(body: Pet, observe?: 'body', headers?: Headers): Observable; public updatePet(body: Pet, observe?: 'response', headers?: Headers): Observable>; public updatePet(body: Pet, observe: any = 'body', headers: Headers = {}): Observable { - if (body == null){ + if (body === null || body === undefined){ throw new Error('Required parameter body was null or undefined when calling updatePet.'); } @@ -254,7 +254,7 @@ export class PetService { public updatePetWithForm(petId: number, name?: string, status?: string, observe?: 'body', headers?: Headers): Observable; public updatePetWithForm(petId: number, name?: string, status?: string, observe?: 'response', headers?: Headers): Observable>; public updatePetWithForm(petId: number, name?: string, status?: string, observe: any = 'body', headers: Headers = {}): Observable { - if (petId == null){ + if (petId === null || petId === undefined){ throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.'); } @@ -297,7 +297,7 @@ export class PetService { public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, observe?: 'body', headers?: Headers): Observable; public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, observe?: 'response', headers?: Headers): Observable>; public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, observe: any = 'body', headers: Headers = {}): Observable { - if (petId == null){ + if (petId === null || petId === undefined){ throw new Error('Required parameter petId was null or undefined when calling uploadFile.'); } diff --git a/samples/client/petstore/typescript-inversify/api/store.service.ts b/samples/client/petstore/typescript-inversify/api/store.service.ts index b09cc9061e2a..b383a6937d5c 100644 --- a/samples/client/petstore/typescript-inversify/api/store.service.ts +++ b/samples/client/petstore/typescript-inversify/api/store.service.ts @@ -45,7 +45,7 @@ export class StoreService { public deleteOrder(orderId: string, observe?: 'body', headers?: Headers): Observable; public deleteOrder(orderId: string, observe?: 'response', headers?: Headers): Observable>; public deleteOrder(orderId: string, observe: any = 'body', headers: Headers = {}): Observable { - if (orderId == null){ + if (orderId === null || orderId === undefined){ throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.'); } @@ -94,7 +94,7 @@ export class StoreService { public getOrderById(orderId: number, observe?: 'body', headers?: Headers): Observable; public getOrderById(orderId: number, observe?: 'response', headers?: Headers): Observable>; public getOrderById(orderId: number, observe: any = 'body', headers: Headers = {}): Observable { - if (orderId == null){ + if (orderId === null || orderId === undefined){ throw new Error('Required parameter orderId was null or undefined when calling getOrderById.'); } @@ -119,7 +119,7 @@ export class StoreService { public placeOrder(body: Order, observe?: 'body', headers?: Headers): Observable; public placeOrder(body: Order, observe?: 'response', headers?: Headers): Observable>; public placeOrder(body: Order, observe: any = 'body', headers: Headers = {}): Observable { - if (body == null){ + if (body === null || body === undefined){ throw new Error('Required parameter body was null or undefined when calling placeOrder.'); } diff --git a/samples/client/petstore/typescript-inversify/api/user.service.ts b/samples/client/petstore/typescript-inversify/api/user.service.ts index 830e611f48b4..a2c15a745413 100644 --- a/samples/client/petstore/typescript-inversify/api/user.service.ts +++ b/samples/client/petstore/typescript-inversify/api/user.service.ts @@ -45,7 +45,7 @@ export class UserService { public createUser(body: User, observe?: 'body', headers?: Headers): Observable; public createUser(body: User, observe?: 'response', headers?: Headers): Observable>; public createUser(body: User, observe: any = 'body', headers: Headers = {}): Observable { - if (body == null){ + if (body === null || body === undefined){ throw new Error('Required parameter body was null or undefined when calling createUser.'); } @@ -71,7 +71,7 @@ export class UserService { public createUsersWithArrayInput(body: Array, observe?: 'body', headers?: Headers): Observable; public createUsersWithArrayInput(body: Array, observe?: 'response', headers?: Headers): Observable>; public createUsersWithArrayInput(body: Array, observe: any = 'body', headers: Headers = {}): Observable { - if (body == null){ + if (body === null || body === undefined){ throw new Error('Required parameter body was null or undefined when calling createUsersWithArrayInput.'); } @@ -97,7 +97,7 @@ export class UserService { public createUsersWithListInput(body: Array, observe?: 'body', headers?: Headers): Observable; public createUsersWithListInput(body: Array, observe?: 'response', headers?: Headers): Observable>; public createUsersWithListInput(body: Array, observe: any = 'body', headers: Headers = {}): Observable { - if (body == null){ + if (body === null || body === undefined){ throw new Error('Required parameter body was null or undefined when calling createUsersWithListInput.'); } @@ -123,7 +123,7 @@ export class UserService { public deleteUser(username: string, observe?: 'body', headers?: Headers): Observable; public deleteUser(username: string, observe?: 'response', headers?: Headers): Observable>; public deleteUser(username: string, observe: any = 'body', headers: Headers = {}): Observable { - if (username == null){ + if (username === null || username === undefined){ throw new Error('Required parameter username was null or undefined when calling deleteUser.'); } @@ -148,7 +148,7 @@ export class UserService { public getUserByName(username: string, observe?: 'body', headers?: Headers): Observable; public getUserByName(username: string, observe?: 'response', headers?: Headers): Observable>; public getUserByName(username: string, observe: any = 'body', headers: Headers = {}): Observable { - if (username == null){ + if (username === null || username === undefined){ throw new Error('Required parameter username was null or undefined when calling getUserByName.'); } @@ -174,11 +174,11 @@ export class UserService { public loginUser(username: string, password: string, observe?: 'body', headers?: Headers): Observable; public loginUser(username: string, password: string, observe?: 'response', headers?: Headers): Observable>; public loginUser(username: string, password: string, observe: any = 'body', headers: Headers = {}): Observable { - if (username == null){ + if (username === null || username === undefined){ throw new Error('Required parameter username was null or undefined when calling loginUser.'); } - if (password == null){ + if (password === null || password === undefined){ throw new Error('Required parameter password was null or undefined when calling loginUser.'); } @@ -232,11 +232,11 @@ export class UserService { public updateUser(username: string, body: User, observe?: 'body', headers?: Headers): Observable; public updateUser(username: string, body: User, observe?: 'response', headers?: Headers): Observable>; public updateUser(username: string, body: User, observe: any = 'body', headers: Headers = {}): Observable { - if (username == null){ + if (username === null || username === undefined){ throw new Error('Required parameter username was null or undefined when calling updateUser.'); } - if (body == null){ + if (body === null || body === undefined){ throw new Error('Required parameter body was null or undefined when calling updateUser.'); }