From 81e23ce84e9fabc114dfb008128b3773241ef9c1 Mon Sep 17 00:00:00 2001 From: Georg Rollinger Date: Tue, 17 Jul 2018 14:43:42 +0200 Subject: [PATCH 1/2] typescript-jquery: fix promise resolution The type annotation that is generated for an API states that the JQueryPromise<...> will be resolved with a single value. The implementation, on the other hand resolves with two. This changes the implementation to resolve the promise in accordance with the type annotation. It also adds another type specifying what will be passed if the promise is rejected. --- .../main/resources/typescript-jquery/api.mustache | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-jquery/api.mustache b/modules/openapi-generator/src/main/resources/typescript-jquery/api.mustache index 5f4cf7db208d..71678eada2b7 100644 --- a/modules/openapi-generator/src/main/resources/typescript-jquery/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-jquery/api.mustache @@ -56,7 +56,10 @@ export class {{classname}} { * @param {{paramName}} {{description}} {{/allParams}} */ - public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> { + public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '{{{path}}}'{{#pathParams}}.replace('{' + '{{baseName}}' + '}', encodeURIComponent(String({{paramName}}))){{/pathParams}}; let queryParameters: any = {}; @@ -229,12 +232,15 @@ export class {{classname}} { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}any{{/returnType}}, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } From 3aeebb97efdd96b3a42215812ddaa57db945b6f5 Mon Sep 17 00:00:00 2001 From: Georg Rollinger Date: Tue, 17 Jul 2018 14:44:00 +0200 Subject: [PATCH 2/2] Update petstore sample for typescript-jquery --- .../typescript-jquery/default/api/PetApi.ts | 112 ++++++++++++----- .../typescript-jquery/default/api/StoreApi.ts | 56 ++++++--- .../typescript-jquery/default/api/UserApi.ts | 114 +++++++++++++----- .../typescript-jquery/default/model/Amount.ts | 26 ++++ .../default/model/Currency.ts | 19 +++ .../typescript-jquery/default/model/models.ts | 2 + 6 files changed, 248 insertions(+), 81 deletions(-) create mode 100644 samples/client/petstore/typescript-jquery/default/model/Amount.ts create mode 100644 samples/client/petstore/typescript-jquery/default/model/Currency.ts diff --git a/samples/client/petstore/typescript-jquery/default/api/PetApi.ts b/samples/client/petstore/typescript-jquery/default/api/PetApi.ts index 68203071fd8c..d80ef92fd5b1 100644 --- a/samples/client/petstore/typescript-jquery/default/api/PetApi.ts +++ b/samples/client/petstore/typescript-jquery/default/api/PetApi.ts @@ -51,7 +51,10 @@ 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: models.Pet, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public addPet(body: models.Pet, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/pet'; let queryParameters: any = {}; @@ -107,12 +110,15 @@ export class PetApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: any, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } @@ -123,7 +129,10 @@ export class PetApi { * @param petId Pet id to delete * @param apiKey */ - public deletePet(petId: number, apiKey?: string, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public deletePet(petId: number, apiKey?: string, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/pet/{petId}'.replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); let queryParameters: any = {}; @@ -176,12 +185,15 @@ export class PetApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: any, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } @@ -191,7 +203,10 @@ 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'>, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body: Array; }> { + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body: Array; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/pet/findByStatus'; let queryParameters: any = {}; @@ -245,12 +260,15 @@ export class PetApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body: Array; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: Array, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } @@ -260,7 +278,10 @@ export class PetApi { * @summary Finds Pets by tags * @param tags Tags to filter by */ - public findPetsByTags(tags: Array, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body: Array; }> { + public findPetsByTags(tags: Array, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body: Array; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/pet/findByTags'; let queryParameters: any = {}; @@ -314,12 +335,15 @@ export class PetApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body: Array; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: Array, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } @@ -329,7 +353,10 @@ export class PetApi { * @summary Find pet by ID * @param petId ID of pet to return */ - public getPetById(petId: number, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body: models.Pet; }> { + public getPetById(petId: number, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body: models.Pet; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/pet/{petId}'.replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); let queryParameters: any = {}; @@ -376,12 +403,15 @@ export class PetApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body: models.Pet; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: models.Pet, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } @@ -391,7 +421,10 @@ export class PetApi { * @summary Update an existing pet * @param body Pet object that needs to be added to the store */ - public updatePet(body: models.Pet, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public updatePet(body: models.Pet, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/pet'; let queryParameters: any = {}; @@ -447,12 +480,15 @@ export class PetApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: any, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } @@ -464,7 +500,10 @@ 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, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public updatePetWithForm(petId: number, name?: string, status?: string, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/pet/{petId}'.replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); let queryParameters: any = {}; @@ -533,12 +572,15 @@ export class PetApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: any, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } @@ -550,7 +592,10 @@ export class PetApi { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - public uploadFile(petId: number, additionalMetadata?: string, file?: any, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body: models.ApiResponse; }> { + public uploadFile(petId: number, additionalMetadata?: string, file?: any, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body: models.ApiResponse; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/pet/{petId}/uploadImage'.replace('{' + 'petId' + '}', encodeURIComponent(String(petId))); let queryParameters: any = {}; @@ -617,12 +662,15 @@ export class PetApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body: models.ApiResponse; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: models.ApiResponse, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } diff --git a/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts b/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts index 1a7b91c282ec..3a08a004baeb 100644 --- a/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts +++ b/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts @@ -51,7 +51,10 @@ export class StoreApi { * @summary Delete purchase order by ID * @param orderId ID of the order that needs to be deleted */ - public deleteOrder(orderId: string, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public deleteOrder(orderId: string, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/store/order/{orderId}'.replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); let queryParameters: any = {}; @@ -93,12 +96,15 @@ export class StoreApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: any, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } @@ -107,7 +113,10 @@ export class StoreApi { * Returns a map of status codes to quantities * @summary Returns pet inventories by status */ - public getInventory(extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body: { [key: string]: number; }; }> { + public getInventory(extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body: { [key: string]: number; }; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/store/inventory'; let queryParameters: any = {}; @@ -148,12 +157,15 @@ export class StoreApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body: { [key: string]: number; }; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: { [key: string]: number; }, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } @@ -163,7 +175,10 @@ export class StoreApi { * @summary Find purchase order by ID * @param orderId ID of pet that needs to be fetched */ - public getOrderById(orderId: number, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body: models.Order; }> { + public getOrderById(orderId: number, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body: models.Order; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/store/order/{orderId}'.replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); let queryParameters: any = {}; @@ -205,12 +220,15 @@ export class StoreApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body: models.Order; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: models.Order, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } @@ -220,7 +238,10 @@ export class StoreApi { * @summary Place an order for a pet * @param body order placed for purchasing the pet */ - public placeOrder(body: models.Order, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body: models.Order; }> { + public placeOrder(body: models.Order, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body: models.Order; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/store/order'; let queryParameters: any = {}; @@ -265,12 +286,15 @@ export class StoreApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body: models.Order; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: models.Order, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } diff --git a/samples/client/petstore/typescript-jquery/default/api/UserApi.ts b/samples/client/petstore/typescript-jquery/default/api/UserApi.ts index 3e8308dac354..b896fd794b4e 100644 --- a/samples/client/petstore/typescript-jquery/default/api/UserApi.ts +++ b/samples/client/petstore/typescript-jquery/default/api/UserApi.ts @@ -51,7 +51,10 @@ export class UserApi { * @summary Create user * @param body Created user object */ - public createUser(body: models.User, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public createUser(body: models.User, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/user'; let queryParameters: any = {}; @@ -96,12 +99,15 @@ export class UserApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: any, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } @@ -111,7 +117,10 @@ export class UserApi { * @summary Creates list of users with given input array * @param body List of user object */ - public createUsersWithArrayInput(body: Array, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public createUsersWithArrayInput(body: Array, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/user/createWithArray'; let queryParameters: any = {}; @@ -156,12 +165,15 @@ export class UserApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: any, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } @@ -171,7 +183,10 @@ export class UserApi { * @summary Creates list of users with given input array * @param body List of user object */ - public createUsersWithListInput(body: Array, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public createUsersWithListInput(body: Array, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/user/createWithList'; let queryParameters: any = {}; @@ -216,12 +231,15 @@ export class UserApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: any, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } @@ -231,7 +249,10 @@ export class UserApi { * @summary Delete user * @param username The name that needs to be deleted */ - public deleteUser(username: string, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public deleteUser(username: string, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/user/{username}'.replace('{' + 'username' + '}', encodeURIComponent(String(username))); let queryParameters: any = {}; @@ -273,12 +294,15 @@ export class UserApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: any, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } @@ -286,9 +310,12 @@ export class UserApi { /** * * @summary Get user by user name - * @param username The name that needs to be fetched. Use user1 for testing. + * @param username The name that needs to be fetched. Use user1 for testing. */ - public getUserByName(username: string, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body: models.User; }> { + public getUserByName(username: string, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body: models.User; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/user/{username}'.replace('{' + 'username' + '}', encodeURIComponent(String(username))); let queryParameters: any = {}; @@ -330,12 +357,15 @@ export class UserApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body: models.User; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: models.User, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } @@ -346,7 +376,10 @@ 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, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body: string; }> { + public loginUser(username: string, password: string, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body: string; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/user/login'; let queryParameters: any = {}; @@ -399,12 +432,15 @@ export class UserApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body: string; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: string, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } @@ -413,7 +449,10 @@ export class UserApi { * * @summary Logs out current logged in user session */ - public logoutUser(extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public logoutUser(extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/user/logout'; let queryParameters: any = {}; @@ -450,12 +489,15 @@ export class UserApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: any, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } @@ -466,7 +508,10 @@ export class UserApi { * @param username name that need to be deleted * @param body Updated user object */ - public updateUser(username: string, body: models.User, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public updateUser(username: string, body: models.User, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + > { let localVarPath = this.basePath + '/user/{username}'.replace('{' + 'username' + '}', encodeURIComponent(String(username))); let queryParameters: any = {}; @@ -516,12 +561,15 @@ export class UserApi { requestOptions = (Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings); } - let dfd = $.Deferred(); + let dfd = $.Deferred< + { response: JQueryXHR; body?: any; }, + { response: JQueryXHR; errorThrown: string } + >(); $.ajax(requestOptions).then( (data: any, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve(jqXHR, data), + dfd.resolve({response: jqXHR, body: data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject(xhr, errorThrown) + dfd.reject({response: xhr, errorThrown: errorThrown}) ); return dfd.promise(); } diff --git a/samples/client/petstore/typescript-jquery/default/model/Amount.ts b/samples/client/petstore/typescript-jquery/default/model/Amount.ts new file mode 100644 index 000000000000..5916e491d1cb --- /dev/null +++ b/samples/client/petstore/typescript-jquery/default/model/Amount.ts @@ -0,0 +1,26 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import * as models from './models'; + +/** + * some description + */ +export interface Amount { + /** + * some description + */ + value: number; + + currency: models.Currency; + +} diff --git a/samples/client/petstore/typescript-jquery/default/model/Currency.ts b/samples/client/petstore/typescript-jquery/default/model/Currency.ts new file mode 100644 index 000000000000..a5f758cb6c35 --- /dev/null +++ b/samples/client/petstore/typescript-jquery/default/model/Currency.ts @@ -0,0 +1,19 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import * as models from './models'; + +/** + * some description + */ +export interface Currency { +} diff --git a/samples/client/petstore/typescript-jquery/default/model/models.ts b/samples/client/petstore/typescript-jquery/default/model/models.ts index f53c1dd42bdd..840919adceb3 100644 --- a/samples/client/petstore/typescript-jquery/default/model/models.ts +++ b/samples/client/petstore/typescript-jquery/default/model/models.ts @@ -1,5 +1,7 @@ +export * from './Amount'; export * from './ApiResponse'; export * from './Category'; +export * from './Currency'; export * from './Order'; export * from './Pet'; export * from './Tag';