From 9cd546651d84348c59b7cb1fcdda982a57de6c31 Mon Sep 17 00:00:00 2001 From: Damien Pontifex Date: Fri, 16 Dec 2016 18:55:24 +0800 Subject: [PATCH] Using typescript 2.1.4 object spread operator instead of custom object extend function --- .../resources/typescript-angular/api.mustache | 20 ++--- .../typescript-angular2/api.mustache | 17 +--- .../resources/typescript-node/api.mustache | 11 +-- .../typescript-angular/API/Client/PetApi.ts | 83 +++++++---------- .../typescript-angular/API/Client/StoreApi.ts | 47 ++++------ .../typescript-angular/API/Client/UserApi.ts | 83 +++++++---------- .../petstore/typescript-angular/package.json | 5 +- .../petstore/typescript-angular/tsconfig.json | 9 +- .../petstore/typescript-angular/tsd.json | 24 ----- .../typescript-angular2/default/api/PetApi.ts | 31 ++----- .../default/api/StoreApi.ts | 23 +---- .../default/api/UserApi.ts | 31 ++----- .../typescript-angular2/npm/README.md | 4 +- .../typescript-angular2/npm/api/PetApi.ts | 31 ++----- .../typescript-angular2/npm/api/StoreApi.ts | 23 +---- .../typescript-angular2/npm/api/UserApi.ts | 31 ++----- .../typescript-angular2/npm/package.json | 2 +- .../petstore/typescript-node/default/api.ts | 89 +++++-------------- .../petstore/typescript-node/npm/api.ts | 89 +++++-------------- .../petstore/typescript-node/npm/client.ts | 2 +- .../petstore/typescript-node/npm/package.json | 8 +- .../typescript-node/npm/tsconfig.json | 10 ++- .../petstore/typescript-node/npm/typings.json | 10 --- 23 files changed, 202 insertions(+), 481 deletions(-) delete mode 100644 samples/client/petstore/typescript-angular/tsd.json delete mode 100644 samples/client/petstore/typescript-node/npm/typings.json diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/api.mustache index 6a426c806f1..cd4ecba7390 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/api.mustache @@ -14,7 +14,7 @@ namespace {{package}} { {{/description}} export class {{classname}} { protected basePath = '{{basePath}}'; - public defaultHeaders : any = {}; + public defaultHeaders : ng.IHttpRequestConfigHeaders = {}; static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath']; @@ -24,27 +24,18 @@ namespace {{package}} { } } - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - objA[key] = objB[key]; - } - } - return objA; - } - {{#operation}} /** * {{summary}} * {{notes}} {{#allParams}}* @param {{paramName}} {{description}} {{/allParams}}*/ - public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: any ) : ng.IHttpPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> { + public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> { const localVarPath = this.basePath + '{{path}}'{{#pathParams}} .replace('{' + '{{baseName}}' + '}', String({{paramName}})){{/pathParams}}; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; {{#hasFormParams}} let formParams: any = {}; @@ -75,10 +66,9 @@ namespace {{package}} { formParams['{{baseName}}'] = {{paramName}}; {{/formParams}} - let httpRequestParams: any = { + let httpRequestParams: ng.IRequestConfig = { method: '{{httpMethod}}', url: localVarPath, - json: {{#hasFormParams}}false{{/hasFormParams}}{{^hasFormParams}}true{{/hasFormParams}}, {{#bodyParam}}data: {{paramName}}, {{/bodyParam}} {{#hasFormParams}}data: this.$httpParamSerializer(formParams), @@ -88,7 +78,7 @@ namespace {{package}} { }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache index 8700083b63d..fa77c842b83 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache @@ -35,21 +35,6 @@ export class {{classname}} { } } - /** - * - * Extends object by coping non-existing properties. - * @param objA object to be extended - * @param objB source object - */ - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - (objA as any)[key] = (objB as any)[key]; - } - } - return objA; - } - {{#operation}} /** * {{summary}} @@ -179,7 +164,7 @@ export class {{classname}} { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); 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 48bbaabf5b0..87c8310d6e7 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-node/api.mustache @@ -183,14 +183,7 @@ export class {{classname}} { } {{/isOAuth}} {{/authMethods}} - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - objA[key] = objB[key]; - } - } - return objA; - } + {{#operation}} /** * {{summary}} @@ -201,7 +194,7 @@ export class {{classname}} { const localVarPath = this.basePath + '{{path}}'{{#pathParams}} .replace('{' + '{{baseName}}' + '}', String({{paramName}})){{/pathParams}}; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; {{#allParams}}{{#required}} diff --git a/samples/client/petstore/typescript-angular/API/Client/PetApi.ts b/samples/client/petstore/typescript-angular/API/Client/PetApi.ts index ec5ab968c9d..72d76d1890e 100644 --- a/samples/client/petstore/typescript-angular/API/Client/PetApi.ts +++ b/samples/client/petstore/typescript-angular/API/Client/PetApi.ts @@ -19,7 +19,7 @@ namespace API.Client { export class PetApi { protected basePath = 'http://petstore.swagger.io/v2'; - public defaultHeaders : any = {}; + public defaultHeaders : ng.IHttpRequestConfigHeaders = {}; static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath']; @@ -29,36 +29,26 @@ namespace API.Client { } } - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - objA[key] = objB[key]; - } - } - return objA; - } - /** * Add a new pet to the store * * @param body Pet object that needs to be added to the store */ - public addPet (body?: Pet, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { + public addPet (body?: Pet, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise<{}> { const localVarPath = this.basePath + '/pet'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - let httpRequestParams: any = { + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; + let httpRequestParams: ng.IRequestConfig = { method: 'POST', url: localVarPath, - json: true, data: body, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); @@ -69,28 +59,27 @@ namespace API.Client { * @param petId Pet id to delete * @param apiKey */ - public deletePet (petId: number, apiKey?: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { + public deletePet (petId: number, apiKey?: string, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise<{}> { const localVarPath = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; // verify required parameter 'petId' is not null or undefined if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling deletePet.'); } headerParams['api_key'] = apiKey; - let httpRequestParams: any = { + let httpRequestParams: ng.IRequestConfig = { method: 'DELETE', url: localVarPath, - json: true, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); @@ -100,25 +89,24 @@ namespace API.Client { * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - public findPetsByStatus (status?: Array, extraHttpRequestParams?: any ) : ng.IHttpPromise> { + public findPetsByStatus (status?: Array, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise> { const localVarPath = this.basePath + '/pet/findByStatus'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; if (status !== undefined) { queryParameters['status'] = status; } - let httpRequestParams: any = { + let httpRequestParams: ng.IRequestConfig = { method: 'GET', url: localVarPath, - json: true, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); @@ -128,25 +116,24 @@ namespace API.Client { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - public findPetsByTags (tags?: Array, extraHttpRequestParams?: any ) : ng.IHttpPromise> { + public findPetsByTags (tags?: Array, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise> { const localVarPath = this.basePath + '/pet/findByTags'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; if (tags !== undefined) { queryParameters['tags'] = tags; } - let httpRequestParams: any = { + let httpRequestParams: ng.IRequestConfig = { method: 'GET', url: localVarPath, - json: true, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); @@ -156,26 +143,25 @@ namespace API.Client { * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched */ - public getPetById (petId: number, extraHttpRequestParams?: any ) : ng.IHttpPromise { + public getPetById (petId: number, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise { const localVarPath = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; // verify required parameter 'petId' is not null or undefined if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling getPetById.'); } - let httpRequestParams: any = { + let httpRequestParams: ng.IRequestConfig = { method: 'GET', url: localVarPath, - json: true, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); @@ -185,22 +171,21 @@ namespace API.Client { * * @param body Pet object that needs to be added to the store */ - public updatePet (body?: Pet, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { + public updatePet (body?: Pet, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise<{}> { const localVarPath = this.basePath + '/pet'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - let httpRequestParams: any = { + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; + let httpRequestParams: ng.IRequestConfig = { method: 'PUT', url: localVarPath, - json: true, data: body, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); @@ -212,12 +197,12 @@ namespace API.Client { * @param name Updated name of the pet * @param status Updated status of the pet */ - public updatePetWithForm (petId: string, name?: string, status?: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { + public updatePetWithForm (petId: string, name?: string, status?: string, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise<{}> { const localVarPath = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; let formParams: any = {}; // verify required parameter 'petId' is not null or undefined @@ -230,17 +215,16 @@ namespace API.Client { formParams['status'] = status; - let httpRequestParams: any = { + let httpRequestParams: ng.IRequestConfig = { method: 'POST', url: localVarPath, - json: false, data: this.$httpParamSerializer(formParams), params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); @@ -252,12 +236,12 @@ namespace API.Client { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - public uploadFile (petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { + public uploadFile (petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise<{}> { const localVarPath = this.basePath + '/pet/{petId}/uploadImage' .replace('{' + 'petId' + '}', String(petId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; let formParams: any = {}; // verify required parameter 'petId' is not null or undefined @@ -270,17 +254,16 @@ namespace API.Client { formParams['file'] = file; - let httpRequestParams: any = { + let httpRequestParams: ng.IRequestConfig = { method: 'POST', url: localVarPath, - json: false, data: this.$httpParamSerializer(formParams), params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); diff --git a/samples/client/petstore/typescript-angular/API/Client/StoreApi.ts b/samples/client/petstore/typescript-angular/API/Client/StoreApi.ts index 9be77cc81a1..bb5994c050b 100644 --- a/samples/client/petstore/typescript-angular/API/Client/StoreApi.ts +++ b/samples/client/petstore/typescript-angular/API/Client/StoreApi.ts @@ -19,7 +19,7 @@ namespace API.Client { export class StoreApi { protected basePath = 'http://petstore.swagger.io/v2'; - public defaultHeaders : any = {}; + public defaultHeaders : ng.IHttpRequestConfigHeaders = {}; static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath']; @@ -29,40 +29,30 @@ namespace API.Client { } } - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - objA[key] = objB[key]; - } - } - return objA; - } - /** * Delete purchase order by ID * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param orderId ID of the order that needs to be deleted */ - public deleteOrder (orderId: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { + public deleteOrder (orderId: string, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise<{}> { const localVarPath = this.basePath + '/store/order/{orderId}' .replace('{' + 'orderId' + '}', String(orderId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; // verify required parameter 'orderId' is not null or undefined if (orderId === null || orderId === undefined) { throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.'); } - let httpRequestParams: any = { + let httpRequestParams: ng.IRequestConfig = { method: 'DELETE', url: localVarPath, - json: true, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); @@ -71,21 +61,20 @@ namespace API.Client { * Returns pet inventories by status * Returns a map of status codes to quantities */ - public getInventory (extraHttpRequestParams?: any ) : ng.IHttpPromise<{ [key: string]: number; }> { + public getInventory (extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise<{ [key: string]: number; }> { const localVarPath = this.basePath + '/store/inventory'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - let httpRequestParams: any = { + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; + let httpRequestParams: ng.IRequestConfig = { method: 'GET', url: localVarPath, - json: true, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); @@ -95,26 +84,25 @@ namespace API.Client { * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - public getOrderById (orderId: string, extraHttpRequestParams?: any ) : ng.IHttpPromise { + public getOrderById (orderId: string, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise { const localVarPath = this.basePath + '/store/order/{orderId}' .replace('{' + 'orderId' + '}', String(orderId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; // verify required parameter 'orderId' is not null or undefined if (orderId === null || orderId === undefined) { throw new Error('Required parameter orderId was null or undefined when calling getOrderById.'); } - let httpRequestParams: any = { + let httpRequestParams: ng.IRequestConfig = { method: 'GET', url: localVarPath, - json: true, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); @@ -124,22 +112,21 @@ namespace API.Client { * * @param body order placed for purchasing the pet */ - public placeOrder (body?: Order, extraHttpRequestParams?: any ) : ng.IHttpPromise { + public placeOrder (body?: Order, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise { const localVarPath = this.basePath + '/store/order'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - let httpRequestParams: any = { + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; + let httpRequestParams: ng.IRequestConfig = { method: 'POST', url: localVarPath, - json: true, data: body, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); diff --git a/samples/client/petstore/typescript-angular/API/Client/UserApi.ts b/samples/client/petstore/typescript-angular/API/Client/UserApi.ts index cd69c69c47e..d34ebbdc5d0 100644 --- a/samples/client/petstore/typescript-angular/API/Client/UserApi.ts +++ b/samples/client/petstore/typescript-angular/API/Client/UserApi.ts @@ -19,7 +19,7 @@ namespace API.Client { export class UserApi { protected basePath = 'http://petstore.swagger.io/v2'; - public defaultHeaders : any = {}; + public defaultHeaders : ng.IHttpRequestConfigHeaders = {}; static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath']; @@ -29,36 +29,26 @@ namespace API.Client { } } - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - objA[key] = objB[key]; - } - } - return objA; - } - /** * Create user * This can only be done by the logged in user. * @param body Created user object */ - public createUser (body?: User, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { + public createUser (body?: User, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise<{}> { const localVarPath = this.basePath + '/user'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - let httpRequestParams: any = { + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; + let httpRequestParams: ng.IRequestConfig = { method: 'POST', url: localVarPath, - json: true, data: body, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); @@ -68,22 +58,21 @@ namespace API.Client { * * @param body List of user object */ - public createUsersWithArrayInput (body?: Array, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { + public createUsersWithArrayInput (body?: Array, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise<{}> { const localVarPath = this.basePath + '/user/createWithArray'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - let httpRequestParams: any = { + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; + let httpRequestParams: ng.IRequestConfig = { method: 'POST', url: localVarPath, - json: true, data: body, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); @@ -93,22 +82,21 @@ namespace API.Client { * * @param body List of user object */ - public createUsersWithListInput (body?: Array, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { + public createUsersWithListInput (body?: Array, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise<{}> { const localVarPath = this.basePath + '/user/createWithList'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - let httpRequestParams: any = { + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; + let httpRequestParams: ng.IRequestConfig = { method: 'POST', url: localVarPath, - json: true, data: body, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); @@ -118,26 +106,25 @@ namespace API.Client { * This can only be done by the logged in user. * @param username The name that needs to be deleted */ - public deleteUser (username: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { + public deleteUser (username: string, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise<{}> { const localVarPath = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', String(username)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; // verify required parameter 'username' is not null or undefined if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling deleteUser.'); } - let httpRequestParams: any = { + let httpRequestParams: ng.IRequestConfig = { method: 'DELETE', url: localVarPath, - json: true, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); @@ -147,26 +134,25 @@ namespace API.Client { * * @param username The name that needs to be fetched. Use user1 for testing. */ - public getUserByName (username: string, extraHttpRequestParams?: any ) : ng.IHttpPromise { + public getUserByName (username: string, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise { const localVarPath = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', String(username)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; // verify required parameter 'username' is not null or undefined if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling getUserByName.'); } - let httpRequestParams: any = { + let httpRequestParams: ng.IRequestConfig = { method: 'GET', url: localVarPath, - json: true, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); @@ -177,11 +163,11 @@ namespace API.Client { * @param username The user name for login * @param password The password for login in clear text */ - public loginUser (username?: string, password?: string, extraHttpRequestParams?: any ) : ng.IHttpPromise { + public loginUser (username?: string, password?: string, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise { const localVarPath = this.basePath + '/user/login'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; if (username !== undefined) { queryParameters['username'] = username; } @@ -190,16 +176,15 @@ namespace API.Client { queryParameters['password'] = password; } - let httpRequestParams: any = { + let httpRequestParams: ng.IRequestConfig = { method: 'GET', url: localVarPath, - json: true, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); @@ -208,21 +193,20 @@ namespace API.Client { * Logs out current logged in user session * */ - public logoutUser (extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { + public logoutUser (extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise<{}> { const localVarPath = this.basePath + '/user/logout'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - let httpRequestParams: any = { + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; + let httpRequestParams: ng.IRequestConfig = { method: 'GET', url: localVarPath, - json: true, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); @@ -233,27 +217,26 @@ namespace API.Client { * @param username name that need to be deleted * @param body Updated user object */ - public updateUser (username: string, body?: User, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { + public updateUser (username: string, body?: User, extraHttpRequestParams?: ng.IRequestShortcutConfig ) : ng.IHttpPromise<{}> { const localVarPath = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', String(username)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: ng.IHttpRequestConfigHeaders = { ...this.defaultHeaders }; // verify required parameter 'username' is not null or undefined if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling updateUser.'); } - let httpRequestParams: any = { + let httpRequestParams: ng.IRequestConfig = { method: 'PUT', url: localVarPath, - json: true, data: body, params: queryParameters, headers: headerParams }; if (extraHttpRequestParams) { - httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams); + httpRequestParams = { ...httpRequestParams, ...extraHttpRequestParams }; } return this.$http(httpRequestParams); diff --git a/samples/client/petstore/typescript-angular/package.json b/samples/client/petstore/typescript-angular/package.json index afc18b7e777..134f0ba2dfc 100644 --- a/samples/client/petstore/typescript-angular/package.json +++ b/samples/client/petstore/typescript-angular/package.json @@ -5,7 +5,6 @@ "description": "Sample of generated TypeScript petstore client", "main": "api.js", "scripts": { - "postinstall": "tsd reinstall --overwrite", "test": "tsc --target ES6 && node client.js", "clean": "rm -Rf node_modules/ typings/ *.js" }, @@ -16,7 +15,7 @@ "angular": "^1.4.3" }, "devDependencies": { - "tsd": "^0.6.3", - "typescript": "^1.5.3" + "typescript": "^2.1.4", + "@types/angular": "^1.5.21" } } diff --git a/samples/client/petstore/typescript-angular/tsconfig.json b/samples/client/petstore/typescript-angular/tsconfig.json index 9bf11bd4cee..6d5f780a3f7 100644 --- a/samples/client/petstore/typescript-angular/tsconfig.json +++ b/samples/client/petstore/typescript-angular/tsconfig.json @@ -2,7 +2,11 @@ "compilerOptions": { "noImplicitAny": true, "suppressImplicitAnyIndexErrors": true, - "out": "client.js" + "out": "client.js", + "lib": ["dom", "es5", "es2015"], + "typeRoots": [ + "./node_modules/@types" + ] }, "files": [ "API/Client/Category.ts", @@ -13,7 +17,6 @@ "API/Client/Order.ts", "API/Client/PetApi.ts", "API/Client/Tag.ts", - "API/Client/UserApi.ts", - "typings/tsd.d.ts" + "API/Client/UserApi.ts" ] } diff --git a/samples/client/petstore/typescript-angular/tsd.json b/samples/client/petstore/typescript-angular/tsd.json deleted file mode 100644 index c4cfa3f1bac..00000000000 --- a/samples/client/petstore/typescript-angular/tsd.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "version": "v4", - "repo": "borisyankov/DefinitelyTyped", - "ref": "master", - "path": "typings", - "bundle": "typings/tsd.d.ts", - "installed": { - "angularjs/angular.d.ts": { - "commit": "f6c8ca47193fb67947944a3170912672ac3e908e" - }, - "jquery/jquery.d.ts": { - "commit": "f6c8ca47193fb67947944a3170912672ac3e908e" - }, - "request/request.d.ts": { - "commit": "f6c8ca47193fb67947944a3170912672ac3e908e" - }, - "form-data/form-data.d.ts": { - "commit": "f6c8ca47193fb67947944a3170912672ac3e908e" - }, - "node/node.d.ts": { - "commit": "f6c8ca47193fb67947944a3170912672ac3e908e" - } - } -} diff --git a/samples/client/petstore/typescript-angular2/default/api/PetApi.ts b/samples/client/petstore/typescript-angular2/default/api/PetApi.ts index 5751b452369..f1fcc31fd29 100644 --- a/samples/client/petstore/typescript-angular2/default/api/PetApi.ts +++ b/samples/client/petstore/typescript-angular2/default/api/PetApi.ts @@ -40,21 +40,6 @@ export class PetApi { } } - /** - * - * Extends object by coping non-existing properties. - * @param objA object to be extended - * @param objB source object - */ - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - (objA as any)[key] = (objB as any)[key]; - } - } - return objA; - } - /** * Add a new pet to the store * @@ -236,7 +221,7 @@ export class PetApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -291,7 +276,7 @@ export class PetApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -343,7 +328,7 @@ export class PetApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -395,7 +380,7 @@ export class PetApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -453,7 +438,7 @@ export class PetApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -506,7 +491,7 @@ export class PetApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -572,7 +557,7 @@ export class PetApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -638,7 +623,7 @@ export class PetApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); diff --git a/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts b/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts index 484d5e56fde..5c4000a4083 100644 --- a/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts +++ b/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts @@ -40,21 +40,6 @@ export class StoreApi { } } - /** - * - * Extends object by coping non-existing properties. - * @param objA object to be extended - * @param objB source object - */ - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - (objA as any)[key] = (objB as any)[key]; - } - } - return objA; - } - /** * Delete purchase order by ID * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -157,7 +142,7 @@ export class StoreApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -201,7 +186,7 @@ export class StoreApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -245,7 +230,7 @@ export class StoreApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -287,7 +272,7 @@ export class StoreApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); diff --git a/samples/client/petstore/typescript-angular2/default/api/UserApi.ts b/samples/client/petstore/typescript-angular2/default/api/UserApi.ts index 8dda0cf8377..6e4af530280 100644 --- a/samples/client/petstore/typescript-angular2/default/api/UserApi.ts +++ b/samples/client/petstore/typescript-angular2/default/api/UserApi.ts @@ -40,21 +40,6 @@ export class UserApi { } } - /** - * - * Extends object by coping non-existing properties. - * @param objA object to be extended - * @param objB source object - */ - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - (objA as any)[key] = (objB as any)[key]; - } - } - return objA; - } - /** * Create user * This can only be done by the logged in user. @@ -221,7 +206,7 @@ export class UserApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -263,7 +248,7 @@ export class UserApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -305,7 +290,7 @@ export class UserApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -349,7 +334,7 @@ export class UserApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -393,7 +378,7 @@ export class UserApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -440,7 +425,7 @@ export class UserApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -479,7 +464,7 @@ export class UserApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -526,7 +511,7 @@ export class UserApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); diff --git a/samples/client/petstore/typescript-angular2/npm/README.md b/samples/client/petstore/typescript-angular2/npm/README.md index 5f176a7b484..ecbcf0c7d21 100644 --- a/samples/client/petstore/typescript-angular2/npm/README.md +++ b/samples/client/petstore/typescript-angular2/npm/README.md @@ -1,4 +1,4 @@ -## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201612150011 +## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201612200826 ### Building @@ -19,7 +19,7 @@ navigate to the folder of your consuming project and run one of next commando's. _published:_ ``` -npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201612150011 --save +npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201612200826 --save ``` _unPublished (not recommended):_ diff --git a/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts b/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts index 5751b452369..f1fcc31fd29 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts @@ -40,21 +40,6 @@ export class PetApi { } } - /** - * - * Extends object by coping non-existing properties. - * @param objA object to be extended - * @param objB source object - */ - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - (objA as any)[key] = (objB as any)[key]; - } - } - return objA; - } - /** * Add a new pet to the store * @@ -236,7 +221,7 @@ export class PetApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -291,7 +276,7 @@ export class PetApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -343,7 +328,7 @@ export class PetApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -395,7 +380,7 @@ export class PetApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -453,7 +438,7 @@ export class PetApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -506,7 +491,7 @@ export class PetApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -572,7 +557,7 @@ export class PetApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -638,7 +623,7 @@ export class PetApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); diff --git a/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts b/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts index 484d5e56fde..5c4000a4083 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts @@ -40,21 +40,6 @@ export class StoreApi { } } - /** - * - * Extends object by coping non-existing properties. - * @param objA object to be extended - * @param objB source object - */ - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - (objA as any)[key] = (objB as any)[key]; - } - } - return objA; - } - /** * Delete purchase order by ID * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -157,7 +142,7 @@ export class StoreApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -201,7 +186,7 @@ export class StoreApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -245,7 +230,7 @@ export class StoreApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -287,7 +272,7 @@ export class StoreApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); diff --git a/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts b/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts index 8dda0cf8377..6e4af530280 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts @@ -40,21 +40,6 @@ export class UserApi { } } - /** - * - * Extends object by coping non-existing properties. - * @param objA object to be extended - * @param objB source object - */ - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - (objA as any)[key] = (objB as any)[key]; - } - } - return objA; - } - /** * Create user * This can only be done by the logged in user. @@ -221,7 +206,7 @@ export class UserApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -263,7 +248,7 @@ export class UserApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -305,7 +290,7 @@ export class UserApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -349,7 +334,7 @@ export class UserApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -393,7 +378,7 @@ export class UserApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -440,7 +425,7 @@ export class UserApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -479,7 +464,7 @@ export class UserApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); @@ -526,7 +511,7 @@ export class UserApi { // https://github.com/swagger-api/swagger-codegen/issues/4037 if (extraHttpRequestParams) { - requestOptions = this.extendObj(requestOptions, extraHttpRequestParams); + requestOptions = { ...requestOptions, ...extraHttpRequestParams }; } return this.http.request(path, requestOptions); diff --git a/samples/client/petstore/typescript-angular2/npm/package.json b/samples/client/petstore/typescript-angular2/npm/package.json index 6dd91bb3f86..2e2de2bec93 100644 --- a/samples/client/petstore/typescript-angular2/npm/package.json +++ b/samples/client/petstore/typescript-angular2/npm/package.json @@ -1,6 +1,6 @@ { "name": "@swagger/angular2-typescript-petstore", - "version": "0.0.1-SNAPSHOT.201612150011", + "version": "0.0.1-SNAPSHOT.201612200826", "description": "swagger client for @swagger/angular2-typescript-petstore", "author": "Swagger Codegen Contributors", "keywords": [ diff --git a/samples/client/petstore/typescript-node/default/api.ts b/samples/client/petstore/typescript-node/default/api.ts index 9deaabf6d00..36342f32b1d 100644 --- a/samples/client/petstore/typescript-node/default/api.ts +++ b/samples/client/petstore/typescript-node/default/api.ts @@ -174,14 +174,7 @@ export class PetApi { set accessToken(token: string) { this.authentications.petstore_auth.accessToken = token; } - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - objA[key] = objB[key]; - } - } - return objA; - } + /** * Add a new pet to the store * @@ -190,7 +183,7 @@ export class PetApi { public addPet (body?: Pet) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/pet'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -202,7 +195,6 @@ export class PetApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, body: body, }; @@ -242,7 +234,7 @@ export class PetApi { const localVarPath = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -261,7 +253,6 @@ export class PetApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -298,7 +289,7 @@ export class PetApi { public findPetsByStatus (status?: Array) : Promise<{ response: http.ClientResponse; body: Array; }> { const localVarPath = this.basePath + '/pet/findByStatus'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -314,7 +305,6 @@ export class PetApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -351,7 +341,7 @@ export class PetApi { public findPetsByTags (tags?: Array) : Promise<{ response: http.ClientResponse; body: Array; }> { const localVarPath = this.basePath + '/pet/findByTags'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -367,7 +357,6 @@ export class PetApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -405,7 +394,7 @@ export class PetApi { const localVarPath = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -422,7 +411,6 @@ export class PetApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -461,7 +449,7 @@ export class PetApi { public updatePet (body?: Pet) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/pet'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -473,7 +461,6 @@ export class PetApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, body: body, }; @@ -514,7 +501,7 @@ export class PetApi { const localVarPath = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -539,7 +526,6 @@ export class PetApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -575,11 +561,11 @@ export class PetApi { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - public uploadFile (petId: number, additionalMetadata?: string, file?: any) : Promise<{ response: http.ClientResponse; body?: any; }> { + public uploadFile (petId: number, additionalMetadata?: string, file?: Buffer) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/pet/{petId}/uploadImage' .replace('{' + 'petId' + '}', String(petId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -605,7 +591,6 @@ export class PetApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -674,14 +659,7 @@ export class StoreApi { set accessToken(token: string) { this.authentications.petstore_auth.accessToken = token; } - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - objA[key] = objB[key]; - } - } - return objA; - } + /** * Delete purchase order by ID * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -691,7 +669,7 @@ export class StoreApi { const localVarPath = this.basePath + '/store/order/{orderId}' .replace('{' + 'orderId' + '}', String(orderId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -708,7 +686,6 @@ export class StoreApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -742,7 +719,7 @@ export class StoreApi { public getInventory () : Promise<{ response: http.ClientResponse; body: { [key: string]: number; }; }> { const localVarPath = this.basePath + '/store/inventory'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -754,7 +731,6 @@ export class StoreApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -792,7 +768,7 @@ export class StoreApi { const localVarPath = this.basePath + '/store/order/{orderId}' .replace('{' + 'orderId' + '}', String(orderId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -809,7 +785,6 @@ export class StoreApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -844,7 +819,7 @@ export class StoreApi { public placeOrder (body?: Order) : Promise<{ response: http.ClientResponse; body: Order; }> { const localVarPath = this.basePath + '/store/order'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -856,7 +831,6 @@ export class StoreApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, body: body, }; @@ -924,14 +898,7 @@ export class UserApi { set accessToken(token: string) { this.authentications.petstore_auth.accessToken = token; } - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - objA[key] = objB[key]; - } - } - return objA; - } + /** * Create user * This can only be done by the logged in user. @@ -940,7 +907,7 @@ export class UserApi { public createUser (body?: User) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -952,7 +919,6 @@ export class UserApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, body: body, }; @@ -988,7 +954,7 @@ export class UserApi { public createUsersWithArrayInput (body?: Array) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user/createWithArray'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -1000,7 +966,6 @@ export class UserApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, body: body, }; @@ -1036,7 +1001,7 @@ export class UserApi { public createUsersWithListInput (body?: Array) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user/createWithList'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -1048,7 +1013,6 @@ export class UserApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, body: body, }; @@ -1085,7 +1049,7 @@ export class UserApi { const localVarPath = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', String(username)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -1102,7 +1066,6 @@ export class UserApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -1138,7 +1101,7 @@ export class UserApi { const localVarPath = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', String(username)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -1155,7 +1118,6 @@ export class UserApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -1191,7 +1153,7 @@ export class UserApi { public loginUser (username?: string, password?: string) : Promise<{ response: http.ClientResponse; body: string; }> { const localVarPath = this.basePath + '/user/login'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -1211,7 +1173,6 @@ export class UserApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -1245,7 +1206,7 @@ export class UserApi { public logoutUser () : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user/logout'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -1257,7 +1218,6 @@ export class UserApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -1294,7 +1254,7 @@ export class UserApi { const localVarPath = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', String(username)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -1311,7 +1271,6 @@ export class UserApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, body: body, }; diff --git a/samples/client/petstore/typescript-node/npm/api.ts b/samples/client/petstore/typescript-node/npm/api.ts index 9deaabf6d00..36342f32b1d 100644 --- a/samples/client/petstore/typescript-node/npm/api.ts +++ b/samples/client/petstore/typescript-node/npm/api.ts @@ -174,14 +174,7 @@ export class PetApi { set accessToken(token: string) { this.authentications.petstore_auth.accessToken = token; } - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - objA[key] = objB[key]; - } - } - return objA; - } + /** * Add a new pet to the store * @@ -190,7 +183,7 @@ export class PetApi { public addPet (body?: Pet) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/pet'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -202,7 +195,6 @@ export class PetApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, body: body, }; @@ -242,7 +234,7 @@ export class PetApi { const localVarPath = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -261,7 +253,6 @@ export class PetApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -298,7 +289,7 @@ export class PetApi { public findPetsByStatus (status?: Array) : Promise<{ response: http.ClientResponse; body: Array; }> { const localVarPath = this.basePath + '/pet/findByStatus'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -314,7 +305,6 @@ export class PetApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -351,7 +341,7 @@ export class PetApi { public findPetsByTags (tags?: Array) : Promise<{ response: http.ClientResponse; body: Array; }> { const localVarPath = this.basePath + '/pet/findByTags'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -367,7 +357,6 @@ export class PetApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -405,7 +394,7 @@ export class PetApi { const localVarPath = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -422,7 +411,6 @@ export class PetApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -461,7 +449,7 @@ export class PetApi { public updatePet (body?: Pet) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/pet'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -473,7 +461,6 @@ export class PetApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, body: body, }; @@ -514,7 +501,7 @@ export class PetApi { const localVarPath = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -539,7 +526,6 @@ export class PetApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -575,11 +561,11 @@ export class PetApi { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - public uploadFile (petId: number, additionalMetadata?: string, file?: any) : Promise<{ response: http.ClientResponse; body?: any; }> { + public uploadFile (petId: number, additionalMetadata?: string, file?: Buffer) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/pet/{petId}/uploadImage' .replace('{' + 'petId' + '}', String(petId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -605,7 +591,6 @@ export class PetApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -674,14 +659,7 @@ export class StoreApi { set accessToken(token: string) { this.authentications.petstore_auth.accessToken = token; } - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - objA[key] = objB[key]; - } - } - return objA; - } + /** * Delete purchase order by ID * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -691,7 +669,7 @@ export class StoreApi { const localVarPath = this.basePath + '/store/order/{orderId}' .replace('{' + 'orderId' + '}', String(orderId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -708,7 +686,6 @@ export class StoreApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -742,7 +719,7 @@ export class StoreApi { public getInventory () : Promise<{ response: http.ClientResponse; body: { [key: string]: number; }; }> { const localVarPath = this.basePath + '/store/inventory'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -754,7 +731,6 @@ export class StoreApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -792,7 +768,7 @@ export class StoreApi { const localVarPath = this.basePath + '/store/order/{orderId}' .replace('{' + 'orderId' + '}', String(orderId)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -809,7 +785,6 @@ export class StoreApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -844,7 +819,7 @@ export class StoreApi { public placeOrder (body?: Order) : Promise<{ response: http.ClientResponse; body: Order; }> { const localVarPath = this.basePath + '/store/order'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -856,7 +831,6 @@ export class StoreApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, body: body, }; @@ -924,14 +898,7 @@ export class UserApi { set accessToken(token: string) { this.authentications.petstore_auth.accessToken = token; } - private extendObj(objA: T1, objB: T2) { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - objA[key] = objB[key]; - } - } - return objA; - } + /** * Create user * This can only be done by the logged in user. @@ -940,7 +907,7 @@ export class UserApi { public createUser (body?: User) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -952,7 +919,6 @@ export class UserApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, body: body, }; @@ -988,7 +954,7 @@ export class UserApi { public createUsersWithArrayInput (body?: Array) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user/createWithArray'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -1000,7 +966,6 @@ export class UserApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, body: body, }; @@ -1036,7 +1001,7 @@ export class UserApi { public createUsersWithListInput (body?: Array) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user/createWithList'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -1048,7 +1013,6 @@ export class UserApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, body: body, }; @@ -1085,7 +1049,7 @@ export class UserApi { const localVarPath = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', String(username)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -1102,7 +1066,6 @@ export class UserApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -1138,7 +1101,7 @@ export class UserApi { const localVarPath = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', String(username)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -1155,7 +1118,6 @@ export class UserApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -1191,7 +1153,7 @@ export class UserApi { public loginUser (username?: string, password?: string) : Promise<{ response: http.ClientResponse; body: string; }> { const localVarPath = this.basePath + '/user/login'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -1211,7 +1173,6 @@ export class UserApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -1245,7 +1206,7 @@ export class UserApi { public logoutUser () : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user/logout'; let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -1257,7 +1218,6 @@ export class UserApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, }; @@ -1294,7 +1254,7 @@ export class UserApi { const localVarPath = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', String(username)); let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let headerParams: any = { ...this.defaultHeaders }; let formParams: any = {}; @@ -1311,7 +1271,6 @@ export class UserApi { headers: headerParams, uri: localVarPath, useQuerystring: this._useQuerystring, - json: true, body: body, }; diff --git a/samples/client/petstore/typescript-node/npm/client.ts b/samples/client/petstore/typescript-node/npm/client.ts index 79b8737c92b..c35c1cf1e5b 100644 --- a/samples/client/petstore/typescript-node/npm/client.ts +++ b/samples/client/petstore/typescript-node/npm/client.ts @@ -34,7 +34,7 @@ petApi.addPet(pet) }) .then((res) => { console.log('Updated pet using POST form'); - return petApi.uploadFile(petId, undefined, fs.createReadStream('sample.png')); + return petApi.uploadFile(petId, undefined, fs.readFileSync('sample.png')); }) .then((res) => { console.log('Uploaded image'); diff --git a/samples/client/petstore/typescript-node/npm/package.json b/samples/client/petstore/typescript-node/npm/package.json index 1b4dee09ea7..494fad25104 100644 --- a/samples/client/petstore/typescript-node/npm/package.json +++ b/samples/client/petstore/typescript-node/npm/package.json @@ -5,7 +5,6 @@ "repository": "GIT_USER_ID/GIT_REPO_ID", "main": "api.js", "scripts": { - "postinstall": "typings install", "clean": "rm -Rf node_modules/ typings/ *.js", "build": "tsc", "test": "npm run build && node client.js" @@ -17,8 +16,11 @@ "request": "^2.72.0" }, "devDependencies": { - "typescript": "^1.8.10", - "typings": "^0.8.1" + "typescript": "^2.1.4", + "@types/angular": "^1.5.21", + "@types/node": "^6.0.52", + "@types/bluebird": "^3.0.36", + "@types/request": "^0.0.36" }, "publishConfig":{ "registry":"https://skimdb.npmjs.com/registry" diff --git a/samples/client/petstore/typescript-node/npm/tsconfig.json b/samples/client/petstore/typescript-node/npm/tsconfig.json index 9a007e9f866..a7bf7c68afd 100644 --- a/samples/client/petstore/typescript-node/npm/tsconfig.json +++ b/samples/client/petstore/typescript-node/npm/tsconfig.json @@ -8,12 +8,14 @@ "removeComments": true, "sourceMap": true, "noLib": false, - "declaration": true + "declaration": true, + "lib": ["dom", "es5", "es2015"], + "typeRoots": [ + "./node_modules/@types" + ] }, "exclude": [ - "node_modules", - "typings/browser", - "typings/browser.d.ts" + "node_modules" ] } diff --git a/samples/client/petstore/typescript-node/npm/typings.json b/samples/client/petstore/typescript-node/npm/typings.json deleted file mode 100644 index 22fcebdc231..00000000000 --- a/samples/client/petstore/typescript-node/npm/typings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ambientDependencies": { - "core-js": "registry:dt/core-js#0.0.0+20160317120654", - "node": "registry:dt/node#4.0.0+20160423143914" - }, - "dependencies": { - "bluebird": "registry:npm/bluebird#3.3.4+20160515010139", - "request": "registry:npm/request#2.69.0+20160304121250" - } -} \ No newline at end of file