From 067d0a93183e16f46a56cabbe865872075d2f1c5 Mon Sep 17 00:00:00 2001 From: delenius Date: Tue, 1 Mar 2016 07:41:31 -0800 Subject: [PATCH] Remove toJson method from JS client Also regenerates the petstore samples. --- .../main/resources/Javascript/model.mustache | 4 --- .../javascript-promise/src/ApiClient.js | 8 +++++ .../javascript-promise/src/api/PetApi.js | 8 ++--- .../javascript-promise/src/api/StoreApi.js | 34 +++++++++++++++++++ .../javascript-promise/src/model/Category.js | 4 --- .../javascript-promise/src/model/Order.js | 4 --- .../javascript-promise/src/model/Pet.js | 4 --- .../javascript-promise/src/model/Tag.js | 4 --- .../javascript-promise/src/model/User.js | 4 --- .../petstore/javascript/src/ApiClient.js | 8 ++--- .../petstore/javascript/src/api/PetApi.js | 4 +-- .../petstore/javascript/src/api/StoreApi.js | 2 +- .../client/petstore/javascript/src/index.js | 14 ++++---- .../petstore/javascript/src/model/Category.js | 4 --- .../petstore/javascript/src/model/Order.js | 4 --- .../petstore/javascript/src/model/Pet.js | 4 --- .../petstore/javascript/src/model/Tag.js | 4 --- .../petstore/javascript/src/model/User.js | 4 --- 18 files changed, 60 insertions(+), 62 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Javascript/model.mustache b/modules/swagger-codegen/src/main/resources/Javascript/model.mustache index 1f0f48226a7..068a42c8d4c 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/model.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/model.mustache @@ -73,10 +73,6 @@ {{/vars}} {{/omitModelMethods}} - {{classname}}.prototype.toJson = function() { - return JSON.stringify(this); - } - {{#vars}}{{#isEnum}}{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}} {{>enumClass}}{{/items}}*/{{/items.isEnum}}{{/vars}} diff --git a/samples/client/petstore/javascript-promise/src/ApiClient.js b/samples/client/petstore/javascript-promise/src/ApiClient.js index a0c70eb10ee..e2ab48cf09c 100644 --- a/samples/client/petstore/javascript-promise/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise/src/ApiClient.js @@ -34,6 +34,11 @@ * The default HTTP headers to be included for all API calls. */ this.defaultHeaders = {}; + + /** + * The default HTTP timeout for all API calls. + */ + this.timeout = 60000; }; ApiClient.prototype.paramToString = function paramToString(param) { @@ -234,6 +239,9 @@ // set header parameters request.set(this.defaultHeaders).set(this.normalizeParams(headerParams)); + //set request timeout + request.timeout(this.timeout); + var contentType = this.jsonPreferredMime(contentTypes); if (contentType) { request.type(contentType); diff --git a/samples/client/petstore/javascript-promise/src/api/PetApi.js b/samples/client/petstore/javascript-promise/src/api/PetApi.js index b9dd09d6d9f..044413ab544 100644 --- a/samples/client/petstore/javascript-promise/src/api/PetApi.js +++ b/samples/client/petstore/javascript-promise/src/api/PetApi.js @@ -87,8 +87,8 @@ /** * Finds Pets by status - * Multiple status values can be provided with comma seperated strings - * @param {[String]} opts['status'] Status values that need to be considered for filter + * Multiple status values can be provided with comma separated strings + * @param {[String]} opts['status'] Status values that need to be considered for query * data is of type: [Pet] */ self.findPetsByStatus = function(opts) { @@ -321,12 +321,12 @@ * @param {Integer} petId ID of pet that needs to be fetched * data is of type: 'String' */ - self.getPetByIdWithByteArray = function(petId) { + self.petPetIdtestingByteArraytrueGet = function(petId) { var postBody = null; // verify the required parameter 'petId' is set if (petId == null) { - throw "Missing the required parameter 'petId' when calling getPetByIdWithByteArray"; + throw "Missing the required parameter 'petId' when calling petPetIdtestingByteArraytrueGet"; } diff --git a/samples/client/petstore/javascript-promise/src/api/StoreApi.js b/samples/client/petstore/javascript-promise/src/api/StoreApi.js index d47898d7495..1919aacef5f 100644 --- a/samples/client/petstore/javascript-promise/src/api/StoreApi.js +++ b/samples/client/petstore/javascript-promise/src/api/StoreApi.js @@ -21,6 +21,40 @@ var self = this; + /** + * Finds orders by status + * A single status value can be provided as a string + * @param {String} opts['status'] Status value that needs to be considered for query + * data is of type: [Order] + */ + self.findOrdersByStatus = function(opts) { + opts = opts || {}; + var postBody = null; + + + var pathParams = { + }; + var queryParams = { + 'status': opts['status'] + }; + var headerParams = { + }; + var formParams = { + }; + + var authNames = ['test_api_client_id', 'test_api_client_secret']; + var contentTypes = []; + var accepts = ['application/json', 'application/xml']; + var returnType = [Order]; + + return this.apiClient.callApi( + '/store/findByStatus', 'GET', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType + ); + + } + /** * Returns pet inventories by status * Returns a map of status codes to quantities diff --git a/samples/client/petstore/javascript-promise/src/model/Category.js b/samples/client/petstore/javascript-promise/src/model/Category.js index 7de066c5928..729a22b9e04 100644 --- a/samples/client/petstore/javascript-promise/src/model/Category.js +++ b/samples/client/petstore/javascript-promise/src/model/Category.js @@ -69,10 +69,6 @@ - Category.prototype.toJson = function() { - return JSON.stringify(this); - } - if (module) { diff --git a/samples/client/petstore/javascript-promise/src/model/Order.js b/samples/client/petstore/javascript-promise/src/model/Order.js index 575064ebc89..4d2e4625d90 100644 --- a/samples/client/petstore/javascript-promise/src/model/Order.js +++ b/samples/client/petstore/javascript-promise/src/model/Order.js @@ -143,10 +143,6 @@ - Order.prototype.toJson = function() { - return JSON.stringify(this); - } - var StatusEnum = { /** diff --git a/samples/client/petstore/javascript-promise/src/model/Pet.js b/samples/client/petstore/javascript-promise/src/model/Pet.js index 3b8bdeef123..d751182c303 100644 --- a/samples/client/petstore/javascript-promise/src/model/Pet.js +++ b/samples/client/petstore/javascript-promise/src/model/Pet.js @@ -153,10 +153,6 @@ - Pet.prototype.toJson = function() { - return JSON.stringify(this); - } - var StatusEnum = { /** diff --git a/samples/client/petstore/javascript-promise/src/model/Tag.js b/samples/client/petstore/javascript-promise/src/model/Tag.js index dd0e9c38ea0..fbd43adb7e0 100644 --- a/samples/client/petstore/javascript-promise/src/model/Tag.js +++ b/samples/client/petstore/javascript-promise/src/model/Tag.js @@ -69,10 +69,6 @@ - Tag.prototype.toJson = function() { - return JSON.stringify(this); - } - if (module) { diff --git a/samples/client/petstore/javascript-promise/src/model/User.js b/samples/client/petstore/javascript-promise/src/model/User.js index 976395c5a62..2f6c9863ef8 100644 --- a/samples/client/petstore/javascript-promise/src/model/User.js +++ b/samples/client/petstore/javascript-promise/src/model/User.js @@ -179,10 +179,6 @@ - User.prototype.toJson = function() { - return JSON.stringify(this); - } - if (module) { diff --git a/samples/client/petstore/javascript/src/ApiClient.js b/samples/client/petstore/javascript/src/ApiClient.js index 304cac7e68d..b1492ceb28f 100644 --- a/samples/client/petstore/javascript/src/ApiClient.js +++ b/samples/client/petstore/javascript/src/ApiClient.js @@ -22,12 +22,12 @@ this.basePath = 'http://petstore.swagger.io/v2'.replace(/\/+$/, ''); this.authentications = { - 'test_api_key_header': {type: 'apiKey', in: 'header', name: 'test_api_key_header'}, - 'api_key': {type: 'apiKey', in: 'header', name: 'api_key'}, - 'test_api_client_secret': {type: 'apiKey', in: 'header', name: 'x-test_api_client_secret'}, + 'petstore_auth': {type: 'oauth2'}, 'test_api_client_id': {type: 'apiKey', in: 'header', name: 'x-test_api_client_id'}, + 'test_api_client_secret': {type: 'apiKey', in: 'header', name: 'x-test_api_client_secret'}, + 'api_key': {type: 'apiKey', in: 'header', name: 'api_key'}, 'test_api_key_query': {type: 'apiKey', in: 'query', name: 'test_api_key_query'}, - 'petstore_auth': {type: 'oauth2'} + 'test_api_key_header': {type: 'apiKey', in: 'header', name: 'test_api_key_header'} }; /** diff --git a/samples/client/petstore/javascript/src/api/PetApi.js b/samples/client/petstore/javascript/src/api/PetApi.js index 88f53633fce..e2221bd2621 100644 --- a/samples/client/petstore/javascript/src/api/PetApi.js +++ b/samples/client/petstore/javascript/src/api/PetApi.js @@ -183,7 +183,7 @@ var formParams = { }; - var authNames = ['api_key', 'petstore_auth']; + var authNames = ['petstore_auth', 'api_key']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = Pet; @@ -349,7 +349,7 @@ var formParams = { }; - var authNames = ['api_key', 'petstore_auth']; + var authNames = ['petstore_auth', 'api_key']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = 'String'; diff --git a/samples/client/petstore/javascript/src/api/StoreApi.js b/samples/client/petstore/javascript/src/api/StoreApi.js index 0f30f8776fc..46fd1f3e456 100644 --- a/samples/client/petstore/javascript/src/api/StoreApi.js +++ b/samples/client/petstore/javascript/src/api/StoreApi.js @@ -148,7 +148,7 @@ var formParams = { }; - var authNames = ['test_api_key_header', 'test_api_key_query']; + var authNames = ['test_api_key_query', 'test_api_key_header']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = Order; diff --git a/samples/client/petstore/javascript/src/index.js b/samples/client/petstore/javascript/src/index.js index 8b77f995df4..dcf02fc1547 100644 --- a/samples/client/petstore/javascript/src/index.js +++ b/samples/client/petstore/javascript/src/index.js @@ -1,23 +1,23 @@ (function(factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['./ApiClient', './model/User', './model/Category', './model/Pet', './model/Tag', './model/Order', './api/UserApi', './api/PetApi', './api/StoreApi'], factory); + define(['./ApiClient', './model/Order', './model/User', './model/Category', './model/Tag', './model/Pet', './api/UserApi', './api/StoreApi', './api/PetApi'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('./ApiClient'), require('./model/User'), require('./model/Category'), require('./model/Pet'), require('./model/Tag'), require('./model/Order'), require('./api/UserApi'), require('./api/PetApi'), require('./api/StoreApi')); + module.exports = factory(require('./ApiClient'), require('./model/Order'), require('./model/User'), require('./model/Category'), require('./model/Tag'), require('./model/Pet'), require('./api/UserApi'), require('./api/StoreApi'), require('./api/PetApi')); } -}(function(ApiClient, User, Category, Pet, Tag, Order, UserApi, PetApi, StoreApi) { +}(function(ApiClient, Order, User, Category, Tag, Pet, UserApi, StoreApi, PetApi) { 'use strict'; return { ApiClient: ApiClient, + Order: Order, User: User, Category: Category, - Pet: Pet, Tag: Tag, - Order: Order, + Pet: Pet, UserApi: UserApi, - PetApi: PetApi, - StoreApi: StoreApi + StoreApi: StoreApi, + PetApi: PetApi }; })); diff --git a/samples/client/petstore/javascript/src/model/Category.js b/samples/client/petstore/javascript/src/model/Category.js index 7de066c5928..729a22b9e04 100644 --- a/samples/client/petstore/javascript/src/model/Category.js +++ b/samples/client/petstore/javascript/src/model/Category.js @@ -69,10 +69,6 @@ - Category.prototype.toJson = function() { - return JSON.stringify(this); - } - if (module) { diff --git a/samples/client/petstore/javascript/src/model/Order.js b/samples/client/petstore/javascript/src/model/Order.js index 575064ebc89..4d2e4625d90 100644 --- a/samples/client/petstore/javascript/src/model/Order.js +++ b/samples/client/petstore/javascript/src/model/Order.js @@ -143,10 +143,6 @@ - Order.prototype.toJson = function() { - return JSON.stringify(this); - } - var StatusEnum = { /** diff --git a/samples/client/petstore/javascript/src/model/Pet.js b/samples/client/petstore/javascript/src/model/Pet.js index 3b8bdeef123..d751182c303 100644 --- a/samples/client/petstore/javascript/src/model/Pet.js +++ b/samples/client/petstore/javascript/src/model/Pet.js @@ -153,10 +153,6 @@ - Pet.prototype.toJson = function() { - return JSON.stringify(this); - } - var StatusEnum = { /** diff --git a/samples/client/petstore/javascript/src/model/Tag.js b/samples/client/petstore/javascript/src/model/Tag.js index dd0e9c38ea0..fbd43adb7e0 100644 --- a/samples/client/petstore/javascript/src/model/Tag.js +++ b/samples/client/petstore/javascript/src/model/Tag.js @@ -69,10 +69,6 @@ - Tag.prototype.toJson = function() { - return JSON.stringify(this); - } - if (module) { diff --git a/samples/client/petstore/javascript/src/model/User.js b/samples/client/petstore/javascript/src/model/User.js index 976395c5a62..2f6c9863ef8 100644 --- a/samples/client/petstore/javascript/src/model/User.js +++ b/samples/client/petstore/javascript/src/model/User.js @@ -179,10 +179,6 @@ - User.prototype.toJson = function() { - return JSON.stringify(this); - } - if (module) {