Skip to content

Commit

Permalink
Update petstore sample for typescript-jquery
Browse files Browse the repository at this point in the history
  • Loading branch information
grollinger committed Jul 17, 2018
1 parent 81e23ce commit 3aeebb9
Show file tree
Hide file tree
Showing 6 changed files with 248 additions and 81 deletions.
112 changes: 80 additions & 32 deletions samples/client/petstore/typescript-jquery/default/api/PetApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -107,12 +110,15 @@ export class PetApi {
requestOptions = (<any>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();
}
Expand All @@ -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 = {};
Expand Down Expand Up @@ -176,12 +185,15 @@ export class PetApi {
requestOptions = (<any>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();
}
Expand All @@ -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<models.Pet>; }> {
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise<
{ response: JQueryXHR; body: Array<models.Pet>; },
{ response: JQueryXHR; errorThrown: string }
> {
let localVarPath = this.basePath + '/pet/findByStatus';

let queryParameters: any = {};
Expand Down Expand Up @@ -245,12 +260,15 @@ export class PetApi {
requestOptions = (<any>Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings);
}

let dfd = $.Deferred();
let dfd = $.Deferred<
{ response: JQueryXHR; body: Array<models.Pet>; },
{ response: JQueryXHR; errorThrown: string }
>();
$.ajax(requestOptions).then(
(data: Array<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();
}
Expand All @@ -260,7 +278,10 @@ export class PetApi {
* @summary Finds Pets by tags
* @param tags Tags to filter by
*/
public findPetsByTags(tags: Array<string>, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQueryPromise<{ response: JQueryXHR; body: Array<models.Pet>; }> {
public findPetsByTags(tags: Array<string>, extraJQueryAjaxSettings?: JQueryAjaxSettings): JQuery.Promise<
{ response: JQueryXHR; body: Array<models.Pet>; },
{ response: JQueryXHR; errorThrown: string }
> {
let localVarPath = this.basePath + '/pet/findByTags';

let queryParameters: any = {};
Expand Down Expand Up @@ -314,12 +335,15 @@ export class PetApi {
requestOptions = (<any>Object).assign(requestOptions, this.defaultExtraJQueryAjaxSettings);
}

let dfd = $.Deferred();
let dfd = $.Deferred<
{ response: JQueryXHR; body: Array<models.Pet>; },
{ response: JQueryXHR; errorThrown: string }
>();
$.ajax(requestOptions).then(
(data: Array<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();
}
Expand All @@ -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 = {};
Expand Down Expand Up @@ -376,12 +403,15 @@ export class PetApi {
requestOptions = (<any>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();
}
Expand All @@ -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 = {};
Expand Down Expand Up @@ -447,12 +480,15 @@ export class PetApi {
requestOptions = (<any>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();
}
Expand All @@ -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 = {};
Expand Down Expand Up @@ -533,12 +572,15 @@ export class PetApi {
requestOptions = (<any>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();
}
Expand All @@ -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 = {};
Expand Down Expand Up @@ -617,12 +662,15 @@ export class PetApi {
requestOptions = (<any>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();
}
Expand Down
56 changes: 40 additions & 16 deletions samples/client/petstore/typescript-jquery/default/api/StoreApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -93,12 +96,15 @@ export class StoreApi {
requestOptions = (<any>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();
}
Expand All @@ -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 = {};
Expand Down Expand Up @@ -148,12 +157,15 @@ export class StoreApi {
requestOptions = (<any>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();
}
Expand All @@ -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 = {};
Expand Down Expand Up @@ -205,12 +220,15 @@ export class StoreApi {
requestOptions = (<any>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();
}
Expand All @@ -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 = {};
Expand Down Expand Up @@ -265,12 +286,15 @@ export class StoreApi {
requestOptions = (<any>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();
}
Expand Down
Loading

0 comments on commit 3aeebb9

Please # to comment.