From 2f8e4fe32bdece910717f5a26d8d2e3854aaf928 Mon Sep 17 00:00:00 2001 From: Kevin Turner Date: Thu, 21 Mar 2019 14:27:38 +0000 Subject: [PATCH] [TypeScript][Node] async promises and imports (#2452) * async promises and imports * Sample regen * Correct licence info * update samples --- .../typescript-node/api-single.mustache | 20 ++++++--- .../typescript-node/default/api/petApi.ts | 21 +++++----- .../typescript-node/default/api/storeApi.ts | 12 +++--- .../typescript-node/default/api/userApi.ts | 19 ++++----- .../default/model/inlineObject.ts | 42 +++++++++++++++++++ .../default/model/inlineObject1.ts | 42 +++++++++++++++++++ .../typescript-node/npm/api/petApi.ts | 21 +++++----- .../typescript-node/npm/api/storeApi.ts | 12 +++--- .../typescript-node/npm/api/userApi.ts | 19 ++++----- 9 files changed, 151 insertions(+), 57 deletions(-) create mode 100644 samples/client/petstore/typescript-node/default/model/inlineObject.ts create mode 100644 samples/client/petstore/typescript-node/default/model/inlineObject1.ts diff --git a/modules/openapi-generator/src/main/resources/typescript-node/api-single.mustache b/modules/openapi-generator/src/main/resources/typescript-node/api-single.mustache index c1ae478c2f8..c4227e75de6 100644 --- a/modules/openapi-generator/src/main/resources/typescript-node/api-single.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-node/api-single.mustache @@ -1,16 +1,26 @@ {{>licenseInfo}} import localVarRequest = require('request'); import http = require('http'); -{{^supportsES6}} -import Promise = require('bluebird'); -{{/supportsES6}} /* tslint:disable:no-unused-locals */ {{#imports}} import { {{classname}} } from '../{{filename}}'; {{/imports}} -import { ObjectSerializer, Authentication, HttpBasicAuth, ApiKeyAuth, OAuth, VoidAuth } from '../model/models'; +import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; +{{#hasAuthMethods}} +{{#authMethods}} +{{#isBasic}} +import { HttpBasicAuth } from '../model/models'; +{{/isBasic}} +{{#isApiKey}} +import { ApiKeyAuth } from '../model/models'; +{{/isApiKey}} +{{#isOAuth}} +import { OAuth } from '../model/models'; +{{/isOAuth}} +{{/authMethods}} +{{/hasAuthMethods}} let defaultBasePath = '{{{basePath}}}'; @@ -127,7 +137,7 @@ export class {{classname}} { * @param {{paramName}} {{description}} {{/allParams}} */ - public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.{{#supportsES6}}IncomingMessage{{/supportsES6}}{{^supportsES6}}ClientResponse{{/supportsES6}}; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> { + public async {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.{{#supportsES6}}IncomingMessage{{/supportsES6}}{{^supportsES6}}ClientResponse{{/supportsES6}}; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> { const localVarPath = this.basePath + '{{{path}}}'{{#pathParams}} .replace('{' + '{{baseName}}' + '}', encodeURIComponent(String({{paramName}}))){{/pathParams}}; let localVarQueryParameters: any = {}; diff --git a/samples/client/petstore/typescript-node/default/api/petApi.ts b/samples/client/petstore/typescript-node/default/api/petApi.ts index d7d08ae5db8..22bd5057f70 100644 --- a/samples/client/petstore/typescript-node/default/api/petApi.ts +++ b/samples/client/petstore/typescript-node/default/api/petApi.ts @@ -12,13 +12,14 @@ import localVarRequest = require('request'); import http = require('http'); -import Promise = require('bluebird'); /* tslint:disable:no-unused-locals */ import { ApiResponse } from '../model/apiResponse'; import { Pet } from '../model/pet'; -import { ObjectSerializer, Authentication, HttpBasicAuth, ApiKeyAuth, OAuth, VoidAuth } from '../model/models'; +import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; +import { OAuth } from '../model/models'; +import { ApiKeyAuth } from '../model/models'; let defaultBasePath = 'http://petstore.swagger.io/v2'; @@ -83,7 +84,7 @@ export class PetApi { * @summary Add a new pet to the store * @param body Pet object that needs to be added to the store */ - public addPet (body: Pet, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async addPet (body: Pet, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/pet'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -139,7 +140,7 @@ export class PetApi { * @param petId Pet id to delete * @param apiKey */ - public deletePet (petId: number, apiKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async deletePet (petId: number, apiKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); let localVarQueryParameters: any = {}; @@ -195,7 +196,7 @@ export class PetApi { * @summary Finds Pets by status * @param status Status values that need to be considered for filter */ - public findPetsByStatus (status: Array<'available' | 'pending' | 'sold'>, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + public async findPetsByStatus (status: Array<'available' | 'pending' | 'sold'>, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { const localVarPath = this.basePath + '/pet/findByStatus'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -254,7 +255,7 @@ export class PetApi { * @summary Finds Pets by tags * @param tags Tags to filter by */ - public findPetsByTags (tags: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + public async findPetsByTags (tags: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { const localVarPath = this.basePath + '/pet/findByTags'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -313,7 +314,7 @@ export class PetApi { * @summary Find pet by ID * @param petId ID of pet to return */ - public getPetById (petId: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Pet; }> { + public async getPetById (petId: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Pet; }> { const localVarPath = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); let localVarQueryParameters: any = {}; @@ -369,7 +370,7 @@ export class PetApi { * @summary Update an existing pet * @param body Pet object that needs to be added to the store */ - public updatePet (body: Pet, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async updatePet (body: Pet, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/pet'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -426,7 +427,7 @@ export class PetApi { * @param name Updated name of the pet * @param status Updated status of the pet */ - public updatePetWithForm (petId: number, name?: string, status?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async updatePetWithForm (petId: number, name?: string, status?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); let localVarQueryParameters: any = {}; @@ -491,7 +492,7 @@ export class PetApi { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - public uploadFile (petId: number, additionalMetadata?: string, file?: Buffer, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: ApiResponse; }> { + public async uploadFile (petId: number, additionalMetadata?: string, file?: Buffer, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: ApiResponse; }> { const localVarPath = this.basePath + '/pet/{petId}/uploadImage' .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); let localVarQueryParameters: any = {}; diff --git a/samples/client/petstore/typescript-node/default/api/storeApi.ts b/samples/client/petstore/typescript-node/default/api/storeApi.ts index dbbce5ad5e9..63f0e5a13e7 100644 --- a/samples/client/petstore/typescript-node/default/api/storeApi.ts +++ b/samples/client/petstore/typescript-node/default/api/storeApi.ts @@ -12,12 +12,12 @@ import localVarRequest = require('request'); import http = require('http'); -import Promise = require('bluebird'); /* tslint:disable:no-unused-locals */ import { Order } from '../model/order'; -import { ObjectSerializer, Authentication, HttpBasicAuth, ApiKeyAuth, OAuth, VoidAuth } from '../model/models'; +import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; +import { ApiKeyAuth } from '../model/models'; let defaultBasePath = 'http://petstore.swagger.io/v2'; @@ -77,7 +77,7 @@ export class StoreApi { * @summary Delete purchase order by ID * @param orderId ID of the order that needs to be deleted */ - public deleteOrder (orderId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async deleteOrder (orderId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/store/order/{orderId}' .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); let localVarQueryParameters: any = {}; @@ -129,7 +129,7 @@ export class StoreApi { * Returns a map of status codes to quantities * @summary Returns pet inventories by status */ - public getInventory (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: { [key: string]: number; }; }> { + public async getInventory (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: { [key: string]: number; }; }> { const localVarPath = this.basePath + '/store/inventory'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -179,7 +179,7 @@ export class StoreApi { * @summary Find purchase order by ID * @param orderId ID of pet that needs to be fetched */ - public getOrderById (orderId: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Order; }> { + public async getOrderById (orderId: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Order; }> { const localVarPath = this.basePath + '/store/order/{orderId}' .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); let localVarQueryParameters: any = {}; @@ -233,7 +233,7 @@ export class StoreApi { * @summary Place an order for a pet * @param body order placed for purchasing the pet */ - public placeOrder (body: Order, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Order; }> { + public async placeOrder (body: Order, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Order; }> { const localVarPath = this.basePath + '/store/order'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); diff --git a/samples/client/petstore/typescript-node/default/api/userApi.ts b/samples/client/petstore/typescript-node/default/api/userApi.ts index 6438051f2e2..700491e1349 100644 --- a/samples/client/petstore/typescript-node/default/api/userApi.ts +++ b/samples/client/petstore/typescript-node/default/api/userApi.ts @@ -12,12 +12,11 @@ import localVarRequest = require('request'); import http = require('http'); -import Promise = require('bluebird'); /* tslint:disable:no-unused-locals */ import { User } from '../model/user'; -import { ObjectSerializer, Authentication, HttpBasicAuth, ApiKeyAuth, OAuth, VoidAuth } from '../model/models'; +import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; let defaultBasePath = 'http://petstore.swagger.io/v2'; @@ -75,7 +74,7 @@ export class UserApi { * @summary Create user * @param body Created user object */ - public createUser (body: User, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async createUser (body: User, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -128,7 +127,7 @@ export class UserApi { * @summary Creates list of users with given input array * @param body List of user object */ - public createUsersWithArrayInput (body: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async createUsersWithArrayInput (body: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user/createWithArray'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -181,7 +180,7 @@ export class UserApi { * @summary Creates list of users with given input array * @param body List of user object */ - public createUsersWithListInput (body: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async createUsersWithListInput (body: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user/createWithList'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -234,7 +233,7 @@ export class UserApi { * @summary Delete user * @param username The name that needs to be deleted */ - public deleteUser (username: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async deleteUser (username: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', encodeURIComponent(String(username))); let localVarQueryParameters: any = {}; @@ -287,7 +286,7 @@ export class UserApi { * @summary Get user by user name * @param username The name that needs to be fetched. Use user1 for testing. */ - public getUserByName (username: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: User; }> { + public async getUserByName (username: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: User; }> { const localVarPath = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', encodeURIComponent(String(username))); let localVarQueryParameters: any = {}; @@ -342,7 +341,7 @@ export class UserApi { * @param username The user name for login * @param password The password for login in clear text */ - public loginUser (username: string, password: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: string; }> { + public async loginUser (username: string, password: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: string; }> { const localVarPath = this.basePath + '/user/login'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -407,7 +406,7 @@ export class UserApi { * * @summary Logs out current logged in user session */ - public logoutUser (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async logoutUser (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user/logout'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -455,7 +454,7 @@ export class UserApi { * @param username name that need to be deleted * @param body Updated user object */ - public updateUser (username: string, body: User, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async updateUser (username: string, body: User, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', encodeURIComponent(String(username))); let localVarQueryParameters: any = {}; diff --git a/samples/client/petstore/typescript-node/default/model/inlineObject.ts b/samples/client/petstore/typescript-node/default/model/inlineObject.ts new file mode 100644 index 00000000000..ceaabe7df48 --- /dev/null +++ b/samples/client/petstore/typescript-node/default/model/inlineObject.ts @@ -0,0 +1,42 @@ +/** + * 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 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export class InlineObject { + /** + * Updated name of the pet + */ + 'name'?: string; + /** + * Updated status of the pet + */ + 'status'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "name", + "baseName": "name", + "type": "string" + }, + { + "name": "status", + "baseName": "status", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return InlineObject.attributeTypeMap; + } +} + diff --git a/samples/client/petstore/typescript-node/default/model/inlineObject1.ts b/samples/client/petstore/typescript-node/default/model/inlineObject1.ts new file mode 100644 index 00000000000..b3e23fb8438 --- /dev/null +++ b/samples/client/petstore/typescript-node/default/model/inlineObject1.ts @@ -0,0 +1,42 @@ +/** + * 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 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export class InlineObject1 { + /** + * Additional data to pass to server + */ + 'additionalMetadata'?: string; + /** + * file to upload + */ + 'file'?: Buffer; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "additionalMetadata", + "baseName": "additionalMetadata", + "type": "string" + }, + { + "name": "file", + "baseName": "file", + "type": "Buffer" + } ]; + + static getAttributeTypeMap() { + return InlineObject1.attributeTypeMap; + } +} + diff --git a/samples/client/petstore/typescript-node/npm/api/petApi.ts b/samples/client/petstore/typescript-node/npm/api/petApi.ts index d7d08ae5db8..22bd5057f70 100644 --- a/samples/client/petstore/typescript-node/npm/api/petApi.ts +++ b/samples/client/petstore/typescript-node/npm/api/petApi.ts @@ -12,13 +12,14 @@ import localVarRequest = require('request'); import http = require('http'); -import Promise = require('bluebird'); /* tslint:disable:no-unused-locals */ import { ApiResponse } from '../model/apiResponse'; import { Pet } from '../model/pet'; -import { ObjectSerializer, Authentication, HttpBasicAuth, ApiKeyAuth, OAuth, VoidAuth } from '../model/models'; +import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; +import { OAuth } from '../model/models'; +import { ApiKeyAuth } from '../model/models'; let defaultBasePath = 'http://petstore.swagger.io/v2'; @@ -83,7 +84,7 @@ export class PetApi { * @summary Add a new pet to the store * @param body Pet object that needs to be added to the store */ - public addPet (body: Pet, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async addPet (body: Pet, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/pet'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -139,7 +140,7 @@ export class PetApi { * @param petId Pet id to delete * @param apiKey */ - public deletePet (petId: number, apiKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async deletePet (petId: number, apiKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); let localVarQueryParameters: any = {}; @@ -195,7 +196,7 @@ export class PetApi { * @summary Finds Pets by status * @param status Status values that need to be considered for filter */ - public findPetsByStatus (status: Array<'available' | 'pending' | 'sold'>, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + public async findPetsByStatus (status: Array<'available' | 'pending' | 'sold'>, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { const localVarPath = this.basePath + '/pet/findByStatus'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -254,7 +255,7 @@ export class PetApi { * @summary Finds Pets by tags * @param tags Tags to filter by */ - public findPetsByTags (tags: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { + public async findPetsByTags (tags: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { const localVarPath = this.basePath + '/pet/findByTags'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -313,7 +314,7 @@ export class PetApi { * @summary Find pet by ID * @param petId ID of pet to return */ - public getPetById (petId: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Pet; }> { + public async getPetById (petId: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Pet; }> { const localVarPath = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); let localVarQueryParameters: any = {}; @@ -369,7 +370,7 @@ export class PetApi { * @summary Update an existing pet * @param body Pet object that needs to be added to the store */ - public updatePet (body: Pet, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async updatePet (body: Pet, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/pet'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -426,7 +427,7 @@ export class PetApi { * @param name Updated name of the pet * @param status Updated status of the pet */ - public updatePetWithForm (petId: number, name?: string, status?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async updatePetWithForm (petId: number, name?: string, status?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); let localVarQueryParameters: any = {}; @@ -491,7 +492,7 @@ export class PetApi { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - public uploadFile (petId: number, additionalMetadata?: string, file?: Buffer, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: ApiResponse; }> { + public async uploadFile (petId: number, additionalMetadata?: string, file?: Buffer, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: ApiResponse; }> { const localVarPath = this.basePath + '/pet/{petId}/uploadImage' .replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); let localVarQueryParameters: any = {}; diff --git a/samples/client/petstore/typescript-node/npm/api/storeApi.ts b/samples/client/petstore/typescript-node/npm/api/storeApi.ts index dbbce5ad5e9..63f0e5a13e7 100644 --- a/samples/client/petstore/typescript-node/npm/api/storeApi.ts +++ b/samples/client/petstore/typescript-node/npm/api/storeApi.ts @@ -12,12 +12,12 @@ import localVarRequest = require('request'); import http = require('http'); -import Promise = require('bluebird'); /* tslint:disable:no-unused-locals */ import { Order } from '../model/order'; -import { ObjectSerializer, Authentication, HttpBasicAuth, ApiKeyAuth, OAuth, VoidAuth } from '../model/models'; +import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; +import { ApiKeyAuth } from '../model/models'; let defaultBasePath = 'http://petstore.swagger.io/v2'; @@ -77,7 +77,7 @@ export class StoreApi { * @summary Delete purchase order by ID * @param orderId ID of the order that needs to be deleted */ - public deleteOrder (orderId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async deleteOrder (orderId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/store/order/{orderId}' .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); let localVarQueryParameters: any = {}; @@ -129,7 +129,7 @@ export class StoreApi { * Returns a map of status codes to quantities * @summary Returns pet inventories by status */ - public getInventory (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: { [key: string]: number; }; }> { + public async getInventory (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: { [key: string]: number; }; }> { const localVarPath = this.basePath + '/store/inventory'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -179,7 +179,7 @@ export class StoreApi { * @summary Find purchase order by ID * @param orderId ID of pet that needs to be fetched */ - public getOrderById (orderId: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Order; }> { + public async getOrderById (orderId: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Order; }> { const localVarPath = this.basePath + '/store/order/{orderId}' .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); let localVarQueryParameters: any = {}; @@ -233,7 +233,7 @@ export class StoreApi { * @summary Place an order for a pet * @param body order placed for purchasing the pet */ - public placeOrder (body: Order, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Order; }> { + public async placeOrder (body: Order, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Order; }> { const localVarPath = this.basePath + '/store/order'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); diff --git a/samples/client/petstore/typescript-node/npm/api/userApi.ts b/samples/client/petstore/typescript-node/npm/api/userApi.ts index 6438051f2e2..700491e1349 100644 --- a/samples/client/petstore/typescript-node/npm/api/userApi.ts +++ b/samples/client/petstore/typescript-node/npm/api/userApi.ts @@ -12,12 +12,11 @@ import localVarRequest = require('request'); import http = require('http'); -import Promise = require('bluebird'); /* tslint:disable:no-unused-locals */ import { User } from '../model/user'; -import { ObjectSerializer, Authentication, HttpBasicAuth, ApiKeyAuth, OAuth, VoidAuth } from '../model/models'; +import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; let defaultBasePath = 'http://petstore.swagger.io/v2'; @@ -75,7 +74,7 @@ export class UserApi { * @summary Create user * @param body Created user object */ - public createUser (body: User, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async createUser (body: User, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -128,7 +127,7 @@ export class UserApi { * @summary Creates list of users with given input array * @param body List of user object */ - public createUsersWithArrayInput (body: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async createUsersWithArrayInput (body: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user/createWithArray'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -181,7 +180,7 @@ export class UserApi { * @summary Creates list of users with given input array * @param body List of user object */ - public createUsersWithListInput (body: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async createUsersWithListInput (body: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user/createWithList'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -234,7 +233,7 @@ export class UserApi { * @summary Delete user * @param username The name that needs to be deleted */ - public deleteUser (username: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async deleteUser (username: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', encodeURIComponent(String(username))); let localVarQueryParameters: any = {}; @@ -287,7 +286,7 @@ export class UserApi { * @summary Get user by user name * @param username The name that needs to be fetched. Use user1 for testing. */ - public getUserByName (username: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: User; }> { + public async getUserByName (username: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: User; }> { const localVarPath = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', encodeURIComponent(String(username))); let localVarQueryParameters: any = {}; @@ -342,7 +341,7 @@ export class UserApi { * @param username The user name for login * @param password The password for login in clear text */ - public loginUser (username: string, password: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: string; }> { + public async loginUser (username: string, password: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: string; }> { const localVarPath = this.basePath + '/user/login'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -407,7 +406,7 @@ export class UserApi { * * @summary Logs out current logged in user session */ - public logoutUser (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async logoutUser (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user/logout'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -455,7 +454,7 @@ export class UserApi { * @param username name that need to be deleted * @param body Updated user object */ - public updateUser (username: string, body: User, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { + public async updateUser (username: string, body: User, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', encodeURIComponent(String(username))); let localVarQueryParameters: any = {};