From 6c922fdae1b08d7dcf2fac9f7b4dd1452a5e1fd4 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sun, 23 Jul 2017 01:39:36 +0800 Subject: [PATCH] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit b33232e52b9642e9edf724429dc99afe39d9df07 Merge: e3a1e30 3e76185 Author: wing328 Date: Sun Jul 23 01:38:09 2017 +0800 Merge branch 'add-petstore-support-typescript-jquery' of https://github.com/StingrayDigital/swagger-codegen into StingrayDigital-add-petstore-support-typescript-jquery commit 3e76185d906d8b53cc3e7a198546b9e111a0cca4 Author: Jean-François Côté Date: Thu Jul 20 13:50:01 2017 -0400 Add working npm generator. commit 5c27df7c4822fed10ddb81b8a35f60ca40b60914 Author: Jean-François Côté Date: Fri Jul 7 14:39:39 2017 -0400 Fix suggested by @wing328 's review commit 41da37b3576a82ad6056434d36e9d579ef495492 Author: Jean-François Côté Date: Wed Jul 5 15:47:40 2017 -0400 Add petstore integration and updated sample --- ...l.sh => typescript-jquery-petstore-all.sh} | 8 +- bin/typescript-jquery-petstore-npm.json | 6 + bin/typescript-jquery-petstore-with-npm.sh | 31 + bin/typescript-jquery-petstore.sh | 31 + bin/windows/typescript-jquery-with-npm.bat | 10 + bin/windows/typescript-jquery.bat | 10 + .../TypeScriptJqueryClientCodegen.java | 2 +- .../typescript-jquery/package.mustache | 7 +- .../typescript-jquery/tsconfig.mustache | 4 +- .../typescript-jquery/typings.mustache | 4 +- .../petstore/typescript-jquery/default/api.ts | 1213 ----------------- .../typescript-jquery/default/api/PetApi.ts | 102 +- .../typescript-jquery/default/api/StoreApi.ts | 39 +- .../typescript-jquery/default/api/UserApi.ts | 86 +- .../default/model/ApiResponse.ts | 25 + .../default/model/Category.ts | 7 +- .../typescript-jquery/default/model/Order.ts | 7 +- .../typescript-jquery/default/model/Pet.ts | 7 +- .../typescript-jquery/default/model/Tag.ts | 7 +- .../typescript-jquery/default/model/User.ts | 7 +- .../typescript-jquery/default/model/models.ts | 1 + .../petstore/typescript-jquery/npm/api.ts | 1213 ----------------- .../typescript-jquery/npm/api/PetApi.ts | 102 +- .../typescript-jquery/npm/api/StoreApi.ts | 39 +- .../typescript-jquery/npm/api/UserApi.ts | 86 +- .../npm/model/ApiResponse.ts | 25 + .../typescript-jquery/npm/model/Category.ts | 7 +- .../typescript-jquery/npm/model/Order.ts | 7 +- .../typescript-jquery/npm/model/Pet.ts | 7 +- .../typescript-jquery/npm/model/Tag.ts | 7 +- .../typescript-jquery/npm/model/User.ts | 7 +- .../typescript-jquery/npm/model/models.ts | 1 + .../typescript-jquery/npm/package.json | 11 +- .../petstore/typescript-jquery/npm/pom.xml | 46 - .../typescript-jquery/npm/tsconfig.json | 4 +- .../typescript-jquery/npm/typings.json | 4 +- 36 files changed, 469 insertions(+), 2711 deletions(-) rename bin/{typescript-jquery-all.sh => typescript-jquery-petstore-all.sh} (73%) create mode 100644 bin/typescript-jquery-petstore-npm.json create mode 100644 bin/typescript-jquery-petstore-with-npm.sh create mode 100644 bin/typescript-jquery-petstore.sh create mode 100644 bin/windows/typescript-jquery-with-npm.bat create mode 100644 bin/windows/typescript-jquery.bat delete mode 100644 samples/client/petstore/typescript-jquery/default/api.ts create mode 100644 samples/client/petstore/typescript-jquery/default/model/ApiResponse.ts delete mode 100644 samples/client/petstore/typescript-jquery/npm/api.ts create mode 100644 samples/client/petstore/typescript-jquery/npm/model/ApiResponse.ts delete mode 100644 samples/client/petstore/typescript-jquery/npm/pom.xml diff --git a/bin/typescript-jquery-all.sh b/bin/typescript-jquery-petstore-all.sh similarity index 73% rename from bin/typescript-jquery-all.sh rename to bin/typescript-jquery-petstore-all.sh index 7203fa099a55..1a00eb1ce1c6 100755 --- a/bin/typescript-jquery-all.sh +++ b/bin/typescript-jquery-petstore-all.sh @@ -27,10 +27,10 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -echo "Typescript jquery Petstore API client (default setting)" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-jquery -o samples/client/petstore/typescript-jquery/default" +echo "Typescript Petstore API client (default)" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-jquery -o samples/client/petstore/typescript-jquery/default" java $JAVA_OPTS -jar $executable $ags -echo "Typescript jquery Petstore API client with npm setting" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-jquery -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-jquery/npm" +echo "Typescript Petstore API client (npm setting)" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-jquery -c bin/typescript-jquery-petstore-npm.json -o samples/client/petstore/typescript-jquery/npm" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/typescript-jquery-petstore-npm.json b/bin/typescript-jquery-petstore-npm.json new file mode 100644 index 000000000000..c1ec66df6ea3 --- /dev/null +++ b/bin/typescript-jquery-petstore-npm.json @@ -0,0 +1,6 @@ +{ + "npmName": "@swagger/jquery-typescript-petstore", + "npmVersion": "0.0.1", + "npmRepository" : "https://skimdb.npmjs.com/registry", + "snapshot" : false +} diff --git a/bin/typescript-jquery-petstore-with-npm.sh b/bin/typescript-jquery-petstore-with-npm.sh new file mode 100644 index 000000000000..576d2ff5c098 --- /dev/null +++ b/bin/typescript-jquery-petstore-with-npm.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +SCRIPT="$0" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-jquery -c bin/typescript-jquery-petstore-npm.json -o samples/client/petstore/typescript-jquery/npm" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/typescript-jquery-petstore.sh b/bin/typescript-jquery-petstore.sh new file mode 100644 index 000000000000..fcce07152ddf --- /dev/null +++ b/bin/typescript-jquery-petstore.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +SCRIPT="$0" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-jquery -o samples/client/petstore/typescript-jquery/default" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/windows/typescript-jquery-with-npm.bat b/bin/windows/typescript-jquery-with-npm.bat new file mode 100644 index 000000000000..cc7b1e6e4ffa --- /dev/null +++ b/bin/windows/typescript-jquery-with-npm.bat @@ -0,0 +1,10 @@ +set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar + +If Not Exist %executable% ( + mvn clean package +) + +REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M +set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -c bin\typescript-petstore-npm.json -l typescript-jquery -o samples\client\petstore\typescript-jquery\npm + +java %JAVA_OPTS% -jar %executable% %ags% diff --git a/bin/windows/typescript-jquery.bat b/bin/windows/typescript-jquery.bat new file mode 100644 index 000000000000..5a30ca4dfc04 --- /dev/null +++ b/bin/windows/typescript-jquery.bat @@ -0,0 +1,10 @@ +set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar + +If Not Exist %executable% ( + mvn clean package +) + +REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M +set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l typescript-query -o samples\client\petstore\typescript-jquery\default + +java %JAVA_OPTS% -jar %executable% %ags% diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptJqueryClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptJqueryClientCodegen.java index ab12f1a5b60c..9edb26a7829a 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptJqueryClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptJqueryClientCodegen.java @@ -15,7 +15,7 @@ import io.swagger.codegen.CliOption; import io.swagger.codegen.SupportingFile; public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodegen { - private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptNodeClientCodegen.class); + private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptJqueryClientCodegen.class); private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm"); public static final String NPM_NAME = "npmName"; diff --git a/modules/swagger-codegen/src/main/resources/typescript-jquery/package.mustache b/modules/swagger-codegen/src/main/resources/typescript-jquery/package.mustache index 732777196fc2..753b37fb769f 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-jquery/package.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-jquery/package.mustache @@ -10,11 +10,12 @@ "license": "MIT", "dependencies": { "bluebird": "^3.3.5", - "request": "^2.72.0" + "request": "^2.72.0", + "jquery": "^3.1.1" }, "devDependencies": { - "typescript": "^1.8.10", - "typings": "^0.8.1" + "typescript": "2.2.2", + "typings": "^1.3.0" }{{#npmRepository}}, "publishConfig":{ "registry":"{{npmRepository}}" diff --git a/modules/swagger-codegen/src/main/resources/typescript-jquery/tsconfig.mustache b/modules/swagger-codegen/src/main/resources/typescript-jquery/tsconfig.mustache index 1a3bd00183a3..c5228429a633 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-jquery/tsconfig.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-jquery/tsconfig.mustache @@ -11,8 +11,8 @@ "declaration": true }, "files": [ - "api.ts", - "typings/main.d.ts" + "index.ts", + "typings/index.d.ts" ] } diff --git a/modules/swagger-codegen/src/main/resources/typescript-jquery/typings.mustache b/modules/swagger-codegen/src/main/resources/typescript-jquery/typings.mustache index 76c4cc8e6af3..306cf301b884 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-jquery/typings.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-jquery/typings.mustache @@ -4,7 +4,7 @@ "core-js": "registry:dt/core-js#0.0.0+20160317120654", "node": "registry:dt/node#4.0.0+20160423143914" }, - "dependencies": { - "request": "registry:npm/request#2.69.0+20160304121250" + "globalDependencies": { + "jquery": "registry:dt/jquery#1.10.0+20170310222111" } } \ No newline at end of file diff --git a/samples/client/petstore/typescript-jquery/default/api.ts b/samples/client/petstore/typescript-jquery/default/api.ts deleted file mode 100644 index 9bcd271b9ef4..000000000000 --- a/samples/client/petstore/typescript-jquery/default/api.ts +++ /dev/null @@ -1,1213 +0,0 @@ -import * as $ from 'jquery'; - -let defaultBasePath = 'http://petstore.swagger.io/v2'; - -// =============================================== -// This file is autogenerated - Please do not edit -// =============================================== - -/* tslint:disable:no-unused-variable */ - -export class Category { - 'id': number; - 'name': string; -} - -export class Order { - '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 class Pet { - '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 class Tag { - '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; -} - - -export interface Authentication { - /** - * 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; - } -} - -export class ApiKeyAuth implements Authentication { - public apiKey: string; - - constructor(private location: string, private paramName: string) { - } - - applyToRequest(requestOptions: JQueryAjaxSettings): void { - requestOptions.headers[this.paramName] = this.apiKey; - } -} - -export class OAuth implements Authentication { - public accessToken: string; - - 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 - } -} - -export enum PetApiApiKeys { - 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; - } - - /** - * - * @summary 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: any, 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(); - } - /** - * - * @summary 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: any, 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(); - } - /** - * Multiple status values can be provided with comma separated strings - * @summary Finds Pets by status - * @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(); - } - /** - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * @summary Finds Pets by tags - * @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(); - } - /** - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @summary Find pet by ID - * @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.api_key.applyToRequest(requestOptions); - - this.authentications.petstore_auth.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(); - } - /** - * - * @summary 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: any, 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(); - } - /** - * - * @summary 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: any, 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(); - } - /** - * - * @summary 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: any, 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, -} - -export class StoreApi { - 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: 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; - } - - /** - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * @summary Delete purchase order by ID - * @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.'); - } - - - 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: any, 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 a map of status codes to quantities - * @summary Returns pet inventories by status - */ - 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); - - - 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.api_key.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(); - } - /** - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * @summary Find purchase order by ID - * @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.'); - } - - - 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: 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(); - } - /** - * - * @summary 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); - - - 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: 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, -} - -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; - } - - /** - * This can only be done by the logged in user. - * @summary Create 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: any, 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(); - } - /** - * - * @summary 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: any, 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(); - } - /** - * - * @summary 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: any, 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(); - } - /** - * This can only be done by the logged in user. - * @summary Delete 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: any, 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(); - } - /** - * - * @summary 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(); - } - /** - * - * @summary 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(); - } - /** - * - * @summary 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: any, 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(); - } - /** - * This can only be done by the logged in user. - * @summary Updated 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: any, 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/default/api/PetApi.ts b/samples/client/petstore/typescript-jquery/default/api/PetApi.ts index fdf053b73039..8b7200125255 100644 --- a/samples/client/petstore/typescript-jquery/default/api/PetApi.ts +++ b/samples/client/petstore/typescript-jquery/default/api/PetApi.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -43,15 +43,19 @@ export class PetApi { } /** - * Add a new pet to the store * + * @summary Add a new pet to the store * @param body Pet object that needs to be added to the store */ - public addPet(body?: models.Pet): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public addPet(body: models.Pet): JQueryPromise<{ response: JQueryXHR; body?: any; }> { let localVarPath = this.basePath + '/pet'; let queryParameters: any = {}; let headerParams: any = {}; + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling addPet.'); + } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -63,8 +67,8 @@ export class PetApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -102,8 +106,8 @@ export class PetApi { } /** - * Deletes a pet * + * @summary Deletes a pet * @param petId Pet id to delete * @param apiKey */ @@ -128,8 +132,8 @@ export class PetApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -164,20 +168,22 @@ export class PetApi { } /** - * Finds Pets by status * Multiple status values can be provided with comma separated strings + * @summary Finds Pets by status * @param status Status values that need to be considered for filter */ - public findPetsByStatus(status?: Array): JQueryPromise<{ response: JQueryXHR; body: Array; }> { + public findPetsByStatus(status: Array): JQueryPromise<{ response: JQueryXHR; body: Array; }> { let localVarPath = this.basePath + '/pet/findByStatus'; let queryParameters: any = {}; let headerParams: any = {}; + // verify required parameter 'status' is not null or undefined + if (status === null || status === undefined) { + throw new Error('Required parameter status was null or undefined when calling findPetsByStatus.'); + } if (status) { - status.forEach((element: any) => { - queryParameters['status'].push(element); - }); + queryParameters['status'] = status.join(COLLECTION_FORMATS['csv']); } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -187,8 +193,8 @@ export class PetApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -223,20 +229,22 @@ export class PetApi { } /** - * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @summary Finds Pets by tags * @param tags Tags to filter by */ - public findPetsByTags(tags?: Array): JQueryPromise<{ response: JQueryXHR; body: Array; }> { + public findPetsByTags(tags: Array): JQueryPromise<{ response: JQueryXHR; body: Array; }> { let localVarPath = this.basePath + '/pet/findByTags'; let queryParameters: any = {}; let headerParams: any = {}; + // verify required parameter 'tags' is not null or undefined + if (tags === null || tags === undefined) { + throw new Error('Required parameter tags was null or undefined when calling findPetsByTags.'); + } if (tags) { - tags.forEach((element: any) => { - queryParameters['tags'].push(element); - }); + queryParameters['tags'] = tags.join(COLLECTION_FORMATS['csv']); } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -246,8 +254,8 @@ export class PetApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -282,9 +290,9 @@ export class PetApi { } /** - * 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 + * Returns a single pet + * @summary Find pet by ID + * @param petId ID of pet to return */ public getPetById(petId: number): JQueryPromise<{ response: JQueryXHR; body: models.Pet; }> { let localVarPath = this.basePath + '/pet/{petId}'.replace('{' + 'petId' + '}', String(petId)); @@ -304,8 +312,8 @@ export class PetApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (api_key) required @@ -313,15 +321,6 @@ export class PetApi { headerParams['api_key'] = this.configuration.apiKey; } - // authentication (petstore_auth) required - // oauth required - if (this.configuration.accessToken) { - let accessToken = typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; - headerParams['Authorization'] = 'Bearer ' + accessToken; - } - let requestOptions: JQueryAjaxSettings = { url: localVarPath, @@ -345,15 +344,19 @@ export class PetApi { } /** - * Update an existing pet * + * @summary Update an existing pet * @param body Pet object that needs to be added to the store */ - public updatePet(body?: models.Pet): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public updatePet(body: models.Pet): JQueryPromise<{ response: JQueryXHR; body?: any; }> { let localVarPath = this.basePath + '/pet'; let queryParameters: any = {}; let headerParams: any = {}; + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling updatePet.'); + } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -365,8 +368,8 @@ export class PetApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -404,13 +407,13 @@ export class PetApi { } /** - * Updates a pet in the store with form data * + * @summary 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; }> { + public updatePetWithForm(petId: number, name?: string, status?: string): JQueryPromise<{ response: JQueryXHR; body?: any; }> { let localVarPath = this.basePath + '/pet/{petId}'.replace('{' + 'petId' + '}', String(petId)); let queryParameters: any = {}; @@ -442,8 +445,8 @@ export class PetApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -486,13 +489,13 @@ export class PetApi { } /** - * uploads an image * + * @summary 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; }> { + public uploadFile(petId: number, additionalMetadata?: string, file?: any): JQueryPromise<{ response: JQueryXHR; body: models.ApiResponse; }> { let localVarPath = this.basePath + '/pet/{petId}/uploadImage'.replace('{' + 'petId' + '}', String(petId)); let queryParameters: any = {}; @@ -525,8 +528,7 @@ export class PetApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/json' ]; // authentication (petstore_auth) required @@ -560,7 +562,7 @@ export class PetApi { let dfd = $.Deferred(); $.ajax(requestOptions).then( - (data: any, textStatus: string, jqXHR: JQueryXHR) => + (data: models.ApiResponse, textStatus: string, jqXHR: JQueryXHR) => dfd.resolve(jqXHR, data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => dfd.reject(xhr, errorThrown) diff --git a/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts b/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts index a2495cc0f30a..f7e3edc1ccd2 100644 --- a/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts +++ b/samples/client/petstore/typescript-jquery/default/api/StoreApi.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -43,8 +43,8 @@ export class StoreApi { } /** - * Delete purchase order by ID - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @summary Delete purchase order by ID * @param orderId ID of the order that needs to be deleted */ public deleteOrder(orderId: string): JQueryPromise<{ response: JQueryXHR; body?: any; }> { @@ -65,8 +65,8 @@ export class StoreApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -92,8 +92,8 @@ export class StoreApi { } /** - * Returns pet inventories by status * Returns a map of status codes to quantities + * @summary Returns pet inventories by status */ public getInventory(): JQueryPromise<{ response: JQueryXHR; body: { [key: string]: number; }; }> { let localVarPath = this.basePath + '/store/inventory'; @@ -108,8 +108,7 @@ export class StoreApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/json' ]; // authentication (api_key) required @@ -140,11 +139,11 @@ export class StoreApi { } /** - * Find purchase order by ID - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @summary Find purchase order by ID * @param orderId ID of pet that needs to be fetched */ - public getOrderById(orderId: string): JQueryPromise<{ response: JQueryXHR; body: models.Order; }> { + public getOrderById(orderId: number): JQueryPromise<{ response: JQueryXHR; body: models.Order; }> { let localVarPath = this.basePath + '/store/order/{orderId}'.replace('{' + 'orderId' + '}', String(orderId)); let queryParameters: any = {}; @@ -162,8 +161,8 @@ export class StoreApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -189,15 +188,19 @@ export class StoreApi { } /** - * Place an order for a pet * + * @summary Place an order for a pet * @param body order placed for purchasing the pet */ - public placeOrder(body?: models.Order): JQueryPromise<{ response: JQueryXHR; body: models.Order; }> { + public placeOrder(body: models.Order): JQueryPromise<{ response: JQueryXHR; body: models.Order; }> { let localVarPath = this.basePath + '/store/order'; let queryParameters: any = {}; let headerParams: any = {}; + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling placeOrder.'); + } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -207,8 +210,8 @@ export class StoreApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; diff --git a/samples/client/petstore/typescript-jquery/default/api/UserApi.ts b/samples/client/petstore/typescript-jquery/default/api/UserApi.ts index 53349124ed65..3daa0f679407 100644 --- a/samples/client/petstore/typescript-jquery/default/api/UserApi.ts +++ b/samples/client/petstore/typescript-jquery/default/api/UserApi.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -43,15 +43,19 @@ export class UserApi { } /** - * Create user * This can only be done by the logged in user. + * @summary Create user * @param body Created user object */ - public createUser(body?: models.User): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public createUser(body: models.User): JQueryPromise<{ response: JQueryXHR; body?: any; }> { let localVarPath = this.basePath + '/user'; let queryParameters: any = {}; let headerParams: any = {}; + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling createUser.'); + } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -61,8 +65,8 @@ export class UserApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -91,15 +95,19 @@ export class UserApi { } /** - * Creates list of users with given input array * + * @summary Creates list of users with given input array * @param body List of user object */ - public createUsersWithArrayInput(body?: Array): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public createUsersWithArrayInput(body: Array): JQueryPromise<{ response: JQueryXHR; body?: any; }> { let localVarPath = this.basePath + '/user/createWithArray'; let queryParameters: any = {}; let headerParams: any = {}; + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling createUsersWithArrayInput.'); + } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -109,8 +117,8 @@ export class UserApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -139,15 +147,19 @@ export class UserApi { } /** - * Creates list of users with given input array * + * @summary Creates list of users with given input array * @param body List of user object */ - public createUsersWithListInput(body?: Array): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public createUsersWithListInput(body: Array): JQueryPromise<{ response: JQueryXHR; body?: any; }> { let localVarPath = this.basePath + '/user/createWithList'; let queryParameters: any = {}; let headerParams: any = {}; + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling createUsersWithListInput.'); + } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -157,8 +169,8 @@ export class UserApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -187,8 +199,8 @@ export class UserApi { } /** - * Delete user * This can only be done by the logged in user. + * @summary Delete user * @param username The name that needs to be deleted */ public deleteUser(username: string): JQueryPromise<{ response: JQueryXHR; body?: any; }> { @@ -209,8 +221,8 @@ export class UserApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -236,8 +248,8 @@ export class UserApi { } /** - * Get user by user name * + * @summary 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: models.User; }> { @@ -258,8 +270,8 @@ export class UserApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -285,17 +297,25 @@ export class UserApi { } /** - * Logs user into the system * + * @summary 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; }> { + public loginUser(username: string, password: string): JQueryPromise<{ response: JQueryXHR; body: string; }> { let localVarPath = this.basePath + '/user/login'; let queryParameters: any = {}; let headerParams: any = {}; + // 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 loginUser.'); + } + // verify required parameter 'password' is not null or undefined + if (password === null || password === undefined) { + throw new Error('Required parameter password was null or undefined when calling loginUser.'); + } if (username !== null && username !== undefined) { queryParameters['username'] = username; @@ -311,8 +331,8 @@ export class UserApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -338,8 +358,8 @@ export class UserApi { } /** - * Logs out current logged in user session * + * @summary Logs out current logged in user session */ public logoutUser(): JQueryPromise<{ response: JQueryXHR; body?: any; }> { let localVarPath = this.basePath + '/user/logout'; @@ -354,8 +374,8 @@ export class UserApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -381,12 +401,12 @@ export class UserApi { } /** - * Updated user * This can only be done by the logged in user. + * @summary Updated user * @param username name that need to be deleted * @param body Updated user object */ - public updateUser(username: string, body?: models.User): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public updateUser(username: string, body: models.User): JQueryPromise<{ response: JQueryXHR; body?: any; }> { let localVarPath = this.basePath + '/user/{username}'.replace('{' + 'username' + '}', String(username)); let queryParameters: any = {}; @@ -396,6 +416,10 @@ export class UserApi { throw new Error('Required parameter username was null or undefined when calling updateUser.'); } + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling updateUser.'); + } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -405,8 +429,8 @@ export class UserApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; diff --git a/samples/client/petstore/typescript-jquery/default/model/ApiResponse.ts b/samples/client/petstore/typescript-jquery/default/model/ApiResponse.ts new file mode 100644 index 000000000000..f86e84f93a3a --- /dev/null +++ b/samples/client/petstore/typescript-jquery/default/model/ApiResponse.ts @@ -0,0 +1,25 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import * as models from './models'; + +/** + * Describes the result of uploading an image resource + */ +export interface ApiResponse { + code?: number; + + type?: string; + + message?: string; + +} diff --git a/samples/client/petstore/typescript-jquery/default/model/Category.ts b/samples/client/petstore/typescript-jquery/default/model/Category.ts index ffdacd4f707d..254c3003c89a 100644 --- a/samples/client/petstore/typescript-jquery/default/model/Category.ts +++ b/samples/client/petstore/typescript-jquery/default/model/Category.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -12,6 +12,9 @@ import * as models from './models'; +/** + * A category for a pet + */ export interface Category { id?: number; diff --git a/samples/client/petstore/typescript-jquery/default/model/Order.ts b/samples/client/petstore/typescript-jquery/default/model/Order.ts index 9c47071c5b67..2b6c7aeebd66 100644 --- a/samples/client/petstore/typescript-jquery/default/model/Order.ts +++ b/samples/client/petstore/typescript-jquery/default/model/Order.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -12,6 +12,9 @@ import * as models from './models'; +/** + * An order for a pets from the pet store + */ export interface Order { id?: number; diff --git a/samples/client/petstore/typescript-jquery/default/model/Pet.ts b/samples/client/petstore/typescript-jquery/default/model/Pet.ts index d64dc809e532..b878cadb9058 100644 --- a/samples/client/petstore/typescript-jquery/default/model/Pet.ts +++ b/samples/client/petstore/typescript-jquery/default/model/Pet.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -12,6 +12,9 @@ import * as models from './models'; +/** + * A pet for sale in the pet store + */ export interface Pet { id?: number; diff --git a/samples/client/petstore/typescript-jquery/default/model/Tag.ts b/samples/client/petstore/typescript-jquery/default/model/Tag.ts index 8a3b99ae9ca4..8cbdc4fa145e 100644 --- a/samples/client/petstore/typescript-jquery/default/model/Tag.ts +++ b/samples/client/petstore/typescript-jquery/default/model/Tag.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -12,6 +12,9 @@ import * as models from './models'; +/** + * A tag for a pet + */ export interface Tag { id?: number; diff --git a/samples/client/petstore/typescript-jquery/default/model/User.ts b/samples/client/petstore/typescript-jquery/default/model/User.ts index 43d00f7b318e..fbf75dfe28e3 100644 --- a/samples/client/petstore/typescript-jquery/default/model/User.ts +++ b/samples/client/petstore/typescript-jquery/default/model/User.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -12,6 +12,9 @@ import * as models from './models'; +/** + * A User who is purchasing from the pet store + */ export interface User { id?: number; diff --git a/samples/client/petstore/typescript-jquery/default/model/models.ts b/samples/client/petstore/typescript-jquery/default/model/models.ts index 92dac02846c2..f53c1dd42bdd 100644 --- a/samples/client/petstore/typescript-jquery/default/model/models.ts +++ b/samples/client/petstore/typescript-jquery/default/model/models.ts @@ -1,3 +1,4 @@ +export * from './ApiResponse'; export * from './Category'; export * from './Order'; export * from './Pet'; diff --git a/samples/client/petstore/typescript-jquery/npm/api.ts b/samples/client/petstore/typescript-jquery/npm/api.ts deleted file mode 100644 index 9bcd271b9ef4..000000000000 --- a/samples/client/petstore/typescript-jquery/npm/api.ts +++ /dev/null @@ -1,1213 +0,0 @@ -import * as $ from 'jquery'; - -let defaultBasePath = 'http://petstore.swagger.io/v2'; - -// =============================================== -// This file is autogenerated - Please do not edit -// =============================================== - -/* tslint:disable:no-unused-variable */ - -export class Category { - 'id': number; - 'name': string; -} - -export class Order { - '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 class Pet { - '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 class Tag { - '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; -} - - -export interface Authentication { - /** - * 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; - } -} - -export class ApiKeyAuth implements Authentication { - public apiKey: string; - - constructor(private location: string, private paramName: string) { - } - - applyToRequest(requestOptions: JQueryAjaxSettings): void { - requestOptions.headers[this.paramName] = this.apiKey; - } -} - -export class OAuth implements Authentication { - public accessToken: string; - - 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 - } -} - -export enum PetApiApiKeys { - 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; - } - - /** - * - * @summary 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: any, 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(); - } - /** - * - * @summary 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: any, 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(); - } - /** - * Multiple status values can be provided with comma separated strings - * @summary Finds Pets by status - * @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(); - } - /** - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * @summary Finds Pets by tags - * @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(); - } - /** - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @summary Find pet by ID - * @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.api_key.applyToRequest(requestOptions); - - this.authentications.petstore_auth.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(); - } - /** - * - * @summary 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: any, 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(); - } - /** - * - * @summary 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: any, 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(); - } - /** - * - * @summary 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: any, 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, -} - -export class StoreApi { - 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: 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; - } - - /** - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * @summary Delete purchase order by ID - * @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.'); - } - - - 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: any, 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 a map of status codes to quantities - * @summary Returns pet inventories by status - */ - 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); - - - 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.api_key.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(); - } - /** - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * @summary Find purchase order by ID - * @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.'); - } - - - 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: 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(); - } - /** - * - * @summary 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); - - - 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: 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, -} - -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; - } - - /** - * This can only be done by the logged in user. - * @summary Create 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: any, 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(); - } - /** - * - * @summary 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: any, 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(); - } - /** - * - * @summary 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: any, 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(); - } - /** - * This can only be done by the logged in user. - * @summary Delete 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: any, 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(); - } - /** - * - * @summary 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(); - } - /** - * - * @summary 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(); - } - /** - * - * @summary 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: any, 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(); - } - /** - * This can only be done by the logged in user. - * @summary Updated 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: any, 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/PetApi.ts b/samples/client/petstore/typescript-jquery/npm/api/PetApi.ts index fdf053b73039..8b7200125255 100644 --- a/samples/client/petstore/typescript-jquery/npm/api/PetApi.ts +++ b/samples/client/petstore/typescript-jquery/npm/api/PetApi.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -43,15 +43,19 @@ export class PetApi { } /** - * Add a new pet to the store * + * @summary Add a new pet to the store * @param body Pet object that needs to be added to the store */ - public addPet(body?: models.Pet): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public addPet(body: models.Pet): JQueryPromise<{ response: JQueryXHR; body?: any; }> { let localVarPath = this.basePath + '/pet'; let queryParameters: any = {}; let headerParams: any = {}; + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling addPet.'); + } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -63,8 +67,8 @@ export class PetApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -102,8 +106,8 @@ export class PetApi { } /** - * Deletes a pet * + * @summary Deletes a pet * @param petId Pet id to delete * @param apiKey */ @@ -128,8 +132,8 @@ export class PetApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -164,20 +168,22 @@ export class PetApi { } /** - * Finds Pets by status * Multiple status values can be provided with comma separated strings + * @summary Finds Pets by status * @param status Status values that need to be considered for filter */ - public findPetsByStatus(status?: Array): JQueryPromise<{ response: JQueryXHR; body: Array; }> { + public findPetsByStatus(status: Array): JQueryPromise<{ response: JQueryXHR; body: Array; }> { let localVarPath = this.basePath + '/pet/findByStatus'; let queryParameters: any = {}; let headerParams: any = {}; + // verify required parameter 'status' is not null or undefined + if (status === null || status === undefined) { + throw new Error('Required parameter status was null or undefined when calling findPetsByStatus.'); + } if (status) { - status.forEach((element: any) => { - queryParameters['status'].push(element); - }); + queryParameters['status'] = status.join(COLLECTION_FORMATS['csv']); } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -187,8 +193,8 @@ export class PetApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -223,20 +229,22 @@ export class PetApi { } /** - * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @summary Finds Pets by tags * @param tags Tags to filter by */ - public findPetsByTags(tags?: Array): JQueryPromise<{ response: JQueryXHR; body: Array; }> { + public findPetsByTags(tags: Array): JQueryPromise<{ response: JQueryXHR; body: Array; }> { let localVarPath = this.basePath + '/pet/findByTags'; let queryParameters: any = {}; let headerParams: any = {}; + // verify required parameter 'tags' is not null or undefined + if (tags === null || tags === undefined) { + throw new Error('Required parameter tags was null or undefined when calling findPetsByTags.'); + } if (tags) { - tags.forEach((element: any) => { - queryParameters['tags'].push(element); - }); + queryParameters['tags'] = tags.join(COLLECTION_FORMATS['csv']); } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -246,8 +254,8 @@ export class PetApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -282,9 +290,9 @@ export class PetApi { } /** - * 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 + * Returns a single pet + * @summary Find pet by ID + * @param petId ID of pet to return */ public getPetById(petId: number): JQueryPromise<{ response: JQueryXHR; body: models.Pet; }> { let localVarPath = this.basePath + '/pet/{petId}'.replace('{' + 'petId' + '}', String(petId)); @@ -304,8 +312,8 @@ export class PetApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (api_key) required @@ -313,15 +321,6 @@ export class PetApi { headerParams['api_key'] = this.configuration.apiKey; } - // authentication (petstore_auth) required - // oauth required - if (this.configuration.accessToken) { - let accessToken = typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; - headerParams['Authorization'] = 'Bearer ' + accessToken; - } - let requestOptions: JQueryAjaxSettings = { url: localVarPath, @@ -345,15 +344,19 @@ export class PetApi { } /** - * Update an existing pet * + * @summary Update an existing pet * @param body Pet object that needs to be added to the store */ - public updatePet(body?: models.Pet): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public updatePet(body: models.Pet): JQueryPromise<{ response: JQueryXHR; body?: any; }> { let localVarPath = this.basePath + '/pet'; let queryParameters: any = {}; let headerParams: any = {}; + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling updatePet.'); + } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -365,8 +368,8 @@ export class PetApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -404,13 +407,13 @@ export class PetApi { } /** - * Updates a pet in the store with form data * + * @summary 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; }> { + public updatePetWithForm(petId: number, name?: string, status?: string): JQueryPromise<{ response: JQueryXHR; body?: any; }> { let localVarPath = this.basePath + '/pet/{petId}'.replace('{' + 'petId' + '}', String(petId)); let queryParameters: any = {}; @@ -442,8 +445,8 @@ export class PetApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -486,13 +489,13 @@ export class PetApi { } /** - * uploads an image * + * @summary 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; }> { + public uploadFile(petId: number, additionalMetadata?: string, file?: any): JQueryPromise<{ response: JQueryXHR; body: models.ApiResponse; }> { let localVarPath = this.basePath + '/pet/{petId}/uploadImage'.replace('{' + 'petId' + '}', String(petId)); let queryParameters: any = {}; @@ -525,8 +528,7 @@ export class PetApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/json' ]; // authentication (petstore_auth) required @@ -560,7 +562,7 @@ export class PetApi { let dfd = $.Deferred(); $.ajax(requestOptions).then( - (data: any, textStatus: string, jqXHR: JQueryXHR) => + (data: models.ApiResponse, textStatus: string, jqXHR: JQueryXHR) => dfd.resolve(jqXHR, data), (xhr: JQueryXHR, textStatus: string, errorThrown: string) => dfd.reject(xhr, errorThrown) diff --git a/samples/client/petstore/typescript-jquery/npm/api/StoreApi.ts b/samples/client/petstore/typescript-jquery/npm/api/StoreApi.ts index a2495cc0f30a..f7e3edc1ccd2 100644 --- a/samples/client/petstore/typescript-jquery/npm/api/StoreApi.ts +++ b/samples/client/petstore/typescript-jquery/npm/api/StoreApi.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -43,8 +43,8 @@ export class StoreApi { } /** - * Delete purchase order by ID - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @summary Delete purchase order by ID * @param orderId ID of the order that needs to be deleted */ public deleteOrder(orderId: string): JQueryPromise<{ response: JQueryXHR; body?: any; }> { @@ -65,8 +65,8 @@ export class StoreApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -92,8 +92,8 @@ export class StoreApi { } /** - * Returns pet inventories by status * Returns a map of status codes to quantities + * @summary Returns pet inventories by status */ public getInventory(): JQueryPromise<{ response: JQueryXHR; body: { [key: string]: number; }; }> { let localVarPath = this.basePath + '/store/inventory'; @@ -108,8 +108,7 @@ export class StoreApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/json' ]; // authentication (api_key) required @@ -140,11 +139,11 @@ export class StoreApi { } /** - * Find purchase order by ID - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @summary Find purchase order by ID * @param orderId ID of pet that needs to be fetched */ - public getOrderById(orderId: string): JQueryPromise<{ response: JQueryXHR; body: models.Order; }> { + public getOrderById(orderId: number): JQueryPromise<{ response: JQueryXHR; body: models.Order; }> { let localVarPath = this.basePath + '/store/order/{orderId}'.replace('{' + 'orderId' + '}', String(orderId)); let queryParameters: any = {}; @@ -162,8 +161,8 @@ export class StoreApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -189,15 +188,19 @@ export class StoreApi { } /** - * Place an order for a pet * + * @summary Place an order for a pet * @param body order placed for purchasing the pet */ - public placeOrder(body?: models.Order): JQueryPromise<{ response: JQueryXHR; body: models.Order; }> { + public placeOrder(body: models.Order): JQueryPromise<{ response: JQueryXHR; body: models.Order; }> { let localVarPath = this.basePath + '/store/order'; let queryParameters: any = {}; let headerParams: any = {}; + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling placeOrder.'); + } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -207,8 +210,8 @@ export class StoreApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; diff --git a/samples/client/petstore/typescript-jquery/npm/api/UserApi.ts b/samples/client/petstore/typescript-jquery/npm/api/UserApi.ts index 53349124ed65..3daa0f679407 100644 --- a/samples/client/petstore/typescript-jquery/npm/api/UserApi.ts +++ b/samples/client/petstore/typescript-jquery/npm/api/UserApi.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -43,15 +43,19 @@ export class UserApi { } /** - * Create user * This can only be done by the logged in user. + * @summary Create user * @param body Created user object */ - public createUser(body?: models.User): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public createUser(body: models.User): JQueryPromise<{ response: JQueryXHR; body?: any; }> { let localVarPath = this.basePath + '/user'; let queryParameters: any = {}; let headerParams: any = {}; + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling createUser.'); + } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -61,8 +65,8 @@ export class UserApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -91,15 +95,19 @@ export class UserApi { } /** - * Creates list of users with given input array * + * @summary Creates list of users with given input array * @param body List of user object */ - public createUsersWithArrayInput(body?: Array): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public createUsersWithArrayInput(body: Array): JQueryPromise<{ response: JQueryXHR; body?: any; }> { let localVarPath = this.basePath + '/user/createWithArray'; let queryParameters: any = {}; let headerParams: any = {}; + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling createUsersWithArrayInput.'); + } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -109,8 +117,8 @@ export class UserApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -139,15 +147,19 @@ export class UserApi { } /** - * Creates list of users with given input array * + * @summary Creates list of users with given input array * @param body List of user object */ - public createUsersWithListInput(body?: Array): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public createUsersWithListInput(body: Array): JQueryPromise<{ response: JQueryXHR; body?: any; }> { let localVarPath = this.basePath + '/user/createWithList'; let queryParameters: any = {}; let headerParams: any = {}; + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling createUsersWithListInput.'); + } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -157,8 +169,8 @@ export class UserApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -187,8 +199,8 @@ export class UserApi { } /** - * Delete user * This can only be done by the logged in user. + * @summary Delete user * @param username The name that needs to be deleted */ public deleteUser(username: string): JQueryPromise<{ response: JQueryXHR; body?: any; }> { @@ -209,8 +221,8 @@ export class UserApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -236,8 +248,8 @@ export class UserApi { } /** - * Get user by user name * + * @summary 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: models.User; }> { @@ -258,8 +270,8 @@ export class UserApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -285,17 +297,25 @@ export class UserApi { } /** - * Logs user into the system * + * @summary 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; }> { + public loginUser(username: string, password: string): JQueryPromise<{ response: JQueryXHR; body: string; }> { let localVarPath = this.basePath + '/user/login'; let queryParameters: any = {}; let headerParams: any = {}; + // 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 loginUser.'); + } + // verify required parameter 'password' is not null or undefined + if (password === null || password === undefined) { + throw new Error('Required parameter password was null or undefined when calling loginUser.'); + } if (username !== null && username !== undefined) { queryParameters['username'] = username; @@ -311,8 +331,8 @@ export class UserApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -338,8 +358,8 @@ export class UserApi { } /** - * Logs out current logged in user session * + * @summary Logs out current logged in user session */ public logoutUser(): JQueryPromise<{ response: JQueryXHR; body?: any; }> { let localVarPath = this.basePath + '/user/logout'; @@ -354,8 +374,8 @@ export class UserApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -381,12 +401,12 @@ export class UserApi { } /** - * Updated user * This can only be done by the logged in user. + * @summary Updated user * @param username name that need to be deleted * @param body Updated user object */ - public updateUser(username: string, body?: models.User): JQueryPromise<{ response: JQueryXHR; body?: any; }> { + public updateUser(username: string, body: models.User): JQueryPromise<{ response: JQueryXHR; body?: any; }> { let localVarPath = this.basePath + '/user/{username}'.replace('{' + 'username' + '}', String(username)); let queryParameters: any = {}; @@ -396,6 +416,10 @@ export class UserApi { throw new Error('Required parameter username was null or undefined when calling updateUser.'); } + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling updateUser.'); + } localVarPath = localVarPath + "?" + $.param(queryParameters); @@ -405,8 +429,8 @@ export class UserApi { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; diff --git a/samples/client/petstore/typescript-jquery/npm/model/ApiResponse.ts b/samples/client/petstore/typescript-jquery/npm/model/ApiResponse.ts new file mode 100644 index 000000000000..f86e84f93a3a --- /dev/null +++ b/samples/client/petstore/typescript-jquery/npm/model/ApiResponse.ts @@ -0,0 +1,25 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +import * as models from './models'; + +/** + * Describes the result of uploading an image resource + */ +export interface ApiResponse { + code?: number; + + type?: string; + + message?: string; + +} diff --git a/samples/client/petstore/typescript-jquery/npm/model/Category.ts b/samples/client/petstore/typescript-jquery/npm/model/Category.ts index ffdacd4f707d..254c3003c89a 100644 --- a/samples/client/petstore/typescript-jquery/npm/model/Category.ts +++ b/samples/client/petstore/typescript-jquery/npm/model/Category.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -12,6 +12,9 @@ import * as models from './models'; +/** + * A category for a pet + */ export interface Category { id?: number; diff --git a/samples/client/petstore/typescript-jquery/npm/model/Order.ts b/samples/client/petstore/typescript-jquery/npm/model/Order.ts index 9c47071c5b67..2b6c7aeebd66 100644 --- a/samples/client/petstore/typescript-jquery/npm/model/Order.ts +++ b/samples/client/petstore/typescript-jquery/npm/model/Order.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -12,6 +12,9 @@ import * as models from './models'; +/** + * An order for a pets from the pet store + */ export interface Order { id?: number; diff --git a/samples/client/petstore/typescript-jquery/npm/model/Pet.ts b/samples/client/petstore/typescript-jquery/npm/model/Pet.ts index d64dc809e532..b878cadb9058 100644 --- a/samples/client/petstore/typescript-jquery/npm/model/Pet.ts +++ b/samples/client/petstore/typescript-jquery/npm/model/Pet.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -12,6 +12,9 @@ import * as models from './models'; +/** + * A pet for sale in the pet store + */ export interface Pet { id?: number; diff --git a/samples/client/petstore/typescript-jquery/npm/model/Tag.ts b/samples/client/petstore/typescript-jquery/npm/model/Tag.ts index 8a3b99ae9ca4..8cbdc4fa145e 100644 --- a/samples/client/petstore/typescript-jquery/npm/model/Tag.ts +++ b/samples/client/petstore/typescript-jquery/npm/model/Tag.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -12,6 +12,9 @@ import * as models from './models'; +/** + * A tag for a pet + */ export interface Tag { id?: number; diff --git a/samples/client/petstore/typescript-jquery/npm/model/User.ts b/samples/client/petstore/typescript-jquery/npm/model/User.ts index 43d00f7b318e..fbf75dfe28e3 100644 --- a/samples/client/petstore/typescript-jquery/npm/model/User.ts +++ b/samples/client/petstore/typescript-jquery/npm/model/User.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -12,6 +12,9 @@ import * as models from './models'; +/** + * A User who is purchasing from the pet store + */ export interface User { id?: number; diff --git a/samples/client/petstore/typescript-jquery/npm/model/models.ts b/samples/client/petstore/typescript-jquery/npm/model/models.ts index 92dac02846c2..f53c1dd42bdd 100644 --- a/samples/client/petstore/typescript-jquery/npm/model/models.ts +++ b/samples/client/petstore/typescript-jquery/npm/model/models.ts @@ -1,3 +1,4 @@ +export * from './ApiResponse'; export * from './Category'; export * from './Order'; export * from './Pet'; diff --git a/samples/client/petstore/typescript-jquery/npm/package.json b/samples/client/petstore/typescript-jquery/npm/package.json index aa1996b4d777..2e3360574b88 100644 --- a/samples/client/petstore/typescript-jquery/npm/package.json +++ b/samples/client/petstore/typescript-jquery/npm/package.json @@ -1,7 +1,7 @@ { - "name": "@swagger/angular2-typescript-petstore", + "name": "@swagger/jquery-typescript-petstore", "version": "0.0.1", - "description": "JQuery client for @swagger/angular2-typescript-petstore", + "description": "JQuery client for @swagger/jquery-typescript-petstore", "main": "api.js", "scripts": { "build": "tsc" @@ -10,11 +10,12 @@ "license": "MIT", "dependencies": { "bluebird": "^3.3.5", - "request": "^2.72.0" + "request": "^2.72.0", + "jquery": "^3.1.1" }, "devDependencies": { - "typescript": "^1.8.10", - "typings": "^0.8.1" + "typescript": "2.2.2", + "typings": "^1.3.0" }, "publishConfig":{ "registry":"https://skimdb.npmjs.com/registry" diff --git a/samples/client/petstore/typescript-jquery/npm/pom.xml b/samples/client/petstore/typescript-jquery/npm/pom.xml deleted file mode 100644 index 5e9f6989d264..000000000000 --- a/samples/client/petstore/typescript-jquery/npm/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - 4.0.0 - io.swagger - TSJQueryNPMPestoreClientTests - pom - 1.0-SNAPSHOT - TS jQuery npm Petstore Client - - - - maven-dependency-plugin - - - package - - copy-dependencies - - - ${project.build.directory} - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - - npm-install - pre-integration-test - - exec - - - npm - - install - - - - - - - - diff --git a/samples/client/petstore/typescript-jquery/npm/tsconfig.json b/samples/client/petstore/typescript-jquery/npm/tsconfig.json index 2dd166566e97..e083415ea55d 100644 --- a/samples/client/petstore/typescript-jquery/npm/tsconfig.json +++ b/samples/client/petstore/typescript-jquery/npm/tsconfig.json @@ -11,8 +11,8 @@ "declaration": true }, "files": [ - "api.ts", - "typings/main.d.ts" + "index.ts", + "typings/index.d.ts" ] } diff --git a/samples/client/petstore/typescript-jquery/npm/typings.json b/samples/client/petstore/typescript-jquery/npm/typings.json index 76c4cc8e6af3..306cf301b884 100644 --- a/samples/client/petstore/typescript-jquery/npm/typings.json +++ b/samples/client/petstore/typescript-jquery/npm/typings.json @@ -4,7 +4,7 @@ "core-js": "registry:dt/core-js#0.0.0+20160317120654", "node": "registry:dt/node#4.0.0+20160423143914" }, - "dependencies": { - "request": "registry:npm/request#2.69.0+20160304121250" + "globalDependencies": { + "jquery": "registry:dt/jquery#1.10.0+20170310222111" } } \ No newline at end of file