From 9516c81ebb6d35bb7b48d8263938217bd4f247b0 Mon Sep 17 00:00:00 2001 From: Vlad Frolov Date: Fri, 3 Mar 2017 12:20:52 +0200 Subject: [PATCH] [JavaScript] Added *WithHttpInfo methods in 'usePromises' mode to provide a way to get access to HTTP response object (e.g. headers or status code) (#3654) (#4902) --- .../resources/Javascript/ApiClient.mustache | 2 +- .../main/resources/Javascript/api.mustache | 26 ++- .../javascript-promise/src/ApiClient.js | 2 +- .../javascript-promise/src/api/FakeApi.js | 83 +++++++-- .../javascript-promise/src/api/PetApi.js | 160 +++++++++++++++--- .../javascript-promise/src/api/StoreApi.js | 73 ++++++-- .../javascript-promise/src/api/UserApi.js | 155 ++++++++++++++--- .../petstore/javascript/src/api/FakeApi.js | 10 +- .../petstore/javascript/src/api/PetApi.js | 16 +- .../petstore/javascript/src/api/StoreApi.js | 6 +- .../petstore/javascript/src/api/UserApi.js | 18 +- 11 files changed, 450 insertions(+), 101 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Javascript/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Javascript/ApiClient.mustache index 8a80d0d80b..8f49b13a4c 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/ApiClient.mustache @@ -412,7 +412,7 @@ } else { try { var data = _this.deserialize(response, returnType); - resolve(data); + resolve({data, response}); } catch (err) { reject(err); } diff --git a/modules/swagger-codegen/src/main/resources/Javascript/api.mustache b/modules/swagger-codegen/src/main/resources/Javascript/api.mustache index e3990ed910..b012bfe458 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/api.mustache @@ -50,14 +50,14 @@ * @param {<&vendorExtensions.x-jsdoc-type>} opts. <#defaultValue> (default to <.>)<^usePromises> * @param {module:<#invokerPackage><&invokerPackage>/<#apiPackage><&apiPackage>/<&classname>~Callback} callback The callback function, accepting three arguments: error, data, response<#returnType> * data is of type: {@link <&vendorExtensions.x-jsdoc-type>}<#usePromises> - * @return {Promise} a {@link https://www.promisejs.org/|Promise}<#returnType>, with data of type {@link <&vendorExtensions.x-jsdoc-type>} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}<#returnType>, with an object containing data of type {@link <&vendorExtensions.x-jsdoc-type>} and HTTP response<^returnType>, with an object containing HTTP response */ - this. = function() {<#hasOptionalParams> + this.<#usePromises>WithHttpInfo = function() {<#hasOptionalParams> opts = opts || {}; var postBody = <#bodyParam><#required><^required>opts['']<^bodyParam>null; <#allParams><#required> // verify the required parameter '' is set - if ( == undefined || == null) { + if ( === undefined || === null) { throw new Error("Missing the required parameter '' when calling "); } @@ -86,6 +86,26 @@ authNames, contentTypes, accepts, returnType<^usePromises>, callback ); } +<#usePromises> + <#emitJSDoc> + + /**<#summary> + * <#notes> + * <#allParams><#required> + * @param {<&vendorExtensions.x-jsdoc-type>} <#hasOptionalParams> + * @param {Object} opts Optional parameters<#allParams><^required> + * @param {<&vendorExtensions.x-jsdoc-type>} opts. <#defaultValue> (default to <.>)<^usePromises> + * @param {module:<#invokerPackage><&invokerPackage>/<#apiPackage><&apiPackage>/<&classname>~Callback} callback The callback function, accepting three arguments: error, data, response<#returnType> + * data is of type: {@link <&vendorExtensions.x-jsdoc-type>}<#usePromises> + * @return {Promise} a {@link https://www.promisejs.org/|Promise}<#returnType>, with data of type {@link <&vendorExtensions.x-jsdoc-type>} + */ + this. = function() { + return this.WithHttpInfo() + .then(function(response_and_data) { + return response_and_data.data; + }); + } + }; return exports; diff --git a/samples/client/petstore/javascript-promise/src/ApiClient.js b/samples/client/petstore/javascript-promise/src/ApiClient.js index 3f73597830..6a64ce46bc 100644 --- a/samples/client/petstore/javascript-promise/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise/src/ApiClient.js @@ -406,7 +406,7 @@ } else { try { var data = _this.deserialize(response, returnType); - resolve(data); + resolve({data, response}); } catch (err) { reject(err); } diff --git a/samples/client/petstore/javascript-promise/src/api/FakeApi.js b/samples/client/petstore/javascript-promise/src/api/FakeApi.js index 623fb1d191..30f48949f2 100644 --- a/samples/client/petstore/javascript-promise/src/api/FakeApi.js +++ b/samples/client/petstore/javascript-promise/src/api/FakeApi.js @@ -50,13 +50,13 @@ * To test \"client\" model * To test \"client\" model * @param {module:model/Client} body client model - * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/Client} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/Client} and HTTP response */ - this.testClientModel = function(body) { + this.testClientModelWithHttpInfo = function(body) { var postBody = body; // verify the required parameter 'body' is set - if (body == undefined || body == null) { + if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling testClientModel"); } @@ -82,6 +82,19 @@ ); } + /** + * To test \"client\" model + * To test \"client\" model + * @param {module:model/Client} body client model + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/Client} + */ + this.testClientModel = function(body) { + return this.testClientModelWithHttpInfo(body) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -101,29 +114,29 @@ * @param {Date} opts.dateTime None * @param {String} opts.password None * @param {String} opts.callback None - * @return {Promise} a {@link https://www.promisejs.org/|Promise} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ - this.testEndpointParameters = function(_number, _double, patternWithoutDelimiter, _byte, opts) { + this.testEndpointParametersWithHttpInfo = function(_number, _double, patternWithoutDelimiter, _byte, opts) { opts = opts || {}; var postBody = null; // verify the required parameter '_number' is set - if (_number == undefined || _number == null) { + if (_number === undefined || _number === null) { throw new Error("Missing the required parameter '_number' when calling testEndpointParameters"); } // verify the required parameter '_double' is set - if (_double == undefined || _double == null) { + if (_double === undefined || _double === null) { throw new Error("Missing the required parameter '_double' when calling testEndpointParameters"); } // verify the required parameter 'patternWithoutDelimiter' is set - if (patternWithoutDelimiter == undefined || patternWithoutDelimiter == null) { + if (patternWithoutDelimiter === undefined || patternWithoutDelimiter === null) { throw new Error("Missing the required parameter 'patternWithoutDelimiter' when calling testEndpointParameters"); } // verify the required parameter '_byte' is set - if (_byte == undefined || _byte == null) { + if (_byte === undefined || _byte === null) { throw new Error("Missing the required parameter '_byte' when calling testEndpointParameters"); } @@ -163,6 +176,33 @@ ); } + /** + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * @param {Number} _number None + * @param {Number} _double None + * @param {String} patternWithoutDelimiter None + * @param {String} _byte None + * @param {Object} opts Optional parameters + * @param {Number} opts.integer None + * @param {Number} opts.int32 None + * @param {Number} opts.int64 None + * @param {Number} opts._float None + * @param {String} opts._string None + * @param {String} opts.binary None + * @param {Date} opts._date None + * @param {Date} opts.dateTime None + * @param {String} opts.password None + * @param {String} opts.callback None + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + this.testEndpointParameters = function(_number, _double, patternWithoutDelimiter, _byte, opts) { + return this.testEndpointParametersWithHttpInfo(_number, _double, patternWithoutDelimiter, _byte, opts) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * To test enum parameters @@ -176,9 +216,9 @@ * @param {module:model/String} opts.enumQueryString Query parameter enum test (string) (default to -efg) * @param {Number} opts.enumQueryInteger Query parameter enum test (double) * @param {Number} opts.enumQueryDouble Query parameter enum test (double) - * @return {Promise} a {@link https://www.promisejs.org/|Promise} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ - this.testEnumParameters = function(opts) { + this.testEnumParametersWithHttpInfo = function(opts) { opts = opts || {}; var postBody = null; @@ -211,6 +251,27 @@ authNames, contentTypes, accepts, returnType ); } + + /** + * To test enum parameters + * To test enum parameters + * @param {Object} opts Optional parameters + * @param {Array.} opts.enumFormStringArray Form parameter enum test (string array) + * @param {module:model/String} opts.enumFormString Form parameter enum test (string) (default to -efg) + * @param {Array.} opts.enumHeaderStringArray Header parameter enum test (string array) + * @param {module:model/String} opts.enumHeaderString Header parameter enum test (string) (default to -efg) + * @param {Array.} opts.enumQueryStringArray Query parameter enum test (string array) + * @param {module:model/String} opts.enumQueryString Query parameter enum test (string) (default to -efg) + * @param {Number} opts.enumQueryInteger Query parameter enum test (double) + * @param {Number} opts.enumQueryDouble Query parameter enum test (double) + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + this.testEnumParameters = function(opts) { + return this.testEnumParametersWithHttpInfo(opts) + .then(function(response_and_data) { + return response_and_data.data; + }); + } }; return exports; diff --git a/samples/client/petstore/javascript-promise/src/api/PetApi.js b/samples/client/petstore/javascript-promise/src/api/PetApi.js index cb7005107a..c0e068ace2 100644 --- a/samples/client/petstore/javascript-promise/src/api/PetApi.js +++ b/samples/client/petstore/javascript-promise/src/api/PetApi.js @@ -50,13 +50,13 @@ * Add a new pet to the store * * @param {module:model/Pet} body Pet object that needs to be added to the store - * @return {Promise} a {@link https://www.promisejs.org/|Promise} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ - this.addPet = function(body) { + this.addPetWithHttpInfo = function(body) { var postBody = body; // verify the required parameter 'body' is set - if (body == undefined || body == null) { + if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling addPet"); } @@ -82,6 +82,19 @@ ); } + /** + * Add a new pet to the store + * + * @param {module:model/Pet} body Pet object that needs to be added to the store + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + this.addPet = function(body) { + return this.addPetWithHttpInfo(body) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * Deletes a pet @@ -89,14 +102,14 @@ * @param {Number} petId Pet id to delete * @param {Object} opts Optional parameters * @param {String} opts.apiKey - * @return {Promise} a {@link https://www.promisejs.org/|Promise} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ - this.deletePet = function(petId, opts) { + this.deletePetWithHttpInfo = function(petId, opts) { opts = opts || {}; var postBody = null; // verify the required parameter 'petId' is set - if (petId == undefined || petId == null) { + if (petId === undefined || petId === null) { throw new Error("Missing the required parameter 'petId' when calling deletePet"); } @@ -124,18 +137,33 @@ ); } + /** + * Deletes a pet + * + * @param {Number} petId Pet id to delete + * @param {Object} opts Optional parameters + * @param {String} opts.apiKey + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + this.deletePet = function(petId, opts) { + return this.deletePetWithHttpInfo(petId, opts) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * Finds Pets by status * Multiple status values can be provided with comma separated strings * @param {Array.} status Status values that need to be considered for filter - * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Array.} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Array.} and HTTP response */ - this.findPetsByStatus = function(status) { + this.findPetsByStatusWithHttpInfo = function(status) { var postBody = null; // verify the required parameter 'status' is set - if (status == undefined || status == null) { + if (status === undefined || status === null) { throw new Error("Missing the required parameter 'status' when calling findPetsByStatus"); } @@ -162,18 +190,31 @@ ); } + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param {Array.} status Status values that need to be considered for filter + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Array.} + */ + this.findPetsByStatus = function(status) { + return this.findPetsByStatusWithHttpInfo(status) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param {Array.} tags Tags to filter by - * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Array.} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Array.} and HTTP response */ - this.findPetsByTags = function(tags) { + this.findPetsByTagsWithHttpInfo = function(tags) { var postBody = null; // verify the required parameter 'tags' is set - if (tags == undefined || tags == null) { + if (tags === undefined || tags === null) { throw new Error("Missing the required parameter 'tags' when calling findPetsByTags"); } @@ -200,18 +241,31 @@ ); } + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param {Array.} tags Tags to filter by + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Array.} + */ + this.findPetsByTags = function(tags) { + return this.findPetsByTagsWithHttpInfo(tags) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * Find pet by ID * Returns a single pet * @param {Number} petId ID of pet to return - * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/Pet} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/Pet} and HTTP response */ - this.getPetById = function(petId) { + this.getPetByIdWithHttpInfo = function(petId) { var postBody = null; // verify the required parameter 'petId' is set - if (petId == undefined || petId == null) { + if (petId === undefined || petId === null) { throw new Error("Missing the required parameter 'petId' when calling getPetById"); } @@ -238,18 +292,31 @@ ); } + /** + * Find pet by ID + * Returns a single pet + * @param {Number} petId ID of pet to return + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/Pet} + */ + this.getPetById = function(petId) { + return this.getPetByIdWithHttpInfo(petId) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * Update an existing pet * * @param {module:model/Pet} body Pet object that needs to be added to the store - * @return {Promise} a {@link https://www.promisejs.org/|Promise} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ - this.updatePet = function(body) { + this.updatePetWithHttpInfo = function(body) { var postBody = body; // verify the required parameter 'body' is set - if (body == undefined || body == null) { + if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling updatePet"); } @@ -275,6 +342,19 @@ ); } + /** + * Update an existing pet + * + * @param {module:model/Pet} body Pet object that needs to be added to the store + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + this.updatePet = function(body) { + return this.updatePetWithHttpInfo(body) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * Updates a pet in the store with form data @@ -283,14 +363,14 @@ * @param {Object} opts Optional parameters * @param {String} opts.name Updated name of the pet * @param {String} opts.status Updated status of the pet - * @return {Promise} a {@link https://www.promisejs.org/|Promise} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ - this.updatePetWithForm = function(petId, opts) { + this.updatePetWithFormWithHttpInfo = function(petId, opts) { opts = opts || {}; var postBody = null; // verify the required parameter 'petId' is set - if (petId == undefined || petId == null) { + if (petId === undefined || petId === null) { throw new Error("Missing the required parameter 'petId' when calling updatePetWithForm"); } @@ -319,6 +399,22 @@ ); } + /** + * Updates a pet in the store with form data + * + * @param {Number} petId ID of pet that needs to be updated + * @param {Object} opts Optional parameters + * @param {String} opts.name Updated name of the pet + * @param {String} opts.status Updated status of the pet + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + this.updatePetWithForm = function(petId, opts) { + return this.updatePetWithFormWithHttpInfo(petId, opts) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * uploads an image @@ -327,14 +423,14 @@ * @param {Object} opts Optional parameters * @param {String} opts.additionalMetadata Additional data to pass to server * @param {File} opts.file file to upload - * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ApiResponse} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ApiResponse} and HTTP response */ - this.uploadFile = function(petId, opts) { + this.uploadFileWithHttpInfo = function(petId, opts) { opts = opts || {}; var postBody = null; // verify the required parameter 'petId' is set - if (petId == undefined || petId == null) { + if (petId === undefined || petId === null) { throw new Error("Missing the required parameter 'petId' when calling uploadFile"); } @@ -362,6 +458,22 @@ authNames, contentTypes, accepts, returnType ); } + + /** + * uploads an image + * + * @param {Number} petId ID of pet to update + * @param {Object} opts Optional parameters + * @param {String} opts.additionalMetadata Additional data to pass to server + * @param {File} opts.file file to upload + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ApiResponse} + */ + this.uploadFile = function(petId, opts) { + return this.uploadFileWithHttpInfo(petId, opts) + .then(function(response_and_data) { + return response_and_data.data; + }); + } }; return exports; diff --git a/samples/client/petstore/javascript-promise/src/api/StoreApi.js b/samples/client/petstore/javascript-promise/src/api/StoreApi.js index b652284257..987f5c0bdb 100644 --- a/samples/client/petstore/javascript-promise/src/api/StoreApi.js +++ b/samples/client/petstore/javascript-promise/src/api/StoreApi.js @@ -50,13 +50,13 @@ * Delete purchase order by ID * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param {String} orderId ID of the order that needs to be deleted - * @return {Promise} a {@link https://www.promisejs.org/|Promise} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ - this.deleteOrder = function(orderId) { + this.deleteOrderWithHttpInfo = function(orderId) { var postBody = null; // verify the required parameter 'orderId' is set - if (orderId == undefined || orderId == null) { + if (orderId === undefined || orderId === null) { throw new Error("Missing the required parameter 'orderId' when calling deleteOrder"); } @@ -83,13 +83,26 @@ ); } + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param {String} orderId ID of the order that needs to be deleted + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + this.deleteOrder = function(orderId) { + return this.deleteOrderWithHttpInfo(orderId) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * Returns pet inventories by status * Returns a map of status codes to quantities - * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object.} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object.} and HTTP response */ - this.getInventory = function() { + this.getInventoryWithHttpInfo = function() { var postBody = null; @@ -114,18 +127,30 @@ ); } + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object.} + */ + this.getInventory = function() { + return this.getInventoryWithHttpInfo() + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param {Number} orderId ID of pet that needs to be fetched - * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/Order} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/Order} and HTTP response */ - this.getOrderById = function(orderId) { + this.getOrderByIdWithHttpInfo = function(orderId) { var postBody = null; // verify the required parameter 'orderId' is set - if (orderId == undefined || orderId == null) { + if (orderId === undefined || orderId === null) { throw new Error("Missing the required parameter 'orderId' when calling getOrderById"); } @@ -152,18 +177,31 @@ ); } + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @param {Number} orderId ID of pet that needs to be fetched + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/Order} + */ + this.getOrderById = function(orderId) { + return this.getOrderByIdWithHttpInfo(orderId) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * Place an order for a pet * * @param {module:model/Order} body order placed for purchasing the pet - * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/Order} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/Order} and HTTP response */ - this.placeOrder = function(body) { + this.placeOrderWithHttpInfo = function(body) { var postBody = body; // verify the required parameter 'body' is set - if (body == undefined || body == null) { + if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling placeOrder"); } @@ -188,6 +226,19 @@ authNames, contentTypes, accepts, returnType ); } + + /** + * Place an order for a pet + * + * @param {module:model/Order} body order placed for purchasing the pet + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/Order} + */ + this.placeOrder = function(body) { + return this.placeOrderWithHttpInfo(body) + .then(function(response_and_data) { + return response_and_data.data; + }); + } }; return exports; diff --git a/samples/client/petstore/javascript-promise/src/api/UserApi.js b/samples/client/petstore/javascript-promise/src/api/UserApi.js index db2af27a90..c36b5186a1 100644 --- a/samples/client/petstore/javascript-promise/src/api/UserApi.js +++ b/samples/client/petstore/javascript-promise/src/api/UserApi.js @@ -50,13 +50,13 @@ * Create user * This can only be done by the logged in user. * @param {module:model/User} body Created user object - * @return {Promise} a {@link https://www.promisejs.org/|Promise} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ - this.createUser = function(body) { + this.createUserWithHttpInfo = function(body) { var postBody = body; // verify the required parameter 'body' is set - if (body == undefined || body == null) { + if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling createUser"); } @@ -82,18 +82,31 @@ ); } + /** + * Create user + * This can only be done by the logged in user. + * @param {module:model/User} body Created user object + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + this.createUser = function(body) { + return this.createUserWithHttpInfo(body) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * Creates list of users with given input array * * @param {Array.} body List of user object - * @return {Promise} a {@link https://www.promisejs.org/|Promise} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ - this.createUsersWithArrayInput = function(body) { + this.createUsersWithArrayInputWithHttpInfo = function(body) { var postBody = body; // verify the required parameter 'body' is set - if (body == undefined || body == null) { + if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling createUsersWithArrayInput"); } @@ -119,18 +132,31 @@ ); } - /** * Creates list of users with given input array * * @param {Array.} body List of user object * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ - this.createUsersWithListInput = function(body) { + this.createUsersWithArrayInput = function(body) { + return this.createUsersWithArrayInputWithHttpInfo(body) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + + + /** + * Creates list of users with given input array + * + * @param {Array.} body List of user object + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response + */ + this.createUsersWithListInputWithHttpInfo = function(body) { var postBody = body; // verify the required parameter 'body' is set - if (body == undefined || body == null) { + if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling createUsersWithListInput"); } @@ -156,18 +182,31 @@ ); } + /** + * Creates list of users with given input array + * + * @param {Array.} body List of user object + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + this.createUsersWithListInput = function(body) { + return this.createUsersWithListInputWithHttpInfo(body) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * Delete user * This can only be done by the logged in user. * @param {String} username The name that needs to be deleted - * @return {Promise} a {@link https://www.promisejs.org/|Promise} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ - this.deleteUser = function(username) { + this.deleteUserWithHttpInfo = function(username) { var postBody = null; // verify the required parameter 'username' is set - if (username == undefined || username == null) { + if (username === undefined || username === null) { throw new Error("Missing the required parameter 'username' when calling deleteUser"); } @@ -194,18 +233,31 @@ ); } + /** + * Delete user + * This can only be done by the logged in user. + * @param {String} username The name that needs to be deleted + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + this.deleteUser = function(username) { + return this.deleteUserWithHttpInfo(username) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * Get user by user name * * @param {String} username The name that needs to be fetched. Use user1 for testing. - * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/User} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/User} and HTTP response */ - this.getUserByName = function(username) { + this.getUserByNameWithHttpInfo = function(username) { var postBody = null; // verify the required parameter 'username' is set - if (username == undefined || username == null) { + if (username === undefined || username === null) { throw new Error("Missing the required parameter 'username' when calling getUserByName"); } @@ -232,24 +284,37 @@ ); } + /** + * Get user by user name + * + * @param {String} username The name that needs to be fetched. Use user1 for testing. + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/User} + */ + this.getUserByName = function(username) { + return this.getUserByNameWithHttpInfo(username) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * Logs user into the system * * @param {String} username The user name for login * @param {String} password The password for login in clear text - * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link 'String'} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link 'String'} and HTTP response */ - this.loginUser = function(username, password) { + this.loginUserWithHttpInfo = function(username, password) { var postBody = null; // verify the required parameter 'username' is set - if (username == undefined || username == null) { + if (username === undefined || username === null) { throw new Error("Missing the required parameter 'username' when calling loginUser"); } // verify the required parameter 'password' is set - if (password == undefined || password == null) { + if (password === undefined || password === null) { throw new Error("Missing the required parameter 'password' when calling loginUser"); } @@ -277,13 +342,27 @@ ); } + /** + * Logs user into the system + * + * @param {String} username The user name for login + * @param {String} password The password for login in clear text + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link 'String'} + */ + this.loginUser = function(username, password) { + return this.loginUserWithHttpInfo(username, password) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * Logs out current logged in user session * - * @return {Promise} a {@link https://www.promisejs.org/|Promise} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ - this.logoutUser = function() { + this.logoutUserWithHttpInfo = function() { var postBody = null; @@ -308,24 +387,36 @@ ); } + /** + * Logs out current logged in user session + * + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + this.logoutUser = function() { + return this.logoutUserWithHttpInfo() + .then(function(response_and_data) { + return response_and_data.data; + }); + } + /** * Updated user * This can only be done by the logged in user. * @param {String} username name that need to be deleted * @param {module:model/User} body Updated user object - * @return {Promise} a {@link https://www.promisejs.org/|Promise} + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ - this.updateUser = function(username, body) { + this.updateUserWithHttpInfo = function(username, body) { var postBody = body; // verify the required parameter 'username' is set - if (username == undefined || username == null) { + if (username === undefined || username === null) { throw new Error("Missing the required parameter 'username' when calling updateUser"); } // verify the required parameter 'body' is set - if (body == undefined || body == null) { + if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling updateUser"); } @@ -351,6 +442,20 @@ authNames, contentTypes, accepts, returnType ); } + + /** + * Updated user + * This can only be done by the logged in user. + * @param {String} username name that need to be deleted + * @param {module:model/User} body Updated user object + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + this.updateUser = function(username, body) { + return this.updateUserWithHttpInfo(username, body) + .then(function(response_and_data) { + return response_and_data.data; + }); + } }; return exports; diff --git a/samples/client/petstore/javascript/src/api/FakeApi.js b/samples/client/petstore/javascript/src/api/FakeApi.js index c9f0fbdbf0..9a64ccfc0a 100644 --- a/samples/client/petstore/javascript/src/api/FakeApi.js +++ b/samples/client/petstore/javascript/src/api/FakeApi.js @@ -64,7 +64,7 @@ var postBody = body; // verify the required parameter 'body' is set - if (body == undefined || body == null) { + if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling testClientModel"); } @@ -123,22 +123,22 @@ var postBody = null; // verify the required parameter '_number' is set - if (_number == undefined || _number == null) { + if (_number === undefined || _number === null) { throw new Error("Missing the required parameter '_number' when calling testEndpointParameters"); } // verify the required parameter '_double' is set - if (_double == undefined || _double == null) { + if (_double === undefined || _double === null) { throw new Error("Missing the required parameter '_double' when calling testEndpointParameters"); } // verify the required parameter 'patternWithoutDelimiter' is set - if (patternWithoutDelimiter == undefined || patternWithoutDelimiter == null) { + if (patternWithoutDelimiter === undefined || patternWithoutDelimiter === null) { throw new Error("Missing the required parameter 'patternWithoutDelimiter' when calling testEndpointParameters"); } // verify the required parameter '_byte' is set - if (_byte == undefined || _byte == null) { + if (_byte === undefined || _byte === null) { throw new Error("Missing the required parameter '_byte' when calling testEndpointParameters"); } diff --git a/samples/client/petstore/javascript/src/api/PetApi.js b/samples/client/petstore/javascript/src/api/PetApi.js index 16203fcb4b..4944965b39 100644 --- a/samples/client/petstore/javascript/src/api/PetApi.js +++ b/samples/client/petstore/javascript/src/api/PetApi.js @@ -63,7 +63,7 @@ var postBody = body; // verify the required parameter 'body' is set - if (body == undefined || body == null) { + if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling addPet"); } @@ -110,7 +110,7 @@ var postBody = null; // verify the required parameter 'petId' is set - if (petId == undefined || petId == null) { + if (petId === undefined || petId === null) { throw new Error("Missing the required parameter 'petId' when calling deletePet"); } @@ -157,7 +157,7 @@ var postBody = null; // verify the required parameter 'status' is set - if (status == undefined || status == null) { + if (status === undefined || status === null) { throw new Error("Missing the required parameter 'status' when calling findPetsByStatus"); } @@ -203,7 +203,7 @@ var postBody = null; // verify the required parameter 'tags' is set - if (tags == undefined || tags == null) { + if (tags === undefined || tags === null) { throw new Error("Missing the required parameter 'tags' when calling findPetsByTags"); } @@ -249,7 +249,7 @@ var postBody = null; // verify the required parameter 'petId' is set - if (petId == undefined || petId == null) { + if (petId === undefined || petId === null) { throw new Error("Missing the required parameter 'petId' when calling getPetById"); } @@ -294,7 +294,7 @@ var postBody = body; // verify the required parameter 'body' is set - if (body == undefined || body == null) { + if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling updatePet"); } @@ -342,7 +342,7 @@ var postBody = null; // verify the required parameter 'petId' is set - if (petId == undefined || petId == null) { + if (petId === undefined || petId === null) { throw new Error("Missing the required parameter 'petId' when calling updatePetWithForm"); } @@ -394,7 +394,7 @@ var postBody = null; // verify the required parameter 'petId' is set - if (petId == undefined || petId == null) { + if (petId === undefined || petId === null) { throw new Error("Missing the required parameter 'petId' when calling uploadFile"); } diff --git a/samples/client/petstore/javascript/src/api/StoreApi.js b/samples/client/petstore/javascript/src/api/StoreApi.js index 7219f4db4e..36cc93dc02 100644 --- a/samples/client/petstore/javascript/src/api/StoreApi.js +++ b/samples/client/petstore/javascript/src/api/StoreApi.js @@ -63,7 +63,7 @@ var postBody = null; // verify the required parameter 'orderId' is set - if (orderId == undefined || orderId == null) { + if (orderId === undefined || orderId === null) { throw new Error("Missing the required parameter 'orderId' when calling deleteOrder"); } @@ -148,7 +148,7 @@ var postBody = null; // verify the required parameter 'orderId' is set - if (orderId == undefined || orderId == null) { + if (orderId === undefined || orderId === null) { throw new Error("Missing the required parameter 'orderId' when calling getOrderById"); } @@ -194,7 +194,7 @@ var postBody = body; // verify the required parameter 'body' is set - if (body == undefined || body == null) { + if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling placeOrder"); } diff --git a/samples/client/petstore/javascript/src/api/UserApi.js b/samples/client/petstore/javascript/src/api/UserApi.js index 76d3768dea..6264689ca1 100644 --- a/samples/client/petstore/javascript/src/api/UserApi.js +++ b/samples/client/petstore/javascript/src/api/UserApi.js @@ -63,7 +63,7 @@ var postBody = body; // verify the required parameter 'body' is set - if (body == undefined || body == null) { + if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling createUser"); } @@ -107,7 +107,7 @@ var postBody = body; // verify the required parameter 'body' is set - if (body == undefined || body == null) { + if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling createUsersWithArrayInput"); } @@ -151,7 +151,7 @@ var postBody = body; // verify the required parameter 'body' is set - if (body == undefined || body == null) { + if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling createUsersWithListInput"); } @@ -195,7 +195,7 @@ var postBody = null; // verify the required parameter 'username' is set - if (username == undefined || username == null) { + if (username === undefined || username === null) { throw new Error("Missing the required parameter 'username' when calling deleteUser"); } @@ -241,7 +241,7 @@ var postBody = null; // verify the required parameter 'username' is set - if (username == undefined || username == null) { + if (username === undefined || username === null) { throw new Error("Missing the required parameter 'username' when calling getUserByName"); } @@ -288,12 +288,12 @@ var postBody = null; // verify the required parameter 'username' is set - if (username == undefined || username == null) { + if (username === undefined || username === null) { throw new Error("Missing the required parameter 'username' when calling loginUser"); } // verify the required parameter 'password' is set - if (password == undefined || password == null) { + if (password === undefined || password === null) { throw new Error("Missing the required parameter 'password' when calling loginUser"); } @@ -378,12 +378,12 @@ var postBody = body; // verify the required parameter 'username' is set - if (username == undefined || username == null) { + if (username === undefined || username === null) { throw new Error("Missing the required parameter 'username' when calling updateUser"); } // verify the required parameter 'body' is set - if (body == undefined || body == null) { + if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling updateUser"); }