From e5b3e3cdac2bc62eb6346f30ad59e73b6cb2bd7e Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 3 Apr 2017 15:48:51 +0800 Subject: [PATCH] replace tab with 4space for ts jquery client (#5299) --- .../resources/typescript-jquery/api.mustache | 276 +- .../petstore/typescript-jquery/default/api.ts | 2212 ++++++++--------- .../petstore/typescript-jquery/npm/api.ts | 2212 ++++++++--------- .../typescript-jquery/npm/package.json | 2 +- 4 files changed, 2351 insertions(+), 2351 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/typescript-jquery/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-jquery/api.mustache index 8469672d2fe..8d38815f085 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-jquery/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-jquery/api.mustache @@ -11,18 +11,18 @@ let defaultBasePath = '{{{basePath}}}'; {{#models}} {{#model}} {{#description}} - /** - * {{{description}}} - */ + /** + * {{{description}}} + */ {{/description}} export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ {{#vars}} - {{#description}} - /** - * {{{description}}} - */ - {{/description}} - '{{name}}': {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; + {{#description}} + /** + * {{{description}}} + */ + {{/description}} + '{{name}}': {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; {{/vars}} } @@ -30,13 +30,13 @@ export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ export namespace {{classname}} { {{#vars}} {{#isEnum}} - export enum {{enumName}} { - {{#allowableValues}} - {{#enumVars}} - {{name}} = {{{value}}}{{^-last}},{{/-last}} - {{/enumVars}} - {{/allowableValues}} - } + export enum {{enumName}} { + {{#allowableValues}} + {{#enumVars}} + {{name}} = {{{value}}}{{^-last}},{{/-last}} + {{/enumVars}} + {{/allowableValues}} + } {{/isEnum}} {{/vars}} } @@ -45,46 +45,46 @@ export namespace {{classname}} { {{/models}} export interface Authentication { - /** - * Apply authentication settings to header and query params. - */ - applyToRequest(requestOptions: JQueryAjaxSettings): void; + /** + * Apply authentication settings to header and query params. + */ + applyToRequest(requestOptions: JQueryAjaxSettings): void; } export class HttpBasicAuth implements Authentication { - public username: string; - public password: string; - applyToRequest(requestOptions: any): void { - requestOptions.username = this.username; - requestOptions.password = this.password; - } + public username: string; + public password: string; + applyToRequest(requestOptions: any): void { + requestOptions.username = this.username; + requestOptions.password = this.password; + } } export class ApiKeyAuth implements Authentication { - public apiKey: string; + public apiKey: string; - constructor(private location: string, private paramName: string) { - } + constructor(private location: string, private paramName: string) { + } - applyToRequest(requestOptions: JQueryAjaxSettings): void { - requestOptions.headers[this.paramName] = this.apiKey; - } + applyToRequest(requestOptions: JQueryAjaxSettings): void { + requestOptions.headers[this.paramName] = this.apiKey; + } } export class OAuth implements Authentication { - public accessToken: string; + public accessToken: string; - applyToRequest(requestOptions: JQueryAjaxSettings): void { - requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; - } + applyToRequest(requestOptions: JQueryAjaxSettings): void { + requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; + } } export class VoidAuth implements Authentication { - public username: string; - public password: string; - applyToRequest(requestOptions: JQueryAjaxSettings): void { - // Do nothing - } + public username: string; + public password: string; + applyToRequest(requestOptions: JQueryAjaxSettings): void { + // Do nothing + } } {{#apiInfo}} @@ -98,170 +98,170 @@ export class VoidAuth implements Authentication { export enum {{classname}}ApiKeys { {{#authMethods}} {{#isApiKey}} - {{name}}, + {{name}}, {{/isApiKey}} {{/authMethods}} } export class {{classname}} { - protected basePath = defaultBasePath; - protected defaultHeaders : any = {}; + protected basePath = defaultBasePath; + protected defaultHeaders : any = {}; - protected authentications = { - 'default': new VoidAuth(), + protected authentications = { + 'default': new VoidAuth(), {{#authMethods}} {{#isBasic}} - '{{name}}': new HttpBasicAuth(), + '{{name}}': new HttpBasicAuth(), {{/isBasic}} {{#isApiKey}} - '{{name}}': new ApiKeyAuth({{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{^isKeyInHeader}}'query'{{/isKeyInHeader}}, '{{keyParamName}}'), + '{{name}}': new ApiKeyAuth({{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{^isKeyInHeader}}'query'{{/isKeyInHeader}}, '{{keyParamName}}'), {{/isApiKey}} {{#isOAuth}} - '{{name}}': new OAuth(), + '{{name}}': new OAuth(), {{/isOAuth}} {{/authMethods}} - } + } - constructor(basePath?: string); + constructor(basePath?: string); {{#authMethods}} {{#isBasic}} - constructor(username: string, password: string, basePath?: string); + constructor(username: string, password: string, basePath?: string); {{/isBasic}} {{/authMethods}} - constructor(basePathOrUsername: string, password?: string, basePath?: string) { - if (password) { + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { {{#authMethods}} {{#isBasic}} - this.username = basePathOrUsername; - this.password = password + this.username = basePathOrUsername; + this.password = password {{/isBasic}} {{/authMethods}} - if (basePath) { - this.basePath = basePath; - } - } else { - if (basePathOrUsername) { - this.basePath = basePathOrUsername - } - } - } + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } - public setApiKey(key: {{classname}}ApiKeys, value: string) { - this.authentications[{{classname}}ApiKeys[key]].apiKey = value; - } + public setApiKey(key: {{classname}}ApiKeys, value: string) { + this.authentications[{{classname}}ApiKeys[key]].apiKey = value; + } {{#authMethods}} {{#isBasic}} - set username(username: string) { - this.authentications.{{name}}.username = username; - } + set username(username: string) { + this.authentications.{{name}}.username = username; + } - set password(password: string) { - this.authentications.{{name}}.password = password; - } + set password(password: string) { + this.authentications.{{name}}.password = password; + } {{/isBasic}} {{#isOAuth}} - set accessToken(token: string) { - this.authentications.{{name}}.accessToken = token; - } + set accessToken(token: string) { + this.authentications.{{name}}.accessToken = token; + } {{/isOAuth}} {{/authMethods}} - private extendObj(objA: T2, objB: T2): T1|T2 { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - objA[key] = objB[key]; - } - } - return objA; - } + private extendObj(objA: T2, objB: T2): T1|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}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : JQueryPromise<{ response: JQueryXHR; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> { - let localVarPath = this.basePath + '{{{path}}}'{{#pathParams}} - .replace('{' + '{{baseName}}' + '}', String({{paramName}})){{/pathParams}}; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + /** + * {{summary}} + * {{notes}} + {{#allParams}}* @param {{paramName}} {{description}} + {{/allParams}}*/ + public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : JQueryPromise<{ response: JQueryXHR; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> { + let localVarPath = this.basePath + '{{{path}}}'{{#pathParams}} + .replace('{' + '{{baseName}}' + '}', String({{paramName}})){{/pathParams}}; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); {{#allParams}}{{#required}} - // verify required parameter '{{paramName}}' is not null or undefined - if ({{paramName}} === null || {{paramName}} === undefined) { - throw new Error('Required parameter {{paramName}} was null or undefined when calling {{nickname}}.'); - } + // verify required parameter '{{paramName}}' is not null or undefined + if ({{paramName}} === null || {{paramName}} === undefined) { + throw new Error('Required parameter {{paramName}} was null or undefined when calling {{nickname}}.'); + } {{/required}}{{/allParams}} {{#queryParams}} - if ({{paramName}} !== undefined) { - queryParameters['{{baseName}}'] = {{paramName}}; - } + if ({{paramName}} !== undefined) { + queryParameters['{{baseName}}'] = {{paramName}}; + } {{/queryParams}} - localVarPath = localVarPath + "?" + $.param(queryParameters); + localVarPath = localVarPath + "?" + $.param(queryParameters); {{#headerParams}} - headerParams['{{baseName}}'] = {{paramName}}; + headerParams['{{baseName}}'] = {{paramName}}; {{/headerParams}} {{^bodyParam}} - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); {{#formParams}} {{#isFile}} - reqHasFile = true; + reqHasFile = true; {{/isFile}} - if ({{paramName}} !== undefined) { - reqFormData.append('{{baseName}}', {{paramName}}); - reqDict['{{baseName}}'] = {{paramName}}; - } + if ({{paramName}} !== undefined) { + reqFormData.append('{{baseName}}', {{paramName}}); + reqDict['{{baseName}}'] = {{paramName}}; + } {{/formParams}} {{/bodyParam}} {{#bodyParam}} - let reqDict = {{paramName}}; - let reqFormData = new FormData(); - reqFormData.append('{{paramName}}', {{paramName}}); + let reqDict = {{paramName}}; + let reqFormData = new FormData(); + reqFormData.append('{{paramName}}', {{paramName}}); {{#isFile}} - let reqHasFile = true; + let reqHasFile = true; {{/isFile}} {{^isFile}} - let reqHasFile = false; + let reqHasFile = false; {{/isFile}} {{/bodyParam}} - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: '{{httpMethod}}', - headers: headerParams, - processData: false - }; + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: '{{httpMethod}}', + headers: headerParams, + processData: false + }; - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } {{#authMethods}} - this.authentications.{{name}}.applyToRequest(requestOptions); + this.authentications.{{name}}.applyToRequest(requestOptions); {{/authMethods}} - this.authentications.default.applyToRequest(requestOptions); + this.authentications.default.applyToRequest(requestOptions); - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: {{{returnType}}}, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: {{{returnType}}}, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } {{/operation}} } {{/operations}} diff --git a/samples/client/petstore/typescript-jquery/default/api.ts b/samples/client/petstore/typescript-jquery/default/api.ts index 9491259901e..40119f8c73f 100644 --- a/samples/client/petstore/typescript-jquery/default/api.ts +++ b/samples/client/petstore/typescript-jquery/default/api.ts @@ -9,1205 +9,1205 @@ let defaultBasePath = 'http://petstore.swagger.io/v2'; /* tslint:disable:no-unused-variable */ export class Category { - 'id': number; - 'name': string; + 'id': number; + 'name': string; } export class Order { - 'id': number; - 'petId': number; - 'quantity': number; - 'shipDate': Date; - /** - * Order Status - */ - 'status': Order.StatusEnum; - 'complete': boolean; + 'id': number; + 'petId': number; + 'quantity': number; + 'shipDate': Date; + /** + * Order Status + */ + 'status': Order.StatusEnum; + 'complete': boolean; } export namespace Order { - export enum StatusEnum { - Placed = 'placed', - Approved = 'approved', - Delivered = 'delivered' - } + export enum StatusEnum { + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' + } } export class Pet { - 'id': number; - 'category': Category; - 'name': string; - 'photoUrls': Array; - 'tags': Array; - /** - * pet status in the store - */ - 'status': Pet.StatusEnum; + 'id': number; + 'category': Category; + 'name': string; + 'photoUrls': Array; + 'tags': Array; + /** + * pet status in the store + */ + 'status': Pet.StatusEnum; } export namespace Pet { - export enum StatusEnum { - Available = 'available', - Pending = 'pending', - Sold = 'sold' - } + export enum StatusEnum { + Available = 'available', + Pending = 'pending', + Sold = 'sold' + } } export class Tag { - 'id': number; - 'name': string; + 'id': number; + 'name': string; } export class User { - 'id': number; - 'username': string; - 'firstName': string; - 'lastName': string; - 'email': string; - 'password': string; - 'phone': string; - /** - * User Status - */ - 'userStatus': number; + 'id': number; + 'username': string; + 'firstName': string; + 'lastName': string; + 'email': string; + 'password': string; + 'phone': string; + /** + * User Status + */ + 'userStatus': number; } export interface Authentication { - /** - * Apply authentication settings to header and query params. - */ - applyToRequest(requestOptions: JQueryAjaxSettings): void; + /** + * Apply authentication settings to header and query params. + */ + applyToRequest(requestOptions: JQueryAjaxSettings): void; } export class HttpBasicAuth implements Authentication { - public username: string; - public password: string; - applyToRequest(requestOptions: any): void { - requestOptions.username = this.username; - requestOptions.password = this.password; - } + public username: string; + public password: string; + applyToRequest(requestOptions: any): void { + requestOptions.username = this.username; + requestOptions.password = this.password; + } } export class ApiKeyAuth implements Authentication { - public apiKey: string; + public apiKey: string; - constructor(private location: string, private paramName: string) { - } + constructor(private location: string, private paramName: string) { + } - applyToRequest(requestOptions: JQueryAjaxSettings): void { - requestOptions.headers[this.paramName] = this.apiKey; - } + applyToRequest(requestOptions: JQueryAjaxSettings): void { + requestOptions.headers[this.paramName] = this.apiKey; + } } export class OAuth implements Authentication { - public accessToken: string; + public accessToken: string; - applyToRequest(requestOptions: JQueryAjaxSettings): void { - requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; - } + applyToRequest(requestOptions: JQueryAjaxSettings): void { + requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; + } } export class VoidAuth implements Authentication { - public username: string; - public password: string; - applyToRequest(requestOptions: JQueryAjaxSettings): void { - // Do nothing - } + public username: string; + public password: string; + applyToRequest(requestOptions: JQueryAjaxSettings): void { + // Do nothing + } } export enum PetApiApiKeys { - api_key, + api_key, } export class PetApi { - protected basePath = defaultBasePath; - protected defaultHeaders : any = {}; - - protected authentications = { - 'default': new VoidAuth(), - 'api_key': new ApiKeyAuth('header', 'api_key'), - 'petstore_auth': new OAuth(), - } - - constructor(basePath?: string); - constructor(basePathOrUsername: string, password?: string, basePath?: string) { - if (password) { - if (basePath) { - this.basePath = basePath; - } - } else { - if (basePathOrUsername) { - this.basePath = basePathOrUsername - } - } - } - - public setApiKey(key: PetApiApiKeys, value: string) { - this.authentications[PetApiApiKeys[key]].apiKey = value; - } - - set accessToken(token: string) { - this.authentications.petstore_auth.accessToken = token; - } - private extendObj(objA: T2, objB: T2): T1|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) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/pet'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqDict = body; - let reqFormData = new FormData(); - reqFormData.append('body', body); - let reqHasFile = false; - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'POST', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.petstore_auth.applyToRequest(requestOptions); - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Deletes a pet - * - * @param petId Pet id to delete - * @param apiKey - */ - public deletePet (petId: number, apiKey?: string) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/pet/{petId}' - .replace('{' + 'petId' + '}', String(petId)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, 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.'); - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - headerParams['api_key'] = apiKey; - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'DELETE', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.petstore_auth.applyToRequest(requestOptions); - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Finds Pets by status - * 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) : JQueryPromise<{ response: JQueryXHR; body: Array; }> { - let localVarPath = this.basePath + '/pet/findByStatus'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - if (status !== undefined) { - queryParameters['status'] = status; - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'GET', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.petstore_auth.applyToRequest(requestOptions); - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: Array, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Finds Pets by tags - * 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) : JQueryPromise<{ response: JQueryXHR; body: Array; }> { - let localVarPath = this.basePath + '/pet/findByTags'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - if (tags !== undefined) { - queryParameters['tags'] = tags; - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'GET', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.petstore_auth.applyToRequest(requestOptions); - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: Array, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Find pet by ID - * 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) : JQueryPromise<{ response: JQueryXHR; body: Pet; }> { - let localVarPath = this.basePath + '/pet/{petId}' - .replace('{' + 'petId' + '}', String(petId)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, 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.'); - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'GET', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.petstore_auth.applyToRequest(requestOptions); - - this.authentications.api_key.applyToRequest(requestOptions); - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: Pet, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Update an existing pet - * - * @param body Pet object that needs to be added to the store - */ - public updatePet (body?: Pet) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/pet'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqDict = body; - let reqFormData = new FormData(); - reqFormData.append('body', body); - let reqHasFile = false; - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'PUT', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.petstore_auth.applyToRequest(requestOptions); - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Updates a pet in the store with form data - * - * @param petId ID of pet that needs to be updated - * @param name Updated name of the pet - * @param status Updated status of the pet - */ - public updatePetWithForm (petId: string, name?: string, status?: string) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/pet/{petId}' - .replace('{' + 'petId' + '}', String(petId)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, 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 updatePetWithForm.'); - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - if (name !== undefined) { - reqFormData.append('name', name); - reqDict['name'] = name; - } - - if (status !== undefined) { - reqFormData.append('status', status); - reqDict['status'] = status; - } - - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'POST', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.petstore_auth.applyToRequest(requestOptions); - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * uploads an image - * - * @param petId ID of pet to update - * @param additionalMetadata Additional data to pass to server - * @param file file to upload - */ - public uploadFile (petId: number, additionalMetadata?: string, file?: any) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/pet/{petId}/uploadImage' - .replace('{' + 'petId' + '}', String(petId)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, 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 uploadFile.'); - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - if (additionalMetadata !== undefined) { - reqFormData.append('additionalMetadata', additionalMetadata); - reqDict['additionalMetadata'] = additionalMetadata; - } - - reqHasFile = true; - if (file !== undefined) { - reqFormData.append('file', file); - reqDict['file'] = file; - } - - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'POST', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.petstore_auth.applyToRequest(requestOptions); - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } + protected basePath = defaultBasePath; + protected defaultHeaders : any = {}; + + protected authentications = { + 'default': new VoidAuth(), + 'api_key': new ApiKeyAuth('header', 'api_key'), + 'petstore_auth': new OAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + public setApiKey(key: PetApiApiKeys, value: string) { + this.authentications[PetApiApiKeys[key]].apiKey = value; + } + + set accessToken(token: string) { + this.authentications.petstore_auth.accessToken = token; + } + private extendObj(objA: T2, objB: T2): T1|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) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqDict = body; + let reqFormData = new FormData(); + reqFormData.append('body', body); + let reqHasFile = false; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.petstore_auth.applyToRequest(requestOptions); + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Deletes a pet + * + * @param petId Pet id to delete + * @param apiKey + */ + public deletePet (petId: number, apiKey?: string) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet/{petId}' + .replace('{' + 'petId' + '}', String(petId)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + headerParams['api_key'] = apiKey; + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'DELETE', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.petstore_auth.applyToRequest(requestOptions); + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Finds Pets by status + * 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) : JQueryPromise<{ response: JQueryXHR; body: Array; }> { + let localVarPath = this.basePath + '/pet/findByStatus'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + if (status !== undefined) { + queryParameters['status'] = status; + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.petstore_auth.applyToRequest(requestOptions); + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: Array, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Finds Pets by tags + * 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) : JQueryPromise<{ response: JQueryXHR; body: Array; }> { + let localVarPath = this.basePath + '/pet/findByTags'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + if (tags !== undefined) { + queryParameters['tags'] = tags; + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.petstore_auth.applyToRequest(requestOptions); + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: Array, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Find pet by ID + * 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) : JQueryPromise<{ response: JQueryXHR; body: Pet; }> { + let localVarPath = this.basePath + '/pet/{petId}' + .replace('{' + 'petId' + '}', String(petId)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.petstore_auth.applyToRequest(requestOptions); + + this.authentications.api_key.applyToRequest(requestOptions); + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: Pet, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Update an existing pet + * + * @param body Pet object that needs to be added to the store + */ + public updatePet (body?: Pet) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqDict = body; + let reqFormData = new FormData(); + reqFormData.append('body', body); + let reqHasFile = false; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'PUT', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.petstore_auth.applyToRequest(requestOptions); + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated + * @param name Updated name of the pet + * @param status Updated status of the pet + */ + public updatePetWithForm (petId: string, name?: string, status?: string) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet/{petId}' + .replace('{' + 'petId' + '}', String(petId)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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 updatePetWithForm.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + if (name !== undefined) { + reqFormData.append('name', name); + reqDict['name'] = name; + } + + if (status !== undefined) { + reqFormData.append('status', status); + reqDict['status'] = status; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.petstore_auth.applyToRequest(requestOptions); + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * uploads an image + * + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ + public uploadFile (petId: number, additionalMetadata?: string, file?: any) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet/{petId}/uploadImage' + .replace('{' + 'petId' + '}', String(petId)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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 uploadFile.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + if (additionalMetadata !== undefined) { + reqFormData.append('additionalMetadata', additionalMetadata); + reqDict['additionalMetadata'] = additionalMetadata; + } + + reqHasFile = true; + if (file !== undefined) { + reqFormData.append('file', file); + reqDict['file'] = file; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.petstore_auth.applyToRequest(requestOptions); + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } } export enum StoreApiApiKeys { - api_key, + api_key, } export class StoreApi { - protected basePath = defaultBasePath; - protected defaultHeaders : any = {}; + protected basePath = defaultBasePath; + protected defaultHeaders : any = {}; - protected authentications = { - 'default': new VoidAuth(), - 'api_key': new ApiKeyAuth('header', 'api_key'), - 'petstore_auth': new OAuth(), - } + protected authentications = { + 'default': new VoidAuth(), + 'api_key': new ApiKeyAuth('header', 'api_key'), + 'petstore_auth': new OAuth(), + } - constructor(basePath?: string); - constructor(basePathOrUsername: string, password?: string, basePath?: string) { - if (password) { - if (basePath) { - this.basePath = basePath; - } - } else { - if (basePathOrUsername) { - this.basePath = basePathOrUsername - } - } - } + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } - public setApiKey(key: StoreApiApiKeys, value: string) { - this.authentications[StoreApiApiKeys[key]].apiKey = value; - } + public setApiKey(key: StoreApiApiKeys, value: string) { + this.authentications[StoreApiApiKeys[key]].apiKey = value; + } - set accessToken(token: string) { - this.authentications.petstore_auth.accessToken = token; - } - private extendObj(objA: T2, objB: T2): T1|T2 { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - objA[key] = objB[key]; - } - } - return objA; - } + set accessToken(token: string) { + this.authentications.petstore_auth.accessToken = token; + } + private extendObj(objA: T2, objB: T2): T1|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) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/store/order/{orderId}' - .replace('{' + 'orderId' + '}', String(orderId)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + /** + * 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) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', String(orderId)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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.'); - } + // 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.'); + } - localVarPath = localVarPath + "?" + $.param(queryParameters); + localVarPath = localVarPath + "?" + $.param(queryParameters); - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'DELETE', - headers: headerParams, - processData: false - }; + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'DELETE', + headers: headerParams, + processData: false + }; - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } - this.authentications.default.applyToRequest(requestOptions); + this.authentications.default.applyToRequest(requestOptions); - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Returns pet inventories by status - * Returns a map of status codes to quantities - */ - public getInventory () : JQueryPromise<{ response: JQueryXHR; body: { [key: string]: number; }; }> { - let localVarPath = this.basePath + '/store/inventory'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + */ + public getInventory () : JQueryPromise<{ response: JQueryXHR; body: { [key: string]: number; }; }> { + let localVarPath = this.basePath + '/store/inventory'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); - localVarPath = localVarPath + "?" + $.param(queryParameters); + localVarPath = localVarPath + "?" + $.param(queryParameters); - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'GET', - headers: headerParams, - processData: false - }; + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } - this.authentications.api_key.applyToRequest(requestOptions); + this.authentications.api_key.applyToRequest(requestOptions); - this.authentications.default.applyToRequest(requestOptions); + this.authentications.default.applyToRequest(requestOptions); - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: { [key: string]: number; }, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Find purchase order by ID - * 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) : JQueryPromise<{ response: JQueryXHR; body: Order; }> { - let localVarPath = this.basePath + '/store/order/{orderId}' - .replace('{' + 'orderId' + '}', String(orderId)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: { [key: string]: number; }, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Find purchase order by ID + * 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) : JQueryPromise<{ response: JQueryXHR; body: Order; }> { + let localVarPath = this.basePath + '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', String(orderId)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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.'); - } + // 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.'); + } - localVarPath = localVarPath + "?" + $.param(queryParameters); + localVarPath = localVarPath + "?" + $.param(queryParameters); - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'GET', - headers: headerParams, - processData: false - }; + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } - this.authentications.default.applyToRequest(requestOptions); + this.authentications.default.applyToRequest(requestOptions); - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: Order, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Place an order for a pet - * - * @param body order placed for purchasing the pet - */ - public placeOrder (body?: Order) : JQueryPromise<{ response: JQueryXHR; body: Order; }> { - let localVarPath = this.basePath + '/store/order'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: Order, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Place an order for a pet + * + * @param body order placed for purchasing the pet + */ + public placeOrder (body?: Order) : JQueryPromise<{ response: JQueryXHR; body: Order; }> { + let localVarPath = this.basePath + '/store/order'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); - localVarPath = localVarPath + "?" + $.param(queryParameters); + localVarPath = localVarPath + "?" + $.param(queryParameters); - let reqDict = body; - let reqFormData = new FormData(); - reqFormData.append('body', body); - let reqHasFile = false; + let reqDict = body; + let reqFormData = new FormData(); + reqFormData.append('body', body); + let reqHasFile = false; - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'POST', - headers: headerParams, - processData: false - }; + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } - this.authentications.default.applyToRequest(requestOptions); + this.authentications.default.applyToRequest(requestOptions); - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: Order, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: Order, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } } export enum UserApiApiKeys { - api_key, + api_key, } export class UserApi { - protected basePath = defaultBasePath; - protected defaultHeaders : any = {}; - - protected authentications = { - 'default': new VoidAuth(), - 'api_key': new ApiKeyAuth('header', 'api_key'), - 'petstore_auth': new OAuth(), - } - - constructor(basePath?: string); - constructor(basePathOrUsername: string, password?: string, basePath?: string) { - if (password) { - if (basePath) { - this.basePath = basePath; - } - } else { - if (basePathOrUsername) { - this.basePath = basePathOrUsername - } - } - } - - public setApiKey(key: UserApiApiKeys, value: string) { - this.authentications[UserApiApiKeys[key]].apiKey = value; - } - - set accessToken(token: string) { - this.authentications.petstore_auth.accessToken = token; - } - private extendObj(objA: T2, objB: T2): T1|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) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/user'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqDict = body; - let reqFormData = new FormData(); - reqFormData.append('body', body); - let reqHasFile = false; - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'POST', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Creates list of users with given input array - * - * @param body List of user object - */ - public createUsersWithArrayInput (body?: Array) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/user/createWithArray'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqDict = body; - let reqFormData = new FormData(); - reqFormData.append('body', body); - let reqHasFile = false; - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'POST', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Creates list of users with given input array - * - * @param body List of user object - */ - public createUsersWithListInput (body?: Array) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/user/createWithList'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqDict = body; - let reqFormData = new FormData(); - reqFormData.append('body', body); - let reqHasFile = false; - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'POST', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Delete user - * This can only be done by the logged in user. - * @param username The name that needs to be deleted - */ - public deleteUser (username: string) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/user/{username}' - .replace('{' + 'username' + '}', String(username)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, 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.'); - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'DELETE', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Get user by user name - * - * @param username The name that needs to be fetched. Use user1 for testing. - */ - public getUserByName (username: string) : JQueryPromise<{ response: JQueryXHR; body: User; }> { - let localVarPath = this.basePath + '/user/{username}' - .replace('{' + 'username' + '}', String(username)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, 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.'); - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'GET', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: User, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Logs user into the system - * - * @param username The user name for login - * @param password The password for login in clear text - */ - public loginUser (username?: string, password?: string) : JQueryPromise<{ response: JQueryXHR; body: string; }> { - let localVarPath = this.basePath + '/user/login'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - if (username !== undefined) { - queryParameters['username'] = username; - } - - if (password !== undefined) { - queryParameters['password'] = password; - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'GET', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: string, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Logs out current logged in user session - * - */ - public logoutUser () : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/user/logout'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'GET', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Updated user - * This can only be done by the logged in user. - * @param username name that need to be deleted - * @param body Updated user object - */ - public updateUser (username: string, body?: User) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/user/{username}' - .replace('{' + 'username' + '}', String(username)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, 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.'); - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqDict = body; - let reqFormData = new FormData(); - reqFormData.append('body', body); - let reqHasFile = false; - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'PUT', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } + protected basePath = defaultBasePath; + protected defaultHeaders : any = {}; + + protected authentications = { + 'default': new VoidAuth(), + 'api_key': new ApiKeyAuth('header', 'api_key'), + 'petstore_auth': new OAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + public setApiKey(key: UserApiApiKeys, value: string) { + this.authentications[UserApiApiKeys[key]].apiKey = value; + } + + set accessToken(token: string) { + this.authentications.petstore_auth.accessToken = token; + } + private extendObj(objA: T2, objB: T2): T1|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) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqDict = body; + let reqFormData = new FormData(); + reqFormData.append('body', body); + let reqHasFile = false; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Creates list of users with given input array + * + * @param body List of user object + */ + public createUsersWithArrayInput (body?: Array) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/createWithArray'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqDict = body; + let reqFormData = new FormData(); + reqFormData.append('body', body); + let reqHasFile = false; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Creates list of users with given input array + * + * @param body List of user object + */ + public createUsersWithListInput (body?: Array) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/createWithList'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqDict = body; + let reqFormData = new FormData(); + reqFormData.append('body', body); + let reqHasFile = false; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted + */ + public deleteUser (username: string) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/{username}' + .replace('{' + 'username' + '}', String(username)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'DELETE', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. + */ + public getUserByName (username: string) : JQueryPromise<{ response: JQueryXHR; body: User; }> { + let localVarPath = this.basePath + '/user/{username}' + .replace('{' + 'username' + '}', String(username)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: User, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Logs user into the system + * + * @param username The user name for login + * @param password The password for login in clear text + */ + public loginUser (username?: string, password?: string) : JQueryPromise<{ response: JQueryXHR; body: string; }> { + let localVarPath = this.basePath + '/user/login'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + if (username !== undefined) { + queryParameters['username'] = username; + } + + if (password !== undefined) { + queryParameters['password'] = password; + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: string, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Logs out current logged in user session + * + */ + public logoutUser () : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/logout'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted + * @param body Updated user object + */ + public updateUser (username: string, body?: User) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/{username}' + .replace('{' + 'username' + '}', String(username)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqDict = body; + let reqFormData = new FormData(); + reqFormData.append('body', body); + let reqHasFile = false; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'PUT', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } } diff --git a/samples/client/petstore/typescript-jquery/npm/api.ts b/samples/client/petstore/typescript-jquery/npm/api.ts index 9491259901e..40119f8c73f 100644 --- a/samples/client/petstore/typescript-jquery/npm/api.ts +++ b/samples/client/petstore/typescript-jquery/npm/api.ts @@ -9,1205 +9,1205 @@ let defaultBasePath = 'http://petstore.swagger.io/v2'; /* tslint:disable:no-unused-variable */ export class Category { - 'id': number; - 'name': string; + 'id': number; + 'name': string; } export class Order { - 'id': number; - 'petId': number; - 'quantity': number; - 'shipDate': Date; - /** - * Order Status - */ - 'status': Order.StatusEnum; - 'complete': boolean; + 'id': number; + 'petId': number; + 'quantity': number; + 'shipDate': Date; + /** + * Order Status + */ + 'status': Order.StatusEnum; + 'complete': boolean; } export namespace Order { - export enum StatusEnum { - Placed = 'placed', - Approved = 'approved', - Delivered = 'delivered' - } + export enum StatusEnum { + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' + } } export class Pet { - 'id': number; - 'category': Category; - 'name': string; - 'photoUrls': Array; - 'tags': Array; - /** - * pet status in the store - */ - 'status': Pet.StatusEnum; + 'id': number; + 'category': Category; + 'name': string; + 'photoUrls': Array; + 'tags': Array; + /** + * pet status in the store + */ + 'status': Pet.StatusEnum; } export namespace Pet { - export enum StatusEnum { - Available = 'available', - Pending = 'pending', - Sold = 'sold' - } + export enum StatusEnum { + Available = 'available', + Pending = 'pending', + Sold = 'sold' + } } export class Tag { - 'id': number; - 'name': string; + 'id': number; + 'name': string; } export class User { - 'id': number; - 'username': string; - 'firstName': string; - 'lastName': string; - 'email': string; - 'password': string; - 'phone': string; - /** - * User Status - */ - 'userStatus': number; + 'id': number; + 'username': string; + 'firstName': string; + 'lastName': string; + 'email': string; + 'password': string; + 'phone': string; + /** + * User Status + */ + 'userStatus': number; } export interface Authentication { - /** - * Apply authentication settings to header and query params. - */ - applyToRequest(requestOptions: JQueryAjaxSettings): void; + /** + * Apply authentication settings to header and query params. + */ + applyToRequest(requestOptions: JQueryAjaxSettings): void; } export class HttpBasicAuth implements Authentication { - public username: string; - public password: string; - applyToRequest(requestOptions: any): void { - requestOptions.username = this.username; - requestOptions.password = this.password; - } + public username: string; + public password: string; + applyToRequest(requestOptions: any): void { + requestOptions.username = this.username; + requestOptions.password = this.password; + } } export class ApiKeyAuth implements Authentication { - public apiKey: string; + public apiKey: string; - constructor(private location: string, private paramName: string) { - } + constructor(private location: string, private paramName: string) { + } - applyToRequest(requestOptions: JQueryAjaxSettings): void { - requestOptions.headers[this.paramName] = this.apiKey; - } + applyToRequest(requestOptions: JQueryAjaxSettings): void { + requestOptions.headers[this.paramName] = this.apiKey; + } } export class OAuth implements Authentication { - public accessToken: string; + public accessToken: string; - applyToRequest(requestOptions: JQueryAjaxSettings): void { - requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; - } + applyToRequest(requestOptions: JQueryAjaxSettings): void { + requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; + } } export class VoidAuth implements Authentication { - public username: string; - public password: string; - applyToRequest(requestOptions: JQueryAjaxSettings): void { - // Do nothing - } + public username: string; + public password: string; + applyToRequest(requestOptions: JQueryAjaxSettings): void { + // Do nothing + } } export enum PetApiApiKeys { - api_key, + api_key, } export class PetApi { - protected basePath = defaultBasePath; - protected defaultHeaders : any = {}; - - protected authentications = { - 'default': new VoidAuth(), - 'api_key': new ApiKeyAuth('header', 'api_key'), - 'petstore_auth': new OAuth(), - } - - constructor(basePath?: string); - constructor(basePathOrUsername: string, password?: string, basePath?: string) { - if (password) { - if (basePath) { - this.basePath = basePath; - } - } else { - if (basePathOrUsername) { - this.basePath = basePathOrUsername - } - } - } - - public setApiKey(key: PetApiApiKeys, value: string) { - this.authentications[PetApiApiKeys[key]].apiKey = value; - } - - set accessToken(token: string) { - this.authentications.petstore_auth.accessToken = token; - } - private extendObj(objA: T2, objB: T2): T1|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) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/pet'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqDict = body; - let reqFormData = new FormData(); - reqFormData.append('body', body); - let reqHasFile = false; - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'POST', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.petstore_auth.applyToRequest(requestOptions); - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Deletes a pet - * - * @param petId Pet id to delete - * @param apiKey - */ - public deletePet (petId: number, apiKey?: string) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/pet/{petId}' - .replace('{' + 'petId' + '}', String(petId)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, 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.'); - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - headerParams['api_key'] = apiKey; - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'DELETE', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.petstore_auth.applyToRequest(requestOptions); - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Finds Pets by status - * 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) : JQueryPromise<{ response: JQueryXHR; body: Array; }> { - let localVarPath = this.basePath + '/pet/findByStatus'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - if (status !== undefined) { - queryParameters['status'] = status; - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'GET', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.petstore_auth.applyToRequest(requestOptions); - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: Array, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Finds Pets by tags - * 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) : JQueryPromise<{ response: JQueryXHR; body: Array; }> { - let localVarPath = this.basePath + '/pet/findByTags'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - if (tags !== undefined) { - queryParameters['tags'] = tags; - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'GET', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.petstore_auth.applyToRequest(requestOptions); - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: Array, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Find pet by ID - * 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) : JQueryPromise<{ response: JQueryXHR; body: Pet; }> { - let localVarPath = this.basePath + '/pet/{petId}' - .replace('{' + 'petId' + '}', String(petId)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, 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.'); - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'GET', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.petstore_auth.applyToRequest(requestOptions); - - this.authentications.api_key.applyToRequest(requestOptions); - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: Pet, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Update an existing pet - * - * @param body Pet object that needs to be added to the store - */ - public updatePet (body?: Pet) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/pet'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqDict = body; - let reqFormData = new FormData(); - reqFormData.append('body', body); - let reqHasFile = false; - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'PUT', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.petstore_auth.applyToRequest(requestOptions); - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Updates a pet in the store with form data - * - * @param petId ID of pet that needs to be updated - * @param name Updated name of the pet - * @param status Updated status of the pet - */ - public updatePetWithForm (petId: string, name?: string, status?: string) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/pet/{petId}' - .replace('{' + 'petId' + '}', String(petId)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, 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 updatePetWithForm.'); - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - if (name !== undefined) { - reqFormData.append('name', name); - reqDict['name'] = name; - } - - if (status !== undefined) { - reqFormData.append('status', status); - reqDict['status'] = status; - } - - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'POST', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.petstore_auth.applyToRequest(requestOptions); - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * uploads an image - * - * @param petId ID of pet to update - * @param additionalMetadata Additional data to pass to server - * @param file file to upload - */ - public uploadFile (petId: number, additionalMetadata?: string, file?: any) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/pet/{petId}/uploadImage' - .replace('{' + 'petId' + '}', String(petId)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, 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 uploadFile.'); - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - if (additionalMetadata !== undefined) { - reqFormData.append('additionalMetadata', additionalMetadata); - reqDict['additionalMetadata'] = additionalMetadata; - } - - reqHasFile = true; - if (file !== undefined) { - reqFormData.append('file', file); - reqDict['file'] = file; - } - - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'POST', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.petstore_auth.applyToRequest(requestOptions); - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } + protected basePath = defaultBasePath; + protected defaultHeaders : any = {}; + + protected authentications = { + 'default': new VoidAuth(), + 'api_key': new ApiKeyAuth('header', 'api_key'), + 'petstore_auth': new OAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + public setApiKey(key: PetApiApiKeys, value: string) { + this.authentications[PetApiApiKeys[key]].apiKey = value; + } + + set accessToken(token: string) { + this.authentications.petstore_auth.accessToken = token; + } + private extendObj(objA: T2, objB: T2): T1|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) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqDict = body; + let reqFormData = new FormData(); + reqFormData.append('body', body); + let reqHasFile = false; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.petstore_auth.applyToRequest(requestOptions); + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Deletes a pet + * + * @param petId Pet id to delete + * @param apiKey + */ + public deletePet (petId: number, apiKey?: string) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet/{petId}' + .replace('{' + 'petId' + '}', String(petId)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + headerParams['api_key'] = apiKey; + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'DELETE', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.petstore_auth.applyToRequest(requestOptions); + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Finds Pets by status + * 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) : JQueryPromise<{ response: JQueryXHR; body: Array; }> { + let localVarPath = this.basePath + '/pet/findByStatus'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + if (status !== undefined) { + queryParameters['status'] = status; + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.petstore_auth.applyToRequest(requestOptions); + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: Array, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Finds Pets by tags + * 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) : JQueryPromise<{ response: JQueryXHR; body: Array; }> { + let localVarPath = this.basePath + '/pet/findByTags'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + if (tags !== undefined) { + queryParameters['tags'] = tags; + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.petstore_auth.applyToRequest(requestOptions); + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: Array, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Find pet by ID + * 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) : JQueryPromise<{ response: JQueryXHR; body: Pet; }> { + let localVarPath = this.basePath + '/pet/{petId}' + .replace('{' + 'petId' + '}', String(petId)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.petstore_auth.applyToRequest(requestOptions); + + this.authentications.api_key.applyToRequest(requestOptions); + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: Pet, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Update an existing pet + * + * @param body Pet object that needs to be added to the store + */ + public updatePet (body?: Pet) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqDict = body; + let reqFormData = new FormData(); + reqFormData.append('body', body); + let reqHasFile = false; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'PUT', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.petstore_auth.applyToRequest(requestOptions); + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated + * @param name Updated name of the pet + * @param status Updated status of the pet + */ + public updatePetWithForm (petId: string, name?: string, status?: string) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet/{petId}' + .replace('{' + 'petId' + '}', String(petId)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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 updatePetWithForm.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + if (name !== undefined) { + reqFormData.append('name', name); + reqDict['name'] = name; + } + + if (status !== undefined) { + reqFormData.append('status', status); + reqDict['status'] = status; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.petstore_auth.applyToRequest(requestOptions); + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * uploads an image + * + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ + public uploadFile (petId: number, additionalMetadata?: string, file?: any) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/pet/{petId}/uploadImage' + .replace('{' + 'petId' + '}', String(petId)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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 uploadFile.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + if (additionalMetadata !== undefined) { + reqFormData.append('additionalMetadata', additionalMetadata); + reqDict['additionalMetadata'] = additionalMetadata; + } + + reqHasFile = true; + if (file !== undefined) { + reqFormData.append('file', file); + reqDict['file'] = file; + } + + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.petstore_auth.applyToRequest(requestOptions); + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } } export enum StoreApiApiKeys { - api_key, + api_key, } export class StoreApi { - protected basePath = defaultBasePath; - protected defaultHeaders : any = {}; + protected basePath = defaultBasePath; + protected defaultHeaders : any = {}; - protected authentications = { - 'default': new VoidAuth(), - 'api_key': new ApiKeyAuth('header', 'api_key'), - 'petstore_auth': new OAuth(), - } + protected authentications = { + 'default': new VoidAuth(), + 'api_key': new ApiKeyAuth('header', 'api_key'), + 'petstore_auth': new OAuth(), + } - constructor(basePath?: string); - constructor(basePathOrUsername: string, password?: string, basePath?: string) { - if (password) { - if (basePath) { - this.basePath = basePath; - } - } else { - if (basePathOrUsername) { - this.basePath = basePathOrUsername - } - } - } + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } - public setApiKey(key: StoreApiApiKeys, value: string) { - this.authentications[StoreApiApiKeys[key]].apiKey = value; - } + public setApiKey(key: StoreApiApiKeys, value: string) { + this.authentications[StoreApiApiKeys[key]].apiKey = value; + } - set accessToken(token: string) { - this.authentications.petstore_auth.accessToken = token; - } - private extendObj(objA: T2, objB: T2): T1|T2 { - for(let key in objB){ - if(objB.hasOwnProperty(key)){ - objA[key] = objB[key]; - } - } - return objA; - } + set accessToken(token: string) { + this.authentications.petstore_auth.accessToken = token; + } + private extendObj(objA: T2, objB: T2): T1|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) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/store/order/{orderId}' - .replace('{' + 'orderId' + '}', String(orderId)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + /** + * 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) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', String(orderId)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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.'); - } + // 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.'); + } - localVarPath = localVarPath + "?" + $.param(queryParameters); + localVarPath = localVarPath + "?" + $.param(queryParameters); - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'DELETE', - headers: headerParams, - processData: false - }; + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'DELETE', + headers: headerParams, + processData: false + }; - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } - this.authentications.default.applyToRequest(requestOptions); + this.authentications.default.applyToRequest(requestOptions); - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Returns pet inventories by status - * Returns a map of status codes to quantities - */ - public getInventory () : JQueryPromise<{ response: JQueryXHR; body: { [key: string]: number; }; }> { - let localVarPath = this.basePath + '/store/inventory'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + */ + public getInventory () : JQueryPromise<{ response: JQueryXHR; body: { [key: string]: number; }; }> { + let localVarPath = this.basePath + '/store/inventory'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); - localVarPath = localVarPath + "?" + $.param(queryParameters); + localVarPath = localVarPath + "?" + $.param(queryParameters); - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'GET', - headers: headerParams, - processData: false - }; + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } - this.authentications.api_key.applyToRequest(requestOptions); + this.authentications.api_key.applyToRequest(requestOptions); - this.authentications.default.applyToRequest(requestOptions); + this.authentications.default.applyToRequest(requestOptions); - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: { [key: string]: number; }, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Find purchase order by ID - * 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) : JQueryPromise<{ response: JQueryXHR; body: Order; }> { - let localVarPath = this.basePath + '/store/order/{orderId}' - .replace('{' + 'orderId' + '}', String(orderId)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: { [key: string]: number; }, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Find purchase order by ID + * 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) : JQueryPromise<{ response: JQueryXHR; body: Order; }> { + let localVarPath = this.basePath + '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', String(orderId)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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.'); - } + // 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.'); + } - localVarPath = localVarPath + "?" + $.param(queryParameters); + localVarPath = localVarPath + "?" + $.param(queryParameters); - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'GET', - headers: headerParams, - processData: false - }; + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } - this.authentications.default.applyToRequest(requestOptions); + this.authentications.default.applyToRequest(requestOptions); - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: Order, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Place an order for a pet - * - * @param body order placed for purchasing the pet - */ - public placeOrder (body?: Order) : JQueryPromise<{ response: JQueryXHR; body: Order; }> { - let localVarPath = this.basePath + '/store/order'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: Order, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Place an order for a pet + * + * @param body order placed for purchasing the pet + */ + public placeOrder (body?: Order) : JQueryPromise<{ response: JQueryXHR; body: Order; }> { + let localVarPath = this.basePath + '/store/order'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); - localVarPath = localVarPath + "?" + $.param(queryParameters); + localVarPath = localVarPath + "?" + $.param(queryParameters); - let reqDict = body; - let reqFormData = new FormData(); - reqFormData.append('body', body); - let reqHasFile = false; + let reqDict = body; + let reqFormData = new FormData(); + reqFormData.append('body', body); + let reqHasFile = false; - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'POST', - headers: headerParams, - processData: false - }; + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } - this.authentications.default.applyToRequest(requestOptions); + this.authentications.default.applyToRequest(requestOptions); - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: Order, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: Order, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } } export enum UserApiApiKeys { - api_key, + api_key, } export class UserApi { - protected basePath = defaultBasePath; - protected defaultHeaders : any = {}; - - protected authentications = { - 'default': new VoidAuth(), - 'api_key': new ApiKeyAuth('header', 'api_key'), - 'petstore_auth': new OAuth(), - } - - constructor(basePath?: string); - constructor(basePathOrUsername: string, password?: string, basePath?: string) { - if (password) { - if (basePath) { - this.basePath = basePath; - } - } else { - if (basePathOrUsername) { - this.basePath = basePathOrUsername - } - } - } - - public setApiKey(key: UserApiApiKeys, value: string) { - this.authentications[UserApiApiKeys[key]].apiKey = value; - } - - set accessToken(token: string) { - this.authentications.petstore_auth.accessToken = token; - } - private extendObj(objA: T2, objB: T2): T1|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) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/user'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqDict = body; - let reqFormData = new FormData(); - reqFormData.append('body', body); - let reqHasFile = false; - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'POST', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Creates list of users with given input array - * - * @param body List of user object - */ - public createUsersWithArrayInput (body?: Array) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/user/createWithArray'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqDict = body; - let reqFormData = new FormData(); - reqFormData.append('body', body); - let reqHasFile = false; - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'POST', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Creates list of users with given input array - * - * @param body List of user object - */ - public createUsersWithListInput (body?: Array) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/user/createWithList'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqDict = body; - let reqFormData = new FormData(); - reqFormData.append('body', body); - let reqHasFile = false; - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'POST', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Delete user - * This can only be done by the logged in user. - * @param username The name that needs to be deleted - */ - public deleteUser (username: string) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/user/{username}' - .replace('{' + 'username' + '}', String(username)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, 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.'); - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'DELETE', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Get user by user name - * - * @param username The name that needs to be fetched. Use user1 for testing. - */ - public getUserByName (username: string) : JQueryPromise<{ response: JQueryXHR; body: User; }> { - let localVarPath = this.basePath + '/user/{username}' - .replace('{' + 'username' + '}', String(username)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, 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.'); - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'GET', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: User, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Logs user into the system - * - * @param username The user name for login - * @param password The password for login in clear text - */ - public loginUser (username?: string, password?: string) : JQueryPromise<{ response: JQueryXHR; body: string; }> { - let localVarPath = this.basePath + '/user/login'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - if (username !== undefined) { - queryParameters['username'] = username; - } - - if (password !== undefined) { - queryParameters['password'] = password; - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'GET', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: string, textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Logs out current logged in user session - * - */ - public logoutUser () : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/user/logout'; - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, this.defaultHeaders); - - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqHasFile = false; - let reqDict = {}; - let reqFormData = new FormData(); - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'GET', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } - /** - * Updated user - * This can only be done by the logged in user. - * @param username name that need to be deleted - * @param body Updated user object - */ - public updateUser (username: string, body?: User) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { - let localVarPath = this.basePath + '/user/{username}' - .replace('{' + 'username' + '}', String(username)); - let queryParameters: any = {}; - let headerParams: any = this.extendObj({}, 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.'); - } - - - localVarPath = localVarPath + "?" + $.param(queryParameters); - - - let reqDict = body; - let reqFormData = new FormData(); - reqFormData.append('body', body); - let reqHasFile = false; - - let requestOptions: JQueryAjaxSettings = { - url: localVarPath, - type: 'PUT', - headers: headerParams, - processData: false - }; - - if (Object.keys(reqDict).length) { - requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); - requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; - } - - this.authentications.default.applyToRequest(requestOptions); - - let dfd = $.Deferred(); - $.ajax(requestOptions).then( - (data: , textStatus: string, jqXHR: JQueryXHR) => - dfd.resolve({ response: jqXHR, body: data }), - (xhr: JQueryXHR, textStatus: string, errorThrown: string) => - dfd.reject({ response: xhr, body: errorThrown }) - ); - return dfd.promise(); - } + protected basePath = defaultBasePath; + protected defaultHeaders : any = {}; + + protected authentications = { + 'default': new VoidAuth(), + 'api_key': new ApiKeyAuth('header', 'api_key'), + 'petstore_auth': new OAuth(), + } + + constructor(basePath?: string); + constructor(basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + public setApiKey(key: UserApiApiKeys, value: string) { + this.authentications[UserApiApiKeys[key]].apiKey = value; + } + + set accessToken(token: string) { + this.authentications.petstore_auth.accessToken = token; + } + private extendObj(objA: T2, objB: T2): T1|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) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqDict = body; + let reqFormData = new FormData(); + reqFormData.append('body', body); + let reqHasFile = false; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Creates list of users with given input array + * + * @param body List of user object + */ + public createUsersWithArrayInput (body?: Array) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/createWithArray'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqDict = body; + let reqFormData = new FormData(); + reqFormData.append('body', body); + let reqHasFile = false; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Creates list of users with given input array + * + * @param body List of user object + */ + public createUsersWithListInput (body?: Array) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/createWithList'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqDict = body; + let reqFormData = new FormData(); + reqFormData.append('body', body); + let reqHasFile = false; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'POST', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted + */ + public deleteUser (username: string) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/{username}' + .replace('{' + 'username' + '}', String(username)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'DELETE', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. + */ + public getUserByName (username: string) : JQueryPromise<{ response: JQueryXHR; body: User; }> { + let localVarPath = this.basePath + '/user/{username}' + .replace('{' + 'username' + '}', String(username)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: User, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Logs user into the system + * + * @param username The user name for login + * @param password The password for login in clear text + */ + public loginUser (username?: string, password?: string) : JQueryPromise<{ response: JQueryXHR; body: string; }> { + let localVarPath = this.basePath + '/user/login'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + if (username !== undefined) { + queryParameters['username'] = username; + } + + if (password !== undefined) { + queryParameters['password'] = password; + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: string, textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Logs out current logged in user session + * + */ + public logoutUser () : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/logout'; + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, this.defaultHeaders); + + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqHasFile = false; + let reqDict = {}; + let reqFormData = new FormData(); + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'GET', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted + * @param body Updated user object + */ + public updateUser (username: string, body?: User) : JQueryPromise<{ response: JQueryXHR; body?: any; }> { + let localVarPath = this.basePath + '/user/{username}' + .replace('{' + 'username' + '}', String(username)); + let queryParameters: any = {}; + let headerParams: any = this.extendObj({}, 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.'); + } + + + localVarPath = localVarPath + "?" + $.param(queryParameters); + + + let reqDict = body; + let reqFormData = new FormData(); + reqFormData.append('body', body); + let reqHasFile = false; + + let requestOptions: JQueryAjaxSettings = { + url: localVarPath, + type: 'PUT', + headers: headerParams, + processData: false + }; + + if (Object.keys(reqDict).length) { + requestOptions.data = reqHasFile ? reqFormData : JSON.stringify(reqDict); + requestOptions.contentType = reqHasFile ? false : 'application/json; charset=utf-8'; + } + + this.authentications.default.applyToRequest(requestOptions); + + let dfd = $.Deferred(); + $.ajax(requestOptions).then( + (data: , textStatus: string, jqXHR: JQueryXHR) => + dfd.resolve({ response: jqXHR, body: data }), + (xhr: JQueryXHR, textStatus: string, errorThrown: string) => + dfd.reject({ response: xhr, body: errorThrown }) + ); + return dfd.promise(); + } } diff --git a/samples/client/petstore/typescript-jquery/npm/package.json b/samples/client/petstore/typescript-jquery/npm/package.json index 89b35a0787a..3aa86e60fc4 100644 --- a/samples/client/petstore/typescript-jquery/npm/package.json +++ b/samples/client/petstore/typescript-jquery/npm/package.json @@ -1,6 +1,6 @@ { "name": "@swagger/angular2-typescript-petstore", - "version": "0.0.1-SNAPSHOT.201703061507", + "version": "0.0.1-SNAPSHOT.201704021610", "description": "JQuery client for @swagger/angular2-typescript-petstore", "main": "api.js", "scripts": {