diff --git a/samples/client/petstore/javascript-promise/README.md b/samples/client/petstore/javascript-promise/README.md
index e181365bd60..2c2f6f169b6 100644
--- a/samples/client/petstore/javascript-promise/README.md
+++ b/samples/client/petstore/javascript-promise/README.md
@@ -6,7 +6,7 @@ Version: 1.0.0
Automatically generated by the JavaScript Swagger Codegen project:
-- Build date: 2016-03-17T16:01:50.137+08:00
+- Build date: 2016-03-18T15:44:17.513Z
- Build package: class io.swagger.codegen.languages.JavascriptClientCodegen
## Installation
@@ -116,25 +116,10 @@ Class | Method | HTTP request | Description
## Documentation for Authorization
-### petstore_auth
-
-- **Type**: OAuth
-- **Flow**: implicit
-- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog
-- **Scopes**:
- - write:pets: modify pets in your account
- - read:pets: read your pets
-
-### test_api_client_id
+### test_api_key_header
- **Type**: API key
-- **API key parameter name**: x-test_api_client_id
-- **Location**: HTTP header
-
-### test_api_client_secret
-
-- **Type**: API key
-- **API key parameter name**: x-test_api_client_secret
+- **API key parameter name**: test_api_key_header
- **Location**: HTTP header
### api_key
@@ -147,15 +132,30 @@ Class | Method | HTTP request | Description
- **Type**: HTTP basic authentication
+### test_api_client_secret
+
+- **Type**: API key
+- **API key parameter name**: x-test_api_client_secret
+- **Location**: HTTP header
+
+### test_api_client_id
+
+- **Type**: API key
+- **API key parameter name**: x-test_api_client_id
+- **Location**: HTTP header
+
### test_api_key_query
- **Type**: API key
- **API key parameter name**: test_api_key_query
- **Location**: URL query string
-### test_api_key_header
+### petstore_auth
-- **Type**: API key
-- **API key parameter name**: test_api_key_header
-- **Location**: HTTP header
+- **Type**: OAuth
+- **Flow**: implicit
+- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog
+- **Scopes**:
+ - write:pets: modify pets in your account
+ - read:pets: read your pets
diff --git a/samples/client/petstore/javascript-promise/docs/InlineResponse200.md b/samples/client/petstore/javascript-promise/docs/InlineResponse200.md
index 09b88b74e49..66a4605e2c4 100644
--- a/samples/client/petstore/javascript-promise/docs/InlineResponse200.md
+++ b/samples/client/petstore/javascript-promise/docs/InlineResponse200.md
@@ -1,13 +1,14 @@
+
# SwaggerPetstore.InlineResponse200
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
-**photoUrls** | **[String]** | | [optional]
-**name** | **String** | | [optional]
+**tags** | [**[Tag]**](Tag.md) | | [optional]
**id** | **Integer** | |
**category** | **Object** | | [optional]
-**tags** | [**[Tag]**](Tag.md) | | [optional]
**status** | **String** | pet status in the store | [optional]
+**name** | **String** | | [optional]
+**photoUrls** | **[String]** | | [optional]
diff --git a/samples/client/petstore/javascript-promise/docs/PetApi.md b/samples/client/petstore/javascript-promise/docs/PetApi.md
index b152d6ff78d..9e14ea0c815 100644
--- a/samples/client/petstore/javascript-promise/docs/PetApi.md
+++ b/samples/client/petstore/javascript-promise/docs/PetApi.md
@@ -1,3 +1,4 @@
+
# SwaggerPetstore.PetApi
All URIs are relative to *http://petstore.swagger.io/v2*
@@ -278,16 +279,16 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
-// Configure OAuth2 access token for authorization: petstore_auth
-var petstore_auth = defaultClient.authentications['petstore_auth'];
-petstore_auth.accessToken = "YOUR ACCESS TOKEN"
-
// Configure API key authorization: api_key
var api_key = defaultClient.authentications['api_key'];
api_key.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.apiKeyPrefix['api_key'] = "Token"
+// Configure OAuth2 access token for authorization: petstore_auth
+var petstore_auth = defaultClient.authentications['petstore_auth'];
+petstore_auth.accessToken = "YOUR ACCESS TOKEN"
+
var api = new SwaggerPetstore.PetApi()
var petId = 789; // {Integer} ID of pet that needs to be fetched
@@ -312,7 +313,7 @@ Name | Type | Description | Notes
### Authorization
-[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
+[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
### HTTP reuqest headers
@@ -332,16 +333,16 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
-// Configure OAuth2 access token for authorization: petstore_auth
-var petstore_auth = defaultClient.authentications['petstore_auth'];
-petstore_auth.accessToken = "YOUR ACCESS TOKEN"
-
// Configure API key authorization: api_key
var api_key = defaultClient.authentications['api_key'];
api_key.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.apiKeyPrefix['api_key'] = "Token"
+// Configure OAuth2 access token for authorization: petstore_auth
+var petstore_auth = defaultClient.authentications['petstore_auth'];
+petstore_auth.accessToken = "YOUR ACCESS TOKEN"
+
var api = new SwaggerPetstore.PetApi()
var petId = 789; // {Integer} ID of pet that needs to be fetched
@@ -366,7 +367,7 @@ Name | Type | Description | Notes
### Authorization
-[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
+[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
### HTTP reuqest headers
@@ -386,16 +387,16 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
-// Configure OAuth2 access token for authorization: petstore_auth
-var petstore_auth = defaultClient.authentications['petstore_auth'];
-petstore_auth.accessToken = "YOUR ACCESS TOKEN"
-
// Configure API key authorization: api_key
var api_key = defaultClient.authentications['api_key'];
api_key.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.apiKeyPrefix['api_key'] = "Token"
+// Configure OAuth2 access token for authorization: petstore_auth
+var petstore_auth = defaultClient.authentications['petstore_auth'];
+petstore_auth.accessToken = "YOUR ACCESS TOKEN"
+
var api = new SwaggerPetstore.PetApi()
var petId = 789; // {Integer} ID of pet that needs to be fetched
@@ -420,7 +421,7 @@ Name | Type | Description | Notes
### Authorization
-[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
+[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
### HTTP reuqest headers
diff --git a/samples/client/petstore/javascript-promise/docs/StoreApi.md b/samples/client/petstore/javascript-promise/docs/StoreApi.md
index 91aa8d66973..53e4ffd5bc2 100644
--- a/samples/client/petstore/javascript-promise/docs/StoreApi.md
+++ b/samples/client/petstore/javascript-promise/docs/StoreApi.md
@@ -1,3 +1,4 @@
+
# SwaggerPetstore.StoreApi
All URIs are relative to *http://petstore.swagger.io/v2*
@@ -213,18 +214,18 @@ For valid response try integer IDs with value <= 5 or > 10. Other values w
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
-// Configure API key authorization: test_api_key_query
-var test_api_key_query = defaultClient.authentications['test_api_key_query'];
-test_api_key_query.apiKey = "YOUR API KEY"
-// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
-//test_api_key_query.apiKeyPrefix['test_api_key_query'] = "Token"
-
// Configure API key authorization: test_api_key_header
var test_api_key_header = defaultClient.authentications['test_api_key_header'];
test_api_key_header.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//test_api_key_header.apiKeyPrefix['test_api_key_header'] = "Token"
+// Configure API key authorization: test_api_key_query
+var test_api_key_query = defaultClient.authentications['test_api_key_query'];
+test_api_key_query.apiKey = "YOUR API KEY"
+// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
+//test_api_key_query.apiKeyPrefix['test_api_key_query'] = "Token"
+
var api = new SwaggerPetstore.StoreApi()
var orderId = "orderId_example"; // {String} ID of pet that needs to be fetched
@@ -249,7 +250,7 @@ Name | Type | Description | Notes
### Authorization
-[test_api_key_query](../README.md#test_api_key_query), [test_api_key_header](../README.md#test_api_key_header)
+[test_api_key_header](../README.md#test_api_key_header), [test_api_key_query](../README.md#test_api_key_query)
### HTTP reuqest headers
diff --git a/samples/client/petstore/javascript-promise/src/ApiClient.js b/samples/client/petstore/javascript-promise/src/ApiClient.js
index f1cbadb9505..8943bd4792b 100644
--- a/samples/client/petstore/javascript-promise/src/ApiClient.js
+++ b/samples/client/petstore/javascript-promise/src/ApiClient.js
@@ -15,50 +15,78 @@
}(this, function(superagent) {
'use strict';
- var ApiClient = function ApiClient() {
+ /**
+ * @module ApiClient
+ * @version 1.0.0
+ */
+
+ /**
+ * Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an
+ * application to use this class directly - the *Api and model classes provide the public API for the service. The
+ * contents of this file should be regarded as internal but are documented for completeness.
+ * @alias module:ApiClient
+ * @class
+ */
+ var exports = function() {
/**
- * The base path to put in front of every API call's (relative) path.
+ * The base URL against which to resolve every API call's (relative) path.
+ * @type {String}
+ * @default http://petstore.swagger.io/v2
*/
this.basePath = 'http://petstore.swagger.io/v2'.replace(/\/+$/, '');
+ /**
+ * The authentication methods to be included for all API calls.
+ * @type {Array.
+ * An AMD (recommended!) or CommonJS application will generally do something equivalent to the following:
+ * param
.
+ */
+ exports.prototype.paramToString = function(param) {
+ if (param == undefined || param == null) {
return '';
- } else if (param instanceof Date) {
- return param.toJSON();
- } else {
- return param.toString();
}
+ if (param instanceof Date) {
+ return param.toJSON();
+ }
+ return param.toString();
};
/**
- * Build full URL by appending the given path to base path and replacing
- * path parameter placeholders with parameter values.
+ * Builds full URL by appending the given path to the base URL and replacing path parameter place-holders with parameter values.
* NOTE: query parameters are not handled here.
+ * @param {String} path The path to append to the base URL.
+ * @param {Object} pathParams The parameter values to append.
+ * @returns {String} The encoded path with parameter values substituted.
*/
- ApiClient.prototype.buildUrl = function buildUrl(path, pathParams) {
+ exports.prototype.buildUrl = function(path, pathParams) {
if (!path.match(/^\//)) {
path = '/' + path;
}
@@ -77,34 +105,40 @@
};
/**
- * Check if the given MIME is a JSON MIME.
- * JSON MIME examples:
- * application/json
- * application/json; charset=UTF8
- * APPLICATION/JSON
+ * Checks whether the given content type represents JSON.
+ * JSON content type examples:
+ *
+ *
+ * @param {String} contentType The MIME content type to check.
+ * @returns {Boolean} true
if contentType
represents JSON, otherwise false
.
*/
- ApiClient.prototype.isJsonMime = function isJsonMime(mime) {
- return Boolean(mime != null && mime.match(/^application\/json(;.*)?$/i));
+ exports.prototype.isJsonMime = function(contentType) {
+ return Boolean(contentType != null && contentType.match(/^application\/json(;.*)?$/i));
};
/**
- * Choose a MIME from the given MIMEs with JSON preferred,
- * i.e. return JSON if included, otherwise return the first one.
+ * Chooses a content type from the given array, with JSON preferred; i.e. return JSON if included, otherwise return the first.
+ * @param {Array.true
if param
represents a file.
*/
- ApiClient.prototype.isFileParam = function isFileParam(param) {
+ exports.prototype.isFileParam = function(param) {
// fs.ReadStream in Node.js (but not in runtime like browserify)
if (typeof window === 'undefined' &&
typeof require === 'function' &&
@@ -128,15 +162,19 @@
};
/**
- * Normalize parameters values:
- * remove nils,
- * keep files and arrays,
- * format to string with `paramToString` for other cases.
+ * Normalizes parameter values:
+ *
+ *
+ * @param {Object.csv
+ * @const
+ */
+ CSV: ',',
+ /**
+ * Space-separated values. Value: ssv
+ * @const
+ */
+ SSV: ' ',
+ /**
+ * Tab-separated values. Value: tsv
+ * @const
+ */
+ TSV: '\t',
+ /**
+ * Pipe(|)-separated values. Value: pipes
+ * @const
+ */
+ PIPES: '|',
+ /**
+ * Native array. Value: multi
+ * @const
+ */
+ MULTI: 'multi'
+ };
+
+ /**
+ * Builds a string representation of an array-type actual parameter, according to the given collection format.
+ * @param {Array} param An array parameter.
+ * @param {module:ApiClient.CollectionFormatEnum} collectionFormat The array element separator strategy.
+ * @returns {String|Array} A string representation of the supplied collection, using the specified delimiter. Returns
+ * param
as is if collectionFormat
is multi
.
+ */
+ exports.prototype.buildCollectionParam = function buildCollectionParam(param, collectionFormat) {
if (param == null) {
return null;
}
@@ -166,14 +240,19 @@
case 'pipes':
return param.map(this.paramToString).join('|');
case 'multi':
- // return the array directly as Superagent will handle it as expected
+ // return the array directly as SuperAgent will handle it as expected
return param.map(this.paramToString);
default:
throw new Error('Unknown collection format: ' + collectionFormat);
}
};
- ApiClient.prototype.applyAuthToRequest = function applyAuthToRequest(request, authNames) {
+ /**
+ * Applies authentication headers to the request.
+ * @param {Object} request The request object created by a superagent()
call.
+ * @param {Array.data
will be converted to this type.
+ * @returns A value of the specified type.
+ */
+ exports.prototype.deserialize = function deserialize(response, returnType) {
if (response == null || returnType == null) {
return null;
}
- // Rely on Superagent for parsing response body.
+ // Rely on SuperAgent for parsing response body.
// See http://visionmedia.github.io/superagent/#parsing-response-bodies
var data = response.body;
if (data == null) {
- // Superagent does not always produce a body; use the unparsed response
- // as a fallback
+ // SuperAgent does not always produce a body; use the unparsed response as a fallback
data = response.text;
}
- return ApiClient.convertToType(data, returnType);
+ return exports.convertToType(data, returnType);
};
- ApiClient.prototype.callApi = function callApi(path, httpMethod, pathParams,
- queryParams, headerParams, formParams, bodyParam, authNames, contentTypes,
- accepts, returnType) {
+ /**
+ * Invokes the REST service using the supplied settings and parameters.
+ * @param {String} path The base URL to invoke.
+ * @param {String} httpMethod The HTTP method to use.
+ * @param {Object.
data
will be converted to this type.
+ * @returns An instance of the specified type.
+ */
+ exports.convertToType = function(data, type) {
switch (type) {
case 'Boolean':
return Boolean(data);
@@ -312,13 +424,12 @@
return data;
} else if (typeof type === 'function') {
// for model type like: User
- var model = type.constructFromObject(data);
- return model;
+ return type.constructFromObject(data);
} else if (Array.isArray(type)) {
// for array type like: ['String']
var itemType = type[0];
return data.map(function(item) {
- return ApiClient.convertToType(item, itemType);
+ return exports.convertToType(item, itemType);
});
} else if (typeof type === 'object') {
// for plain object type like: {'String': 'Integer'}
@@ -333,8 +444,8 @@
var result = {};
for (var k in data) {
if (data.hasOwnProperty(k)) {
- var key = ApiClient.convertToType(k, keyType);
- var value = ApiClient.convertToType(data[k], valueType);
+ var key = exports.convertToType(k, keyType);
+ var value = exports.convertToType(data[k], valueType);
result[key] = value;
}
}
@@ -346,7 +457,11 @@
}
};
- ApiClient.default = new ApiClient();
+ /**
+ * The default API client implementation.
+ * @type {module:ApiClient}
+ */
+ exports.instance = new exports();
- return ApiClient;
+ 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 4058a433441..6166cf35cb1 100644
--- a/samples/client/petstore/javascript-promise/src/api/PetApi.js
+++ b/samples/client/petstore/javascript-promise/src/api/PetApi.js
@@ -15,21 +15,34 @@
}(this, function(ApiClient, Pet, InlineResponse200) {
'use strict';
- var PetApi = function PetApi(apiClient) {
- this.apiClient = apiClient || ApiClient.default;
+ /**
+ * Pet service.
+ * @module api/PetApi
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new PetApi.
+ * @alias module:api/PetApi
+ * @class
+ * @param {module:ApiClient} apiClient Optional API client implementation to use, defaulting to {@link module:ApiClient#instance}
+ * if unspecified.
+ */
+ var exports = function(apiClient) {
+ this.apiClient = apiClient || ApiClient.instance;
+
+
- var self = this;
-
-
/**
* Add a new pet to the store
*
- * @param {Pet} opts['body'] Pet object that needs to be added to the store
+ * @param {Object} opts Optional parameters
+ * @param {module:model/Pet} opts.body Pet object that needs to be added to the store
*/
- self.addPet = function(opts) {
+ this.addPet = function(opts) {
opts = opts || {};
var postBody = opts['body'];
-
+
var pathParams = {
};
@@ -50,18 +63,19 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
-
}
-
+
+
/**
* Fake endpoint to test byte array in body parameter for adding a new pet to the store
*
- * @param {String} opts['body'] Pet object in the form of byte array
+ * @param {Object} opts Optional parameters
+ * @param {String} opts.body Pet object in the form of byte array
*/
- self.addPetUsingByteArray = function(opts) {
+ this.addPetUsingByteArray = function(opts) {
opts = opts || {};
var postBody = opts['body'];
-
+
var pathParams = {
};
@@ -82,24 +96,25 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
-
}
-
+
+
/**
* Deletes a pet
*
* @param {Integer} petId Pet id to delete
- * @param {String} opts['apiKey']
+ * @param {Object} opts Optional parameters
+ * @param {String} opts.apiKey
*/
- self.deletePet = function(petId, opts) {
+ this.deletePet = function(petId, opts) {
opts = opts || {};
var postBody = null;
-
+
// verify the required parameter 'petId' is set
- if (petId == null) {
+ if (petId == undefined || petId == null) {
throw "Missing the required parameter 'petId' when calling deletePet";
}
-
+
var pathParams = {
'petId': petId
@@ -122,19 +137,20 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
-
}
-
+
+
/**
* Finds Pets by status
* Multiple status values can be provided with comma separated strings
- * @param {[String]} opts['status'] Status values that need to be considered for query (default to available)
- * data is of type: [Pet]
+ * @param {Object} opts Optional parameters
+ * @param {Array.
+ * The index
module provides access to constructors for all the classes which comprise the public API.
+ *
+ * var SwaggerPetstore = require('./index'); // See note below*.
+ * var xxxSvc = new SwaggerPetstore.XxxApi(); // Allocate the API class we're going to use.
+ * var yyyModel = new SwaggerPetstore.Yyy(); // Construct a model instance.
+ * yyyModel.someProperty = 'someValue';
+ * ...
+ * var zzz = xxxSvc.doSomething(yyyModel); // Invoke the service.
+ * ...
+ *
+ * *NOTE: For a top-level AMD script, use require(['./index'], function(){...}) and put the application logic within the
+ * callback function.
+ *
+ * A non-AMD browser application (discouraged) might do something like this: + *
+ * var xxxSvc = new SwaggerPetstore.XxxApi(); // Allocate the API class we're going to use. + * var yyy = new SwaggerPetstore.Yyy(); // Construct a model instance. + * yyyModel.someProperty = 'someValue'; + * ... + * var zzz = xxxSvc.doSomething(yyyModel); // Invoke the service. + * ... + *+ * + * @module index + * @version 1.0.0 + */ + var exports = { + /** + * The ApiClient constructor. + * @property {module:ApiClient} + */ ApiClient: ApiClient, + /** + * The Category model constructor. + * @property {module:model/Category} + */ Category: Category, + /** + * The InlineResponse200 model constructor. + * @property {module:model/InlineResponse200} + */ InlineResponse200: InlineResponse200, + /** + * The Model200Response model constructor. + * @property {module:model/Model200Response} + */ Model200Response: Model200Response, + /** + * The ModelReturn model constructor. + * @property {module:model/ModelReturn} + */ ModelReturn: ModelReturn, + /** + * The Name model constructor. + * @property {module:model/Name} + */ Name: Name, + /** + * The Order model constructor. + * @property {module:model/Order} + */ Order: Order, + /** + * The Pet model constructor. + * @property {module:model/Pet} + */ Pet: Pet, + /** + * The SpecialModelName model constructor. + * @property {module:model/SpecialModelName} + */ SpecialModelName: SpecialModelName, + /** + * The Tag model constructor. + * @property {module:model/Tag} + */ Tag: Tag, + /** + * The User model constructor. + * @property {module:model/User} + */ User: User, + /** + * The PetApi service constructor. + * @property {module:api/PetApi} + */ PetApi: PetApi, + /** + * The StoreApi service constructor. + * @property {module:api/StoreApi} + */ StoreApi: StoreApi, + /** + * The UserApi service constructor. + * @property {module:api/UserApi} + */ UserApi: UserApi }; + + return exports; })); diff --git a/samples/client/petstore/javascript-promise/src/model/Category.js b/samples/client/petstore/javascript-promise/src/model/Category.js index de7e6a15ddd..473f4b783d5 100644 --- a/samples/client/petstore/javascript-promise/src/model/Category.js +++ b/samples/client/petstore/javascript-promise/src/model/Category.js @@ -14,64 +14,58 @@ } }(this, function(ApiClient) { 'use strict'; - - - var Category = function Category() { - + + /** + * The Category model module. + * @module model/Category + * @version 1.0.0 + */ + + /** + * Constructs a new
Category
.
+ * @alias module:model/Category
+ * @class
+ */
+ var exports = function() {
+
+
+
};
- Category.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a Category
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/Category} obj Optional instance to populate.
+ * @return {module:model/Category} The populated Category
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('id')) {
+ obj['id'] = ApiClient.convertToType(data['id'], 'Integer');
+ }
+ if (data.hasOwnProperty('name')) {
+ obj['name'] = ApiClient.convertToType(data['name'], 'String');
+ }
}
- var _this = new Category();
-
- if (data['id']) {
- _this['id'] = ApiClient.convertToType(data['id'], 'Integer');
- }
-
- if (data['name']) {
- _this['name'] = ApiClient.convertToType(data['name'], 'String');
- }
-
- return _this;
+ return obj;
}
-
-
- /**
- * @return {Integer}
- **/
- Category.prototype.getId = function() {
- return this['id'];
- }
/**
- * @param {Integer} id
- **/
- Category.prototype.setId = function(id) {
- this['id'] = id;
- }
-
- /**
- * @return {String}
- **/
- Category.prototype.getName = function() {
- return this['name'];
- }
+ * @member {Integer} id
+ */
+ exports.prototype['id'] = undefined;
/**
- * @param {String} name
- **/
- Category.prototype.setName = function(name) {
- this['name'] = name;
- }
-
-
+ * @member {String} name
+ */
+ exports.prototype['name'] = undefined;
-
- return Category;
-
-
+
+
+ return exports;
}));
diff --git a/samples/client/petstore/javascript-promise/src/model/InlineResponse200.js b/samples/client/petstore/javascript-promise/src/model/InlineResponse200.js
index 2afc6996266..f9ecda79491 100644
--- a/samples/client/petstore/javascript-promise/src/model/InlineResponse200.js
+++ b/samples/client/petstore/javascript-promise/src/model/InlineResponse200.js
@@ -14,162 +14,119 @@
}
}(this, function(ApiClient, Tag) {
'use strict';
-
-
- var InlineResponse200 = function InlineResponse200(id) {
+
+ /**
+ * The InlineResponse200 model module.
+ * @module model/InlineResponse200
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new InlineResponse200
.
+ * @alias module:model/InlineResponse200
+ * @class
+ * @param id
+ */
+ var exports = function(id) {
+
+
+ this['id'] = id;
+
+
+
+
+ };
+
+ /**
+ * Constructs a InlineResponse200
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/InlineResponse200} obj Optional instance to populate.
+ * @return {module:model/InlineResponse200} The populated InlineResponse200
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('tags')) {
+ obj['tags'] = ApiClient.convertToType(data['tags'], [Tag]);
+ }
+ if (data.hasOwnProperty('id')) {
+ obj['id'] = ApiClient.convertToType(data['id'], 'Integer');
+ }
+ if (data.hasOwnProperty('category')) {
+ obj['category'] = ApiClient.convertToType(data['category'], Object);
+ }
+ if (data.hasOwnProperty('status')) {
+ obj['status'] = ApiClient.convertToType(data['status'], 'String');
+ }
+ if (data.hasOwnProperty('name')) {
+ obj['name'] = ApiClient.convertToType(data['name'], 'String');
+ }
+ if (data.hasOwnProperty('photoUrls')) {
+ obj['photoUrls'] = ApiClient.convertToType(data['photoUrls'], ['String']);
+ }
+ }
+ return obj;
+ }
+
+
+ /**
+ * @member {Array.status
property.
+ * @enum {String}
+ * @readonly
+ */
+ exports.StatusEnum = {
+ /**
+ * value: available
+ * @const
+ */
+ AVAILABLE: "available",
/**
- * datatype: Integer
- * required
- **/
- this['id'] = id;
+ * value: pending
+ * @const
+ */
+ PENDING: "pending",
+
+ /**
+ * value: sold
+ * @const
+ */
+ SOLD: "sold"
};
- InlineResponse200.constructFromObject = function(data) {
- if (!data) {
- return null;
- }
- var _this = new InlineResponse200();
-
- if (data['photoUrls']) {
- _this['photoUrls'] = ApiClient.convertToType(data['photoUrls'], ['String']);
- }
-
- if (data['name']) {
- _this['name'] = ApiClient.convertToType(data['name'], 'String');
- }
-
- if (data['id']) {
- _this['id'] = ApiClient.convertToType(data['id'], 'Integer');
- }
-
- if (data['category']) {
- _this['category'] = ApiClient.convertToType(data['category'], Object);
- }
-
- if (data['tags']) {
- _this['tags'] = ApiClient.convertToType(data['tags'], [Tag]);
- }
-
- if (data['status']) {
- _this['status'] = ApiClient.convertToType(data['status'], 'String');
- }
-
- return _this;
- }
-
-
-
- /**
- * @return {[String]}
- **/
- InlineResponse200.prototype.getPhotoUrls = function() {
- return this['photoUrls'];
- }
-
- /**
- * @param {[String]} photoUrls
- **/
- InlineResponse200.prototype.setPhotoUrls = function(photoUrls) {
- this['photoUrls'] = photoUrls;
- }
-
- /**
- * @return {String}
- **/
- InlineResponse200.prototype.getName = function() {
- return this['name'];
- }
-
- /**
- * @param {String} name
- **/
- InlineResponse200.prototype.setName = function(name) {
- this['name'] = name;
- }
-
- /**
- * @return {Integer}
- **/
- InlineResponse200.prototype.getId = function() {
- return this['id'];
- }
-
- /**
- * @param {Integer} id
- **/
- InlineResponse200.prototype.setId = function(id) {
- this['id'] = id;
- }
-
- /**
- * @return {Object}
- **/
- InlineResponse200.prototype.getCategory = function() {
- return this['category'];
- }
-
- /**
- * @param {Object} category
- **/
- InlineResponse200.prototype.setCategory = function(category) {
- this['category'] = category;
- }
-
- /**
- * @return {[Tag]}
- **/
- InlineResponse200.prototype.getTags = function() {
- return this['tags'];
- }
-
- /**
- * @param {[Tag]} tags
- **/
- InlineResponse200.prototype.setTags = function(tags) {
- this['tags'] = tags;
- }
-
- /**
- * get pet status in the store
- * @return {StatusEnum}
- **/
- InlineResponse200.prototype.getStatus = function() {
- return this['status'];
- }
-
- /**
- * set pet status in the store
- * @param {StatusEnum} status
- **/
- InlineResponse200.prototype.setStatus = function(status) {
- this['status'] = status;
- }
-
-
-
- var StatusEnum = {
-
- /**
- * @const
- */
- AVAILABLE: "available",
-
- /**
- * @const
- */
- PENDING: "pending",
-
- /**
- * @const
- */
- SOLD: "sold"
- };
-
- InlineResponse200.StatusEnum = StatusEnum;
-
-
- return InlineResponse200;
-
-
+ return exports;
}));
diff --git a/samples/client/petstore/javascript-promise/src/model/Model200Response.js b/samples/client/petstore/javascript-promise/src/model/Model200Response.js
index eab775e7476..fb559f5ebaa 100644
--- a/samples/client/petstore/javascript-promise/src/model/Model200Response.js
+++ b/samples/client/petstore/javascript-promise/src/model/Model200Response.js
@@ -14,46 +14,49 @@
}
}(this, function(ApiClient) {
'use strict';
-
-
- var Model200Response = function Model200Response() {
-
+
+ /**
+ * The Model200Response model module.
+ * @module model/Model200Response
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new Model200Response
.
+ * @alias module:model/Model200Response
+ * @class
+ */
+ var exports = function() {
+
+
};
- Model200Response.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a Model200Response
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/Model200Response} obj Optional instance to populate.
+ * @return {module:model/Model200Response} The populated Model200Response
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('name')) {
+ obj['name'] = ApiClient.convertToType(data['name'], 'Integer');
+ }
}
- var _this = new Model200Response();
-
- if (data['name']) {
- _this['name'] = ApiClient.convertToType(data['name'], 'Integer');
- }
-
- return _this;
+ return obj;
}
-
-
- /**
- * @return {Integer}
- **/
- Model200Response.prototype.getName = function() {
- return this['name'];
- }
/**
- * @param {Integer} name
- **/
- Model200Response.prototype.setName = function(name) {
- this['name'] = name;
- }
-
-
+ * @member {Integer} name
+ */
+ exports.prototype['name'] = undefined;
-
- return Model200Response;
-
-
+
+
+ return exports;
}));
diff --git a/samples/client/petstore/javascript-promise/src/model/ModelReturn.js b/samples/client/petstore/javascript-promise/src/model/ModelReturn.js
index e93e4de28f6..d5036e230ea 100644
--- a/samples/client/petstore/javascript-promise/src/model/ModelReturn.js
+++ b/samples/client/petstore/javascript-promise/src/model/ModelReturn.js
@@ -14,46 +14,49 @@
}
}(this, function(ApiClient) {
'use strict';
-
-
- var ModelReturn = function ModelReturn() {
-
+
+ /**
+ * The ModelReturn model module.
+ * @module model/ModelReturn
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new ModelReturn
.
+ * @alias module:model/ModelReturn
+ * @class
+ */
+ var exports = function() {
+
+
};
- ModelReturn.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a ModelReturn
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/ModelReturn} obj Optional instance to populate.
+ * @return {module:model/ModelReturn} The populated ModelReturn
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('return')) {
+ obj['return'] = ApiClient.convertToType(data['return'], 'Integer');
+ }
}
- var _this = new ModelReturn();
-
- if (data['return']) {
- _this['return'] = ApiClient.convertToType(data['return'], 'Integer');
- }
-
- return _this;
+ return obj;
}
-
-
- /**
- * @return {Integer}
- **/
- ModelReturn.prototype.getReturn = function() {
- return this['return'];
- }
/**
- * @param {Integer} _return
- **/
- ModelReturn.prototype.setReturn = function(_return) {
- this['return'] = _return;
- }
-
-
+ * @member {Integer} return
+ */
+ exports.prototype['return'] = undefined;
-
- return ModelReturn;
-
-
+
+
+ return exports;
}));
diff --git a/samples/client/petstore/javascript-promise/src/model/Name.js b/samples/client/petstore/javascript-promise/src/model/Name.js
index 8367c1b1e62..20aa186bd97 100644
--- a/samples/client/petstore/javascript-promise/src/model/Name.js
+++ b/samples/client/petstore/javascript-promise/src/model/Name.js
@@ -14,46 +14,49 @@
}
}(this, function(ApiClient) {
'use strict';
-
-
- var Name = function Name() {
-
+
+ /**
+ * The Name model module.
+ * @module model/Name
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new Name
.
+ * @alias module:model/Name
+ * @class
+ */
+ var exports = function() {
+
+
};
- Name.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a Name
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/Name} obj Optional instance to populate.
+ * @return {module:model/Name} The populated Name
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('name')) {
+ obj['name'] = ApiClient.convertToType(data['name'], 'Integer');
+ }
}
- var _this = new Name();
-
- if (data['name']) {
- _this['name'] = ApiClient.convertToType(data['name'], 'Integer');
- }
-
- return _this;
+ return obj;
}
-
-
- /**
- * @return {Integer}
- **/
- Name.prototype.getName = function() {
- return this['name'];
- }
/**
- * @param {Integer} name
- **/
- Name.prototype.setName = function(name) {
- this['name'] = name;
- }
-
-
+ * @member {Integer} name
+ */
+ exports.prototype['name'] = undefined;
-
- return Name;
-
-
+
+
+ return exports;
}));
diff --git a/samples/client/petstore/javascript-promise/src/model/ObjectReturn.js b/samples/client/petstore/javascript-promise/src/model/ObjectReturn.js
deleted file mode 100644
index b0da87d8465..00000000000
--- a/samples/client/petstore/javascript-promise/src/model/ObjectReturn.js
+++ /dev/null
@@ -1,59 +0,0 @@
-(function(root, factory) {
- if (typeof define === 'function' && define.amd) {
- // AMD. Register as an anonymous module.
- define(['../ApiClient'], factory);
- } else if (typeof module === 'object' && module.exports) {
- // CommonJS-like environments that support module.exports, like Node.
- module.exports = factory(require('../ApiClient'));
- } else {
- // Browser globals (root is window)
- if (!root.SwaggerPetstore) {
- root.SwaggerPetstore = {};
- }
- root.SwaggerPetstore.ObjectReturn = factory(root.SwaggerPetstore.ApiClient);
- }
-}(this, function(ApiClient) {
- 'use strict';
-
-
- var ObjectReturn = function ObjectReturn() {
-
- };
-
- ObjectReturn.constructFromObject = function(data) {
- if (!data) {
- return null;
- }
- var _this = new ObjectReturn();
-
- if (data['return']) {
- _this['return'] = ApiClient.convertToType(data['return'], 'Integer');
- }
-
- return _this;
- }
-
-
-
- /**
- * @return {Integer}
- **/
- ObjectReturn.prototype.getReturn = function() {
- return this['return'];
- }
-
- /**
- * @param {Integer} _return
- **/
- ObjectReturn.prototype.setReturn = function(_return) {
- this['return'] = _return;
- }
-
-
-
-
-
- return ObjectReturn;
-
-
-}));
diff --git a/samples/client/petstore/javascript-promise/src/model/Order.js b/samples/client/petstore/javascript-promise/src/model/Order.js
index a33323e8ca3..81f1feb7800 100644
--- a/samples/client/petstore/javascript-promise/src/model/Order.js
+++ b/samples/client/petstore/javascript-promise/src/model/Order.js
@@ -14,157 +14,118 @@
}
}(this, function(ApiClient) {
'use strict';
-
-
- var Order = function Order() {
-
+
+ /**
+ * The Order model module.
+ * @module model/Order
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new Order
.
+ * @alias module:model/Order
+ * @class
+ */
+ var exports = function() {
+
+
+
+
+
+
+
};
- Order.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a Order
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/Order} obj Optional instance to populate.
+ * @return {module:model/Order} The populated Order
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('id')) {
+ obj['id'] = ApiClient.convertToType(data['id'], 'Integer');
+ }
+ if (data.hasOwnProperty('petId')) {
+ obj['petId'] = ApiClient.convertToType(data['petId'], 'Integer');
+ }
+ if (data.hasOwnProperty('quantity')) {
+ obj['quantity'] = ApiClient.convertToType(data['quantity'], 'Integer');
+ }
+ if (data.hasOwnProperty('shipDate')) {
+ obj['shipDate'] = ApiClient.convertToType(data['shipDate'], 'Date');
+ }
+ if (data.hasOwnProperty('status')) {
+ obj['status'] = ApiClient.convertToType(data['status'], 'String');
+ }
+ if (data.hasOwnProperty('complete')) {
+ obj['complete'] = ApiClient.convertToType(data['complete'], 'Boolean');
+ }
}
- var _this = new Order();
+ return obj;
+ }
+
+
+ /**
+ * @member {Integer} id
+ */
+ exports.prototype['id'] = undefined;
+
+ /**
+ * @member {Integer} petId
+ */
+ exports.prototype['petId'] = undefined;
+
+ /**
+ * @member {Integer} quantity
+ */
+ exports.prototype['quantity'] = undefined;
+
+ /**
+ * @member {Date} shipDate
+ */
+ exports.prototype['shipDate'] = undefined;
+
+ /**
+ * Order Status
+ * @member {module:model/Order.StatusEnum} status
+ */
+ exports.prototype['status'] = undefined;
+
+ /**
+ * @member {Boolean} complete
+ */
+ exports.prototype['complete'] = undefined;
+
+
+ /**
+ * Allowed values for the status
property.
+ * @enum {String}
+ * @readonly
+ */
+ exports.StatusEnum = {
+ /**
+ * value: placed
+ * @const
+ */
+ PLACED: "placed",
- if (data['id']) {
- _this['id'] = ApiClient.convertToType(data['id'], 'Integer');
- }
+ /**
+ * value: approved
+ * @const
+ */
+ APPROVED: "approved",
- if (data['petId']) {
- _this['petId'] = ApiClient.convertToType(data['petId'], 'Integer');
- }
-
- if (data['quantity']) {
- _this['quantity'] = ApiClient.convertToType(data['quantity'], 'Integer');
- }
-
- if (data['shipDate']) {
- _this['shipDate'] = ApiClient.convertToType(data['shipDate'], 'Date');
- }
-
- if (data['status']) {
- _this['status'] = ApiClient.convertToType(data['status'], 'String');
- }
-
- if (data['complete']) {
- _this['complete'] = ApiClient.convertToType(data['complete'], 'Boolean');
- }
-
- return _this;
- }
-
-
-
- /**
- * @return {Integer}
- **/
- Order.prototype.getId = function() {
- return this['id'];
- }
-
- /**
- * @param {Integer} id
- **/
- Order.prototype.setId = function(id) {
- this['id'] = id;
- }
-
- /**
- * @return {Integer}
- **/
- Order.prototype.getPetId = function() {
- return this['petId'];
- }
-
- /**
- * @param {Integer} petId
- **/
- Order.prototype.setPetId = function(petId) {
- this['petId'] = petId;
- }
-
- /**
- * @return {Integer}
- **/
- Order.prototype.getQuantity = function() {
- return this['quantity'];
- }
-
- /**
- * @param {Integer} quantity
- **/
- Order.prototype.setQuantity = function(quantity) {
- this['quantity'] = quantity;
- }
-
- /**
- * @return {Date}
- **/
- Order.prototype.getShipDate = function() {
- return this['shipDate'];
- }
-
- /**
- * @param {Date} shipDate
- **/
- Order.prototype.setShipDate = function(shipDate) {
- this['shipDate'] = shipDate;
- }
-
- /**
- * get Order Status
- * @return {StatusEnum}
- **/
- Order.prototype.getStatus = function() {
- return this['status'];
- }
-
- /**
- * set Order Status
- * @param {StatusEnum} status
- **/
- Order.prototype.setStatus = function(status) {
- this['status'] = status;
- }
-
- /**
- * @return {Boolean}
- **/
- Order.prototype.getComplete = function() {
- return this['complete'];
- }
-
- /**
- * @param {Boolean} complete
- **/
- Order.prototype.setComplete = function(complete) {
- this['complete'] = complete;
- }
-
-
-
- var StatusEnum = {
-
- /**
- * @const
- */
- PLACED: "placed",
-
- /**
- * @const
- */
- APPROVED: "approved",
-
- /**
- * @const
- */
- DELIVERED: "delivered"
+ /**
+ * value: delivered
+ * @const
+ */
+ DELIVERED: "delivered"
};
- Order.StatusEnum = StatusEnum;
-
-
- return Order;
-
-
+ return exports;
}));
diff --git a/samples/client/petstore/javascript-promise/src/model/Pet.js b/samples/client/petstore/javascript-promise/src/model/Pet.js
index f2290772a17..39a09b47170 100644
--- a/samples/client/petstore/javascript-promise/src/model/Pet.js
+++ b/samples/client/petstore/javascript-promise/src/model/Pet.js
@@ -14,167 +14,120 @@
}
}(this, function(ApiClient, Category, Tag) {
'use strict';
-
-
- var Pet = function Pet(name, photoUrls) {
-
- /**
- * datatype: String
- * required
- **/
+
+ /**
+ * The Pet model module.
+ * @module model/Pet
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new Pet
.
+ * @alias module:model/Pet
+ * @class
+ * @param name
+ * @param photoUrls
+ */
+ var exports = function(name, photoUrls) {
+
+
+
this['name'] = name;
- /**
- * datatype: [String]
- * required
- **/
this['photoUrls'] = photoUrls;
+
+
};
- Pet.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a Pet
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/Pet} obj Optional instance to populate.
+ * @return {module:model/Pet} The populated Pet
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('id')) {
+ obj['id'] = ApiClient.convertToType(data['id'], 'Integer');
+ }
+ if (data.hasOwnProperty('category')) {
+ obj['category'] = Category.constructFromObject(data['category']);
+ }
+ if (data.hasOwnProperty('name')) {
+ obj['name'] = ApiClient.convertToType(data['name'], 'String');
+ }
+ if (data.hasOwnProperty('photoUrls')) {
+ obj['photoUrls'] = ApiClient.convertToType(data['photoUrls'], ['String']);
+ }
+ if (data.hasOwnProperty('tags')) {
+ obj['tags'] = ApiClient.convertToType(data['tags'], [Tag]);
+ }
+ if (data.hasOwnProperty('status')) {
+ obj['status'] = ApiClient.convertToType(data['status'], 'String');
+ }
}
- var _this = new Pet();
+ return obj;
+ }
+
+
+ /**
+ * @member {Integer} id
+ */
+ exports.prototype['id'] = undefined;
+
+ /**
+ * @member {module:model/Category} category
+ */
+ exports.prototype['category'] = undefined;
+
+ /**
+ * @member {String} name
+ */
+ exports.prototype['name'] = undefined;
+
+ /**
+ * @member {Array.status
property.
+ * @enum {String}
+ * @readonly
+ */
+ exports.StatusEnum = {
+ /**
+ * value: available
+ * @const
+ */
+ AVAILABLE: "available",
- if (data['id']) {
- _this['id'] = ApiClient.convertToType(data['id'], 'Integer');
- }
+ /**
+ * value: pending
+ * @const
+ */
+ PENDING: "pending",
- if (data['category']) {
- _this['category'] = Category.constructFromObject(data['category']);
- }
-
- if (data['name']) {
- _this['name'] = ApiClient.convertToType(data['name'], 'String');
- }
-
- if (data['photoUrls']) {
- _this['photoUrls'] = ApiClient.convertToType(data['photoUrls'], ['String']);
- }
-
- if (data['tags']) {
- _this['tags'] = ApiClient.convertToType(data['tags'], [Tag]);
- }
-
- if (data['status']) {
- _this['status'] = ApiClient.convertToType(data['status'], 'String');
- }
-
- return _this;
- }
-
-
-
- /**
- * @return {Integer}
- **/
- Pet.prototype.getId = function() {
- return this['id'];
- }
-
- /**
- * @param {Integer} id
- **/
- Pet.prototype.setId = function(id) {
- this['id'] = id;
- }
-
- /**
- * @return {Category}
- **/
- Pet.prototype.getCategory = function() {
- return this['category'];
- }
-
- /**
- * @param {Category} category
- **/
- Pet.prototype.setCategory = function(category) {
- this['category'] = category;
- }
-
- /**
- * @return {String}
- **/
- Pet.prototype.getName = function() {
- return this['name'];
- }
-
- /**
- * @param {String} name
- **/
- Pet.prototype.setName = function(name) {
- this['name'] = name;
- }
-
- /**
- * @return {[String]}
- **/
- Pet.prototype.getPhotoUrls = function() {
- return this['photoUrls'];
- }
-
- /**
- * @param {[String]} photoUrls
- **/
- Pet.prototype.setPhotoUrls = function(photoUrls) {
- this['photoUrls'] = photoUrls;
- }
-
- /**
- * @return {[Tag]}
- **/
- Pet.prototype.getTags = function() {
- return this['tags'];
- }
-
- /**
- * @param {[Tag]} tags
- **/
- Pet.prototype.setTags = function(tags) {
- this['tags'] = tags;
- }
-
- /**
- * get pet status in the store
- * @return {StatusEnum}
- **/
- Pet.prototype.getStatus = function() {
- return this['status'];
- }
-
- /**
- * set pet status in the store
- * @param {StatusEnum} status
- **/
- Pet.prototype.setStatus = function(status) {
- this['status'] = status;
- }
-
-
-
- var StatusEnum = {
-
- /**
- * @const
- */
- AVAILABLE: "available",
-
- /**
- * @const
- */
- PENDING: "pending",
-
- /**
- * @const
- */
- SOLD: "sold"
+ /**
+ * value: sold
+ * @const
+ */
+ SOLD: "sold"
};
- Pet.StatusEnum = StatusEnum;
-
-
- return Pet;
-
-
+ return exports;
}));
diff --git a/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js b/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js
index 7daf60e985e..fb6b4765d3f 100644
--- a/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js
+++ b/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js
@@ -14,46 +14,49 @@
}
}(this, function(ApiClient) {
'use strict';
-
-
- var SpecialModelName = function SpecialModelName() {
-
+
+ /**
+ * The SpecialModelName model module.
+ * @module model/SpecialModelName
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new SpecialModelName
.
+ * @alias module:model/SpecialModelName
+ * @class
+ */
+ var exports = function() {
+
+
};
- SpecialModelName.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a SpecialModelName
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/SpecialModelName} obj Optional instance to populate.
+ * @return {module:model/SpecialModelName} The populated SpecialModelName
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('$special[property.name]')) {
+ obj['$special[property.name]'] = ApiClient.convertToType(data['$special[property.name]'], 'Integer');
+ }
}
- var _this = new SpecialModelName();
-
- if (data['$special[property.name]']) {
- _this['$special[property.name]'] = ApiClient.convertToType(data['$special[property.name]'], 'Integer');
- }
-
- return _this;
+ return obj;
}
-
-
- /**
- * @return {Integer}
- **/
- SpecialModelName.prototype.getSpecialPropertyName = function() {
- return this['$special[property.name]'];
- }
/**
- * @param {Integer} specialPropertyName
- **/
- SpecialModelName.prototype.setSpecialPropertyName = function(specialPropertyName) {
- this['$special[property.name]'] = specialPropertyName;
- }
-
-
+ * @member {Integer} $special[property.name]
+ */
+ exports.prototype['$special[property.name]'] = undefined;
-
- return SpecialModelName;
-
-
+
+
+ return exports;
}));
diff --git a/samples/client/petstore/javascript-promise/src/model/Tag.js b/samples/client/petstore/javascript-promise/src/model/Tag.js
index 793fc7f1730..8a0739b2ef5 100644
--- a/samples/client/petstore/javascript-promise/src/model/Tag.js
+++ b/samples/client/petstore/javascript-promise/src/model/Tag.js
@@ -14,64 +14,58 @@
}
}(this, function(ApiClient) {
'use strict';
-
-
- var Tag = function Tag() {
-
+
+ /**
+ * The Tag model module.
+ * @module model/Tag
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new Tag
.
+ * @alias module:model/Tag
+ * @class
+ */
+ var exports = function() {
+
+
+
};
- Tag.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a Tag
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/Tag} obj Optional instance to populate.
+ * @return {module:model/Tag} The populated Tag
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('id')) {
+ obj['id'] = ApiClient.convertToType(data['id'], 'Integer');
+ }
+ if (data.hasOwnProperty('name')) {
+ obj['name'] = ApiClient.convertToType(data['name'], 'String');
+ }
}
- var _this = new Tag();
-
- if (data['id']) {
- _this['id'] = ApiClient.convertToType(data['id'], 'Integer');
- }
-
- if (data['name']) {
- _this['name'] = ApiClient.convertToType(data['name'], 'String');
- }
-
- return _this;
+ return obj;
}
-
-
- /**
- * @return {Integer}
- **/
- Tag.prototype.getId = function() {
- return this['id'];
- }
/**
- * @param {Integer} id
- **/
- Tag.prototype.setId = function(id) {
- this['id'] = id;
- }
-
- /**
- * @return {String}
- **/
- Tag.prototype.getName = function() {
- return this['name'];
- }
+ * @member {Integer} id
+ */
+ exports.prototype['id'] = undefined;
/**
- * @param {String} name
- **/
- Tag.prototype.setName = function(name) {
- this['name'] = name;
- }
-
-
+ * @member {String} name
+ */
+ exports.prototype['name'] = undefined;
-
- return Tag;
-
-
+
+
+ return exports;
}));
diff --git a/samples/client/petstore/javascript-promise/src/model/User.js b/samples/client/petstore/javascript-promise/src/model/User.js
index a012f200e8e..1d960a89914 100644
--- a/samples/client/petstore/javascript-promise/src/model/User.js
+++ b/samples/client/petstore/javascript-promise/src/model/User.js
@@ -14,174 +14,113 @@
}
}(this, function(ApiClient) {
'use strict';
-
-
- var User = function User() {
-
+
+ /**
+ * The User model module.
+ * @module model/User
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new User
.
+ * @alias module:model/User
+ * @class
+ */
+ var exports = function() {
+
+
+
+
+
+
+
+
+
};
- User.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a User
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/User} obj Optional instance to populate.
+ * @return {module:model/User} The populated User
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('id')) {
+ obj['id'] = ApiClient.convertToType(data['id'], 'Integer');
+ }
+ if (data.hasOwnProperty('username')) {
+ obj['username'] = ApiClient.convertToType(data['username'], 'String');
+ }
+ if (data.hasOwnProperty('firstName')) {
+ obj['firstName'] = ApiClient.convertToType(data['firstName'], 'String');
+ }
+ if (data.hasOwnProperty('lastName')) {
+ obj['lastName'] = ApiClient.convertToType(data['lastName'], 'String');
+ }
+ if (data.hasOwnProperty('email')) {
+ obj['email'] = ApiClient.convertToType(data['email'], 'String');
+ }
+ if (data.hasOwnProperty('password')) {
+ obj['password'] = ApiClient.convertToType(data['password'], 'String');
+ }
+ if (data.hasOwnProperty('phone')) {
+ obj['phone'] = ApiClient.convertToType(data['phone'], 'String');
+ }
+ if (data.hasOwnProperty('userStatus')) {
+ obj['userStatus'] = ApiClient.convertToType(data['userStatus'], 'Integer');
+ }
}
- var _this = new User();
-
- if (data['id']) {
- _this['id'] = ApiClient.convertToType(data['id'], 'Integer');
- }
-
- if (data['username']) {
- _this['username'] = ApiClient.convertToType(data['username'], 'String');
- }
-
- if (data['firstName']) {
- _this['firstName'] = ApiClient.convertToType(data['firstName'], 'String');
- }
-
- if (data['lastName']) {
- _this['lastName'] = ApiClient.convertToType(data['lastName'], 'String');
- }
-
- if (data['email']) {
- _this['email'] = ApiClient.convertToType(data['email'], 'String');
- }
-
- if (data['password']) {
- _this['password'] = ApiClient.convertToType(data['password'], 'String');
- }
-
- if (data['phone']) {
- _this['phone'] = ApiClient.convertToType(data['phone'], 'String');
- }
-
- if (data['userStatus']) {
- _this['userStatus'] = ApiClient.convertToType(data['userStatus'], 'Integer');
- }
-
- return _this;
+ return obj;
}
-
-
- /**
- * @return {Integer}
- **/
- User.prototype.getId = function() {
- return this['id'];
- }
/**
- * @param {Integer} id
- **/
- User.prototype.setId = function(id) {
- this['id'] = id;
- }
-
- /**
- * @return {String}
- **/
- User.prototype.getUsername = function() {
- return this['username'];
- }
+ * @member {Integer} id
+ */
+ exports.prototype['id'] = undefined;
/**
- * @param {String} username
- **/
- User.prototype.setUsername = function(username) {
- this['username'] = username;
- }
-
- /**
- * @return {String}
- **/
- User.prototype.getFirstName = function() {
- return this['firstName'];
- }
+ * @member {String} username
+ */
+ exports.prototype['username'] = undefined;
/**
- * @param {String} firstName
- **/
- User.prototype.setFirstName = function(firstName) {
- this['firstName'] = firstName;
- }
-
- /**
- * @return {String}
- **/
- User.prototype.getLastName = function() {
- return this['lastName'];
- }
+ * @member {String} firstName
+ */
+ exports.prototype['firstName'] = undefined;
/**
- * @param {String} lastName
- **/
- User.prototype.setLastName = function(lastName) {
- this['lastName'] = lastName;
- }
-
- /**
- * @return {String}
- **/
- User.prototype.getEmail = function() {
- return this['email'];
- }
+ * @member {String} lastName
+ */
+ exports.prototype['lastName'] = undefined;
/**
- * @param {String} email
- **/
- User.prototype.setEmail = function(email) {
- this['email'] = email;
- }
-
- /**
- * @return {String}
- **/
- User.prototype.getPassword = function() {
- return this['password'];
- }
+ * @member {String} email
+ */
+ exports.prototype['email'] = undefined;
/**
- * @param {String} password
- **/
- User.prototype.setPassword = function(password) {
- this['password'] = password;
- }
-
- /**
- * @return {String}
- **/
- User.prototype.getPhone = function() {
- return this['phone'];
- }
+ * @member {String} password
+ */
+ exports.prototype['password'] = undefined;
/**
- * @param {String} phone
- **/
- User.prototype.setPhone = function(phone) {
- this['phone'] = phone;
- }
-
- /**
- * get User Status
- * @return {Integer}
- **/
- User.prototype.getUserStatus = function() {
- return this['userStatus'];
- }
+ * @member {String} phone
+ */
+ exports.prototype['phone'] = undefined;
/**
- * set User Status
- * @param {Integer} userStatus
- **/
- User.prototype.setUserStatus = function(userStatus) {
- this['userStatus'] = userStatus;
- }
-
-
+ * User Status
+ * @member {Integer} userStatus
+ */
+ exports.prototype['userStatus'] = undefined;
-
- return User;
-
-
+
+
+ return exports;
}));
diff --git a/samples/client/petstore/javascript-promise/test/ApiClientTest.js b/samples/client/petstore/javascript-promise/test/ApiClientTest.js
index 8eebe6bf7dc..c91fbb03783 100644
--- a/samples/client/petstore/javascript-promise/test/ApiClientTest.js
+++ b/samples/client/petstore/javascript-promise/test/ApiClientTest.js
@@ -4,34 +4,35 @@ if (typeof module === 'object' && module.exports) {
var sinon = require('sinon');
}
-var apiClient = SwaggerPetstore.ApiClient.default;
+var apiClient = SwaggerPetstore.ApiClient.instance;
describe('ApiClient', function() {
describe('defaults', function() {
it('should have correct default values with the default API client', function() {
expect(apiClient).to.be.ok();
+ expect(apiClient.basePath).to.be('http://petstore.swagger.io/v2');
expect(apiClient.authentications).to.eql({
petstore_auth: {type: 'oauth2'},
- api_key: {type: 'apiKey', in: 'header', name: 'api_key'},
+ api_key: {type: 'apiKey', 'in': 'header', name: 'api_key'},
test_http_basic: {type: 'basic'},
test_api_client_id: {
type: 'apiKey',
- in: 'header',
+ 'in': 'header',
name: 'x-test_api_client_id'
},
test_api_client_secret: {
type: 'apiKey',
- in: 'header',
+ 'in': 'header',
name: 'x-test_api_client_secret'
},
test_api_key_query: {
type: 'apiKey',
- in: 'query',
+ 'in': 'query',
name: 'test_api_key_query'
},
test_api_key_header: {
type: 'apiKey',
- in: 'header',
+ 'in': 'header',
name: 'test_api_key_header'
}
});
@@ -274,7 +275,7 @@ describe('ApiClient', function() {
var apiKeyAuth, oauth2;
beforeEach(function() {
- newClient.authentications[apiKeyAuthName] = {type: 'apiKey', name: 'api_key', in: 'query'};
+ newClient.authentications[apiKeyAuthName] = {type: 'apiKey', name: 'api_key', 'in': 'query'};
newClient.authentications[oauth2Name] = {type: 'oauth2'};
apiKeyAuth = newClient.authentications[apiKeyAuthName];
oauth2 = newClient.authentications[oauth2Name];
@@ -377,10 +378,10 @@ function makeDumbRequest(apiClient, opts) {
var headerParams = opts.headerParams || {};
var formParams = opts.formParams || {};
var bodyParam = opts.bodyParam;
+ var authNames = [];
var contentTypes = opts.contentTypes || [];
var accepts = opts.accepts || [];
var callback = opts.callback;
return apiClient.callApi(path, httpMethod, pathParams, queryParams,
- headerParams, formParams, bodyParam, contentTypes, accepts, callback
- );
+ headerParams, formParams, bodyParam, authNames, contentTypes, accepts);
}
diff --git a/samples/client/petstore/javascript-promise/test/api/PetApiTest.js b/samples/client/petstore/javascript-promise/test/api/PetApiTest.js
index d444529a927..1119546014d 100644
--- a/samples/client/petstore/javascript-promise/test/api/PetApiTest.js
+++ b/samples/client/petstore/javascript-promise/test/api/PetApiTest.js
@@ -3,25 +3,45 @@ if (typeof module === 'object' && module.exports) {
var SwaggerPetstore = require('../../src/index');
}
+// When testing in the Node.js environment, ApiClient will need access to a Promise constructor.
+if (typeof Promise == 'undefined')
+ Promise = require('promise');
+
var api;
beforeEach(function() {
api = new SwaggerPetstore.PetApi();
});
+var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+}
+
+var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+}
+
var createRandomPet = function() {
var id = new Date().getTime();
var pet = new SwaggerPetstore.Pet();
- pet.setId(id);
- pet.setName("gorilla" + id);
+ setProperty(pet, "setId", "id", id);
+ setProperty(pet, "setName", "name", "gorilla" + id);
var category = new SwaggerPetstore.Category();
- category.setName("really-happy");
- pet.setCategory(category);
+ setProperty(category, "setName", "name", "really-happy");
+ setProperty(pet, "setCategory", "category", category);
- pet.setStatus('available');
+ setProperty(pet, "setStatus", "status", "available");
var photos = ["http://foo.bar.com/1", "http://foo.bar.com/2"];
- pet.setPhotoUrls(photos);
+ setProperty(pet, "setPhotoUrls", "photoUrls", photos);
return pet;
};
@@ -34,14 +54,13 @@ describe('PetApi', function() {
return api.getPetById(pet.id)
})
.then(function(fetched) {
- //expect(response.status).to.be(200);
- //expect(response.ok).to.be(true);
- //expect(response.get('Content-Type')).to.be('application/json');
expect(fetched).to.be.ok();
expect(fetched.id).to.be(pet.id);
- expect(fetched.getPhotoUrls()).to.eql(pet.getPhotoUrls());
- expect(fetched.getCategory()).to.be.ok();
- expect(fetched.getCategory().getName()).to.be(pet.getCategory().getName());
+ expect(getProperty(fetched, "getPhotoUrls", "photoUrls"))
+ .to.eql(getProperty(pet, "getPhotoUrls", "photoUrls"));
+ expect(getProperty(fetched, "getCategory", "category")).to.be.ok();
+ expect(getProperty(getProperty(fetched, "getCategory", "category"), "getName", "name"))
+ .to.be(getProperty(getProperty(pet, "getCategory", "category"), "getName", "name"));
api.deletePet(pet.id);
done();
diff --git a/samples/client/petstore/javascript/README.md b/samples/client/petstore/javascript/README.md
index d0233cb1a55..f616b048515 100644
--- a/samples/client/petstore/javascript/README.md
+++ b/samples/client/petstore/javascript/README.md
@@ -6,7 +6,7 @@ Version: 1.0.0
Automatically generated by the JavaScript Swagger Codegen project:
-- Build date: 2016-03-17T16:01:44.795+08:00
+- Build date: 2016-03-18T12:55:58.976Z
- Build package: class io.swagger.codegen.languages.JavascriptClientCodegen
## Installation
@@ -116,25 +116,10 @@ Class | Method | HTTP request | Description
## Documentation for Authorization
-### petstore_auth
-
-- **Type**: OAuth
-- **Flow**: implicit
-- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog
-- **Scopes**:
- - write:pets: modify pets in your account
- - read:pets: read your pets
-
-### test_api_client_id
+### test_api_key_header
- **Type**: API key
-- **API key parameter name**: x-test_api_client_id
-- **Location**: HTTP header
-
-### test_api_client_secret
-
-- **Type**: API key
-- **API key parameter name**: x-test_api_client_secret
+- **API key parameter name**: test_api_key_header
- **Location**: HTTP header
### api_key
@@ -147,15 +132,30 @@ Class | Method | HTTP request | Description
- **Type**: HTTP basic authentication
+### test_api_client_secret
+
+- **Type**: API key
+- **API key parameter name**: x-test_api_client_secret
+- **Location**: HTTP header
+
+### test_api_client_id
+
+- **Type**: API key
+- **API key parameter name**: x-test_api_client_id
+- **Location**: HTTP header
+
### test_api_key_query
- **Type**: API key
- **API key parameter name**: test_api_key_query
- **Location**: URL query string
-### test_api_key_header
+### petstore_auth
-- **Type**: API key
-- **API key parameter name**: test_api_key_header
-- **Location**: HTTP header
+- **Type**: OAuth
+- **Flow**: implicit
+- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog
+- **Scopes**:
+ - write:pets: modify pets in your account
+ - read:pets: read your pets
diff --git a/samples/client/petstore/javascript/docs/InlineResponse200.md b/samples/client/petstore/javascript/docs/InlineResponse200.md
index 09b88b74e49..bbb11067e9a 100644
--- a/samples/client/petstore/javascript/docs/InlineResponse200.md
+++ b/samples/client/petstore/javascript/docs/InlineResponse200.md
@@ -3,11 +3,11 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
-**photoUrls** | **[String]** | | [optional]
-**name** | **String** | | [optional]
+**tags** | [**[Tag]**](Tag.md) | | [optional]
**id** | **Integer** | |
**category** | **Object** | | [optional]
-**tags** | [**[Tag]**](Tag.md) | | [optional]
**status** | **String** | pet status in the store | [optional]
+**name** | **String** | | [optional]
+**photoUrls** | **[String]** | | [optional]
diff --git a/samples/client/petstore/javascript/docs/PetApi.md b/samples/client/petstore/javascript/docs/PetApi.md
index b8a453ef390..254db8e2000 100644
--- a/samples/client/petstore/javascript/docs/PetApi.md
+++ b/samples/client/petstore/javascript/docs/PetApi.md
@@ -293,16 +293,16 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
-// Configure OAuth2 access token for authorization: petstore_auth
-var petstore_auth = defaultClient.authentications['petstore_auth'];
-petstore_auth.accessToken = "YOUR ACCESS TOKEN"
-
// Configure API key authorization: api_key
var api_key = defaultClient.authentications['api_key'];
api_key.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.apiKeyPrefix['api_key'] = "Token"
+// Configure OAuth2 access token for authorization: petstore_auth
+var petstore_auth = defaultClient.authentications['petstore_auth'];
+petstore_auth.accessToken = "YOUR ACCESS TOKEN"
+
var api = new SwaggerPetstore.PetApi()
var petId = 789; // {Integer} ID of pet that needs to be fetched
@@ -330,7 +330,7 @@ Name | Type | Description | Notes
### Authorization
-[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
+[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
### HTTP reuqest headers
@@ -350,16 +350,16 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
-// Configure OAuth2 access token for authorization: petstore_auth
-var petstore_auth = defaultClient.authentications['petstore_auth'];
-petstore_auth.accessToken = "YOUR ACCESS TOKEN"
-
// Configure API key authorization: api_key
var api_key = defaultClient.authentications['api_key'];
api_key.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.apiKeyPrefix['api_key'] = "Token"
+// Configure OAuth2 access token for authorization: petstore_auth
+var petstore_auth = defaultClient.authentications['petstore_auth'];
+petstore_auth.accessToken = "YOUR ACCESS TOKEN"
+
var api = new SwaggerPetstore.PetApi()
var petId = 789; // {Integer} ID of pet that needs to be fetched
@@ -387,7 +387,7 @@ Name | Type | Description | Notes
### Authorization
-[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
+[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
### HTTP reuqest headers
@@ -407,16 +407,16 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
-// Configure OAuth2 access token for authorization: petstore_auth
-var petstore_auth = defaultClient.authentications['petstore_auth'];
-petstore_auth.accessToken = "YOUR ACCESS TOKEN"
-
// Configure API key authorization: api_key
var api_key = defaultClient.authentications['api_key'];
api_key.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.apiKeyPrefix['api_key'] = "Token"
+// Configure OAuth2 access token for authorization: petstore_auth
+var petstore_auth = defaultClient.authentications['petstore_auth'];
+petstore_auth.accessToken = "YOUR ACCESS TOKEN"
+
var api = new SwaggerPetstore.PetApi()
var petId = 789; // {Integer} ID of pet that needs to be fetched
@@ -444,7 +444,7 @@ Name | Type | Description | Notes
### Authorization
-[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
+[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
### HTTP reuqest headers
diff --git a/samples/client/petstore/javascript/docs/StoreApi.md b/samples/client/petstore/javascript/docs/StoreApi.md
index fc4f9faf366..a5b6e4141b3 100644
--- a/samples/client/petstore/javascript/docs/StoreApi.md
+++ b/samples/client/petstore/javascript/docs/StoreApi.md
@@ -225,18 +225,18 @@ For valid response try integer IDs with value <= 5 or > 10. Other values w
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
-// Configure API key authorization: test_api_key_query
-var test_api_key_query = defaultClient.authentications['test_api_key_query'];
-test_api_key_query.apiKey = "YOUR API KEY"
-// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
-//test_api_key_query.apiKeyPrefix['test_api_key_query'] = "Token"
-
// Configure API key authorization: test_api_key_header
var test_api_key_header = defaultClient.authentications['test_api_key_header'];
test_api_key_header.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//test_api_key_header.apiKeyPrefix['test_api_key_header'] = "Token"
+// Configure API key authorization: test_api_key_query
+var test_api_key_query = defaultClient.authentications['test_api_key_query'];
+test_api_key_query.apiKey = "YOUR API KEY"
+// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
+//test_api_key_query.apiKeyPrefix['test_api_key_query'] = "Token"
+
var api = new SwaggerPetstore.StoreApi()
var orderId = "orderId_example"; // {String} ID of pet that needs to be fetched
@@ -264,7 +264,7 @@ Name | Type | Description | Notes
### Authorization
-[test_api_key_query](../README.md#test_api_key_query), [test_api_key_header](../README.md#test_api_key_header)
+[test_api_key_header](../README.md#test_api_key_header), [test_api_key_query](../README.md#test_api_key_query)
### HTTP reuqest headers
diff --git a/samples/client/petstore/javascript/src/ApiClient.js b/samples/client/petstore/javascript/src/ApiClient.js
index de889ee58e4..71dd888d7d9 100644
--- a/samples/client/petstore/javascript/src/ApiClient.js
+++ b/samples/client/petstore/javascript/src/ApiClient.js
@@ -15,50 +15,78 @@
}(this, function(superagent) {
'use strict';
- var ApiClient = function ApiClient() {
+ /**
+ * @module ApiClient
+ * @version 1.0.0
+ */
+
+ /**
+ * Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an
+ * application to use this class directly - the *Api and model classes provide the public API for the service. The
+ * contents of this file should be regarded as internal but are documented for completeness.
+ * @alias module:ApiClient
+ * @class
+ */
+ var exports = function() {
/**
- * The base path to put in front of every API call's (relative) path.
+ * The base URL against which to resolve every API call's (relative) path.
+ * @type {String}
+ * @default http://petstore.swagger.io/v2
*/
this.basePath = 'http://petstore.swagger.io/v2'.replace(/\/+$/, '');
+ /**
+ * The authentication methods to be included for all API calls.
+ * @type {Array.param
.
+ */
+ exports.prototype.paramToString = function(param) {
+ if (param == undefined || param == null) {
return '';
- } else if (param instanceof Date) {
- return param.toJSON();
- } else {
- return param.toString();
}
+ if (param instanceof Date) {
+ return param.toJSON();
+ }
+ return param.toString();
};
/**
- * Build full URL by appending the given path to base path and replacing
- * path parameter placeholders with parameter values.
+ * Builds full URL by appending the given path to the base URL and replacing path parameter place-holders with parameter values.
* NOTE: query parameters are not handled here.
+ * @param {String} path The path to append to the base URL.
+ * @param {Object} pathParams The parameter values to append.
+ * @returns {String} The encoded path with parameter values substituted.
*/
- ApiClient.prototype.buildUrl = function buildUrl(path, pathParams) {
+ exports.prototype.buildUrl = function(path, pathParams) {
if (!path.match(/^\//)) {
path = '/' + path;
}
@@ -77,34 +105,40 @@
};
/**
- * Check if the given MIME is a JSON MIME.
- * JSON MIME examples:
- * application/json
- * application/json; charset=UTF8
- * APPLICATION/JSON
+ * Checks whether the given content type represents JSON.true
if contentType
represents JSON, otherwise false
.
*/
- ApiClient.prototype.isJsonMime = function isJsonMime(mime) {
- return Boolean(mime != null && mime.match(/^application\/json(;.*)?$/i));
+ exports.prototype.isJsonMime = function(contentType) {
+ return Boolean(contentType != null && contentType.match(/^application\/json(;.*)?$/i));
};
/**
- * Choose a MIME from the given MIMEs with JSON preferred,
- * i.e. return JSON if included, otherwise return the first one.
+ * Chooses a content type from the given array, with JSON preferred; i.e. return JSON if included, otherwise return the first.
+ * @param {Array.true
if param
represents a file.
*/
- ApiClient.prototype.isFileParam = function isFileParam(param) {
+ exports.prototype.isFileParam = function(param) {
// fs.ReadStream in Node.js (but not in runtime like browserify)
if (typeof window === 'undefined' &&
typeof require === 'function' &&
@@ -128,15 +162,19 @@
};
/**
- * Normalize parameters values:
- * remove nils,
- * keep files and arrays,
- * format to string with `paramToString` for other cases.
+ * Normalizes parameter values:
+ * csv
+ * @const
+ */
+ CSV: ',',
+ /**
+ * Space-separated values. Value: ssv
+ * @const
+ */
+ SSV: ' ',
+ /**
+ * Tab-separated values. Value: tsv
+ * @const
+ */
+ TSV: '\t',
+ /**
+ * Pipe(|)-separated values. Value: pipes
+ * @const
+ */
+ PIPES: '|',
+ /**
+ * Native array. Value: multi
+ * @const
+ */
+ MULTI: 'multi'
+ };
+
+ /**
+ * Builds a string representation of an array-type actual parameter, according to the given collection format.
+ * @param {Array} param An array parameter.
+ * @param {module:ApiClient.CollectionFormatEnum} collectionFormat The array element separator strategy.
+ * @returns {String|Array} A string representation of the supplied collection, using the specified delimiter. Returns
+ * param
as is if collectionFormat
is multi
.
+ */
+ exports.prototype.buildCollectionParam = function buildCollectionParam(param, collectionFormat) {
if (param == null) {
return null;
}
@@ -166,14 +240,19 @@
case 'pipes':
return param.map(this.paramToString).join('|');
case 'multi':
- // return the array directly as Superagent will handle it as expected
+ // return the array directly as SuperAgent will handle it as expected
return param.map(this.paramToString);
default:
throw new Error('Unknown collection format: ' + collectionFormat);
}
};
- ApiClient.prototype.applyAuthToRequest = function applyAuthToRequest(request, authNames) {
+ /**
+ * Applies authentication headers to the request.
+ * @param {Object} request The request object created by a superagent()
call.
+ * @param {Array.data will be converted to this type.
+ * @returns A value of the specified type.
+ */
+ exports.prototype.deserialize = function deserialize(response, returnType) {
if (response == null || returnType == null) {
return null;
}
- // Rely on Superagent for parsing response body.
+ // Rely on SuperAgent for parsing response body.
// See http://visionmedia.github.io/superagent/#parsing-response-bodies
var data = response.body;
if (data == null) {
- // Superagent does not always produce a body; use the unparsed response
- // as a fallback
+ // SuperAgent does not always produce a body; use the unparsed response as a fallback
data = response.text;
}
- return ApiClient.convertToType(data, returnType);
+ return exports.convertToType(data, returnType);
};
- ApiClient.prototype.callApi = function callApi(path, httpMethod, pathParams,
- queryParams, headerParams, formParams, bodyParam, authNames, contentTypes,
- accepts, returnType, callback) {
+ /**
+ * Callback function to receive the result of the operation.
+ * @callback module:ApiClient~callApiCallback
+ * @param {String} error Error message, if any.
+ * @param data The data returned by the service call.
+ * @param {String} response The complete HTTP response.
+ */
+
+ /**
+ * Invokes the REST service using the supplied settings and parameters.
+ * @param {String} path The base URL to invoke.
+ * @param {String} httpMethod The HTTP method to use.
+ * @param {Object.} pathParams A map of path parameters and their values.
+ * @param {Object.} queryParams A map of query parameters and their values.
+ * @param {Object.} headerParams A map of header parameters and their values.
+ * @param {Object.} formParams A map of form parameters and their values.
+ * @param {Object} bodyParam The value to pass as the request body.
+ * @param {Array.} authNames An array of authentication type names.
+ * @param {Array.} contentTypes An array of request MIME types.
+ * @param {Array.} accepts An array of acceptable response MIME types.
+ * @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
+ * constructor for a complex type.
+ * @param {module:ApiClient~callApiCallback} callback The callback function.
+ * @returns {Object} The SuperAgent request object.
+ */
+ exports.prototype.callApi = function callApi(path, httpMethod, pathParams,
+ queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts,
+ returnType, callback) {
+
var _this = this;
var url = this.buildUrl(path, pathParams);
var request = superagent(httpMethod, url);
@@ -240,7 +353,7 @@
// set header parameters
request.set(this.defaultHeaders).set(this.normalizeParams(headerParams));
- //set request timeout
+ // set request timeout
request.timeout(this.timeout);
var contentType = this.jsonPreferredMime(contentTypes);
@@ -273,8 +386,7 @@
request.accept(accept);
}
-
-
+
request.end(function(error, response) {
if (callback) {
var data = null;
@@ -286,15 +398,27 @@
});
return request;
-
};
- ApiClient.parseDate = function parseDate(str) {
- str = str.replace(/T/i, ' ');
- return new Date(str);
+ /**
+ * Parses an ISO-8601 string representation of a date value.
+ * @param {String} str The date value as a string.
+ * @returns {Date} The parsed date object.
+ */
+ exports.parseDate = function(str) {
+ return new Date(str.replace(/T/i, ' '));
};
- ApiClient.convertToType = function convertToType(data, type) {
+ /**
+ * Converts a value to the specified type.
+ * @param {(String|Object)} data The data to convert, as a string or object.
+ * @param {(String|Array.|Object.|Function)} type The type to return. Pass a string for simple types
+ * or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
+ * return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
+ * all properties on data will be converted to this type.
+ * @returns An instance of the specified type.
+ */
+ exports.convertToType = function(data, type) {
switch (type) {
case 'Boolean':
return Boolean(data);
@@ -312,13 +436,12 @@
return data;
} else if (typeof type === 'function') {
// for model type like: User
- var model = type.constructFromObject(data);
- return model;
+ return type.constructFromObject(data);
} else if (Array.isArray(type)) {
// for array type like: ['String']
var itemType = type[0];
return data.map(function(item) {
- return ApiClient.convertToType(item, itemType);
+ return exports.convertToType(item, itemType);
});
} else if (typeof type === 'object') {
// for plain object type like: {'String': 'Integer'}
@@ -333,8 +456,8 @@
var result = {};
for (var k in data) {
if (data.hasOwnProperty(k)) {
- var key = ApiClient.convertToType(k, keyType);
- var value = ApiClient.convertToType(data[k], valueType);
+ var key = exports.convertToType(k, keyType);
+ var value = exports.convertToType(data[k], valueType);
result[key] = value;
}
}
@@ -346,7 +469,11 @@
}
};
- ApiClient.default = new ApiClient();
+ /**
+ * The default API client implementation.
+ * @type {module:ApiClient}
+ */
+ exports.instance = new exports();
- return ApiClient;
+ return exports;
}));
diff --git a/samples/client/petstore/javascript/src/api/PetApi.js b/samples/client/petstore/javascript/src/api/PetApi.js
index ce6c017a1bf..e1b4a79aa67 100644
--- a/samples/client/petstore/javascript/src/api/PetApi.js
+++ b/samples/client/petstore/javascript/src/api/PetApi.js
@@ -15,22 +15,42 @@
}(this, function(ApiClient, Pet, InlineResponse200) {
'use strict';
- var PetApi = function PetApi(apiClient) {
- this.apiClient = apiClient || ApiClient.default;
+ /**
+ * Pet service.
+ * @module api/PetApi
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new PetApi.
+ * @alias module:api/PetApi
+ * @class
+ * @param {module:ApiClient} apiClient Optional API client implementation to use, defaulting to {@link module:ApiClient#instance}
+ * if unspecified.
+ */
+ var exports = function(apiClient) {
+ this.apiClient = apiClient || ApiClient.instance;
+
+
+ /**
+ * Callback function to receive the result of the addPet operation.
+ * @callback module:api/PetApi~addPetCallback
+ * @param {String} error Error message, if any.
+ * @param data This operation does not return a value.
+ * @param {String} response The complete HTTP response.
+ */
- var self = this;
-
-
/**
* Add a new pet to the store
*
- * @param {Pet} opts['body'] Pet object that needs to be added to the store
- * @param {function} callback the callback function, accepting three arguments: error, data, response
+ * @param {Object} opts Optional parameters
+ * @param {module:model/Pet} opts.body Pet object that needs to be added to the store
+ * @param {module:api/PetApi~addPetCallback} callback The callback function, accepting three arguments: error, data, response
*/
- self.addPet = function(opts, callback) {
+ this.addPet = function(opts, callback) {
opts = opts || {};
var postBody = opts['body'];
-
+
var pathParams = {
};
@@ -51,19 +71,27 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the addPetUsingByteArray operation.
+ * @callback module:api/PetApi~addPetUsingByteArrayCallback
+ * @param {String} error Error message, if any.
+ * @param data This operation does not return a value.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Fake endpoint to test byte array in body parameter for adding a new pet to the store
*
- * @param {String} opts['body'] Pet object in the form of byte array
- * @param {function} callback the callback function, accepting three arguments: error, data, response
+ * @param {Object} opts Optional parameters
+ * @param {String} opts.body Pet object in the form of byte array
+ * @param {module:api/PetApi~addPetUsingByteArrayCallback} callback The callback function, accepting three arguments: error, data, response
*/
- self.addPetUsingByteArray = function(opts, callback) {
+ this.addPetUsingByteArray = function(opts, callback) {
opts = opts || {};
var postBody = opts['body'];
-
+
var pathParams = {
};
@@ -84,25 +112,33 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the deletePet operation.
+ * @callback module:api/PetApi~deletePetCallback
+ * @param {String} error Error message, if any.
+ * @param data This operation does not return a value.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Deletes a pet
*
* @param {Integer} petId Pet id to delete
- * @param {String} opts['apiKey']
- * @param {function} callback the callback function, accepting three arguments: error, data, response
+ * @param {Object} opts Optional parameters
+ * @param {String} opts.apiKey
+ * @param {module:api/PetApi~deletePetCallback} callback The callback function, accepting three arguments: error, data, response
*/
- self.deletePet = function(petId, opts, callback) {
+ this.deletePet = function(petId, opts, callback) {
opts = opts || {};
var postBody = null;
-
+
// verify the required parameter 'petId' is set
- if (petId == null) {
+ if (petId == undefined || petId == null) {
throw "Missing the required parameter 'petId' when calling deletePet";
}
-
+
var pathParams = {
'petId': petId
@@ -125,20 +161,28 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the findPetsByStatus operation.
+ * @callback module:api/PetApi~findPetsByStatusCallback
+ * @param {String} error Error message, if any.
+ * @param {Array.} data The data returned by the service call.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Finds Pets by status
* Multiple status values can be provided with comma separated strings
- * @param {[String]} opts['status'] Status values that need to be considered for query (default to available)
- * @param {function} callback the callback function, accepting three arguments: error, data, response
- * data is of type: [Pet]
+ * @param {Object} opts Optional parameters
+ * @param {Array.} opts.status Status values that need to be considered for query
+ * @param {module:api/PetApi~findPetsByStatusCallback} callback The callback function, accepting three arguments: error, data, response
+ * data is of type: {Array.}
*/
- self.findPetsByStatus = function(opts, callback) {
+ this.findPetsByStatus = function(opts, callback) {
opts = opts || {};
var postBody = null;
-
+
var pathParams = {
};
@@ -160,20 +204,28 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the findPetsByTags operation.
+ * @callback module:api/PetApi~findPetsByTagsCallback
+ * @param {String} error Error message, if any.
+ * @param {Array.} data The data returned by the service call.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Finds Pets by tags
* Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
- * @param {[String]} opts['tags'] Tags to filter by
- * @param {function} callback the callback function, accepting three arguments: error, data, response
- * data is of type: [Pet]
+ * @param {Object} opts Optional parameters
+ * @param {Array.} opts.tags Tags to filter by
+ * @param {module:api/PetApi~findPetsByTagsCallback} callback The callback function, accepting three arguments: error, data, response
+ * data is of type: {Array.}
*/
- self.findPetsByTags = function(opts, callback) {
+ this.findPetsByTags = function(opts, callback) {
opts = opts || {};
var postBody = null;
-
+
var pathParams = {
};
@@ -195,24 +247,31 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the getPetById operation.
+ * @callback module:api/PetApi~getPetByIdCallback
+ * @param {String} error Error message, if any.
+ * @param {module:model/Pet} data The data returned by the service call.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Find pet by ID
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
* @param {Integer} petId ID of pet that needs to be fetched
- * @param {function} callback the callback function, accepting three arguments: error, data, response
- * data is of type: Pet
+ * @param {module:api/PetApi~getPetByIdCallback} callback The callback function, accepting three arguments: error, data, response
+ * data is of type: {module:model/Pet}
*/
- self.getPetById = function(petId, callback) {
+ this.getPetById = function(petId, callback) {
var postBody = null;
-
+
// verify the required parameter 'petId' is set
- if (petId == null) {
+ if (petId == undefined || petId == null) {
throw "Missing the required parameter 'petId' when calling getPetById";
}
-
+
var pathParams = {
'petId': petId
@@ -224,7 +283,7 @@
var formParams = {
};
- var authNames = ['petstore_auth', 'api_key'];
+ var authNames = ['api_key', 'petstore_auth'];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var returnType = Pet;
@@ -234,24 +293,31 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the getPetByIdInObject operation.
+ * @callback module:api/PetApi~getPetByIdInObjectCallback
+ * @param {String} error Error message, if any.
+ * @param {module:model/InlineResponse200} data The data returned by the service call.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Fake endpoint to test inline arbitrary object return by 'Find pet by ID'
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
* @param {Integer} petId ID of pet that needs to be fetched
- * @param {function} callback the callback function, accepting three arguments: error, data, response
- * data is of type: InlineResponse200
+ * @param {module:api/PetApi~getPetByIdInObjectCallback} callback The callback function, accepting three arguments: error, data, response
+ * data is of type: {module:model/InlineResponse200}
*/
- self.getPetByIdInObject = function(petId, callback) {
+ this.getPetByIdInObject = function(petId, callback) {
var postBody = null;
-
+
// verify the required parameter 'petId' is set
- if (petId == null) {
+ if (petId == undefined || petId == null) {
throw "Missing the required parameter 'petId' when calling getPetByIdInObject";
}
-
+
var pathParams = {
'petId': petId
@@ -263,7 +329,7 @@
var formParams = {
};
- var authNames = ['petstore_auth', 'api_key'];
+ var authNames = ['api_key', 'petstore_auth'];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var returnType = InlineResponse200;
@@ -273,24 +339,31 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the petPetIdtestingByteArraytrueGet operation.
+ * @callback module:api/PetApi~petPetIdtestingByteArraytrueGetCallback
+ * @param {String} error Error message, if any.
+ * @param {'String'} data The data returned by the service call.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Fake endpoint to test byte array return by 'Find pet by ID'
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
* @param {Integer} petId ID of pet that needs to be fetched
- * @param {function} callback the callback function, accepting three arguments: error, data, response
- * data is of type: 'String'
+ * @param {module:api/PetApi~petPetIdtestingByteArraytrueGetCallback} callback The callback function, accepting three arguments: error, data, response
+ * data is of type: {'String'}
*/
- self.petPetIdtestingByteArraytrueGet = function(petId, callback) {
+ this.petPetIdtestingByteArraytrueGet = function(petId, callback) {
var postBody = null;
-
+
// verify the required parameter 'petId' is set
- if (petId == null) {
+ if (petId == undefined || petId == null) {
throw "Missing the required parameter 'petId' when calling petPetIdtestingByteArraytrueGet";
}
-
+
var pathParams = {
'petId': petId
@@ -302,7 +375,7 @@
var formParams = {
};
- var authNames = ['petstore_auth', 'api_key'];
+ var authNames = ['api_key', 'petstore_auth'];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var returnType = 'String';
@@ -312,19 +385,27 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the updatePet operation.
+ * @callback module:api/PetApi~updatePetCallback
+ * @param {String} error Error message, if any.
+ * @param data This operation does not return a value.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Update an existing pet
*
- * @param {Pet} opts['body'] Pet object that needs to be added to the store
- * @param {function} callback the callback function, accepting three arguments: error, data, response
+ * @param {Object} opts Optional parameters
+ * @param {module:model/Pet} opts.body Pet object that needs to be added to the store
+ * @param {module:api/PetApi~updatePetCallback} callback The callback function, accepting three arguments: error, data, response
*/
- self.updatePet = function(opts, callback) {
+ this.updatePet = function(opts, callback) {
opts = opts || {};
var postBody = opts['body'];
-
+
var pathParams = {
};
@@ -345,26 +426,34 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the updatePetWithForm operation.
+ * @callback module:api/PetApi~updatePetWithFormCallback
+ * @param {String} error Error message, if any.
+ * @param data This operation does not return a value.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Updates a pet in the store with form data
*
* @param {String} petId ID of pet that needs to be updated
- * @param {String} opts['name'] Updated name of the pet
- * @param {String} opts['status'] Updated status of the pet
- * @param {function} callback the callback function, accepting three arguments: error, data, response
+ * @param {Object} opts Optional parameters
+ * @param {String} opts.name Updated name of the pet
+ * @param {String} opts.status Updated status of the pet
+ * @param {module:api/PetApi~updatePetWithFormCallback} callback The callback function, accepting three arguments: error, data, response
*/
- self.updatePetWithForm = function(petId, opts, callback) {
+ this.updatePetWithForm = function(petId, opts, callback) {
opts = opts || {};
var postBody = null;
-
+
// verify the required parameter 'petId' is set
- if (petId == null) {
+ if (petId == undefined || petId == null) {
throw "Missing the required parameter 'petId' when calling updatePetWithForm";
}
-
+
var pathParams = {
'petId': petId
@@ -388,26 +477,34 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the uploadFile operation.
+ * @callback module:api/PetApi~uploadFileCallback
+ * @param {String} error Error message, if any.
+ * @param data This operation does not return a value.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* uploads an image
*
* @param {Integer} petId ID of pet to update
- * @param {String} opts['additionalMetadata'] Additional data to pass to server
- * @param {File} opts['file'] file to upload
- * @param {function} callback the callback function, accepting three arguments: error, data, response
+ * @param {Object} opts Optional parameters
+ * @param {String} opts.additionalMetadata Additional data to pass to server
+ * @param {File} opts.file file to upload
+ * @param {module:api/PetApi~uploadFileCallback} callback The callback function, accepting three arguments: error, data, response
*/
- self.uploadFile = function(petId, opts, callback) {
+ this.uploadFile = function(petId, opts, callback) {
opts = opts || {};
var postBody = null;
-
+
// verify the required parameter 'petId' is set
- if (petId == null) {
+ if (petId == undefined || petId == null) {
throw "Missing the required parameter 'petId' when calling uploadFile";
}
-
+
var pathParams = {
'petId': petId
@@ -431,11 +528,8 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
-
};
- return PetApi;
+ return exports;
}));
diff --git a/samples/client/petstore/javascript/src/api/StoreApi.js b/samples/client/petstore/javascript/src/api/StoreApi.js
index 1f2d80adf3e..da0cfffbc53 100644
--- a/samples/client/petstore/javascript/src/api/StoreApi.js
+++ b/samples/client/petstore/javascript/src/api/StoreApi.js
@@ -15,26 +15,45 @@
}(this, function(ApiClient, Order) {
'use strict';
- var StoreApi = function StoreApi(apiClient) {
- this.apiClient = apiClient || ApiClient.default;
+ /**
+ * Store service.
+ * @module api/StoreApi
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new StoreApi.
+ * @alias module:api/StoreApi
+ * @class
+ * @param {module:ApiClient} apiClient Optional API client implementation to use, defaulting to {@link module:ApiClient#instance}
+ * if unspecified.
+ */
+ var exports = function(apiClient) {
+ this.apiClient = apiClient || ApiClient.instance;
+
+
+ /**
+ * Callback function to receive the result of the deleteOrder operation.
+ * @callback module:api/StoreApi~deleteOrderCallback
+ * @param {String} error Error message, if any.
+ * @param data This operation does not return a value.
+ * @param {String} response The complete HTTP response.
+ */
- var self = this;
-
-
/**
* 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
- * @param {function} callback the callback function, accepting three arguments: error, data, response
+ * @param {module:api/StoreApi~deleteOrderCallback} callback The callback function, accepting three arguments: error, data, response
*/
- self.deleteOrder = function(orderId, callback) {
+ this.deleteOrder = function(orderId, callback) {
var postBody = null;
-
+
// verify the required parameter 'orderId' is set
- if (orderId == null) {
+ if (orderId == undefined || orderId == null) {
throw "Missing the required parameter 'orderId' when calling deleteOrder";
}
-
+
var pathParams = {
'orderId': orderId
@@ -56,20 +75,28 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the findOrdersByStatus operation.
+ * @callback module:api/StoreApi~findOrdersByStatusCallback
+ * @param {String} error Error message, if any.
+ * @param {Array.} data The data returned by the service call.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* 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 (default to placed)
- * @param {function} callback the callback function, accepting three arguments: error, data, response
- * data is of type: [Order]
+ * @param {Object} opts Optional parameters
+ * @param {module:model/String} opts.status Status value that needs to be considered for query
+ * @param {module:api/StoreApi~findOrdersByStatusCallback} callback The callback function, accepting three arguments: error, data, response
+ * data is of type: {Array.}
*/
- self.findOrdersByStatus = function(opts, callback) {
+ this.findOrdersByStatus = function(opts, callback) {
opts = opts || {};
var postBody = null;
-
+
var pathParams = {
};
@@ -91,18 +118,25 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the getInventory operation.
+ * @callback module:api/StoreApi~getInventoryCallback
+ * @param {String} error Error message, if any.
+ * @param {Object.} data The data returned by the service call.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
- * @param {function} callback the callback function, accepting three arguments: error, data, response
- * data is of type: {'String': 'Integer'}
+ * @param {module:api/StoreApi~getInventoryCallback} callback The callback function, accepting three arguments: error, data, response
+ * data is of type: {Object.}
*/
- self.getInventory = function(callback) {
+ this.getInventory = function(callback) {
var postBody = null;
-
+
var pathParams = {
};
@@ -123,18 +157,25 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the getInventoryInObject operation.
+ * @callback module:api/StoreApi~getInventoryInObjectCallback
+ * @param {String} error Error message, if any.
+ * @param {Object} data The data returned by the service call.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Fake endpoint to test arbitrary object return by 'Get inventory'
* Returns an arbitrary object which is actually a map of status codes to quantities
- * @param {function} callback the callback function, accepting three arguments: error, data, response
- * data is of type: Object
+ * @param {module:api/StoreApi~getInventoryInObjectCallback} callback The callback function, accepting three arguments: error, data, response
+ * data is of type: {Object}
*/
- self.getInventoryInObject = function(callback) {
+ this.getInventoryInObject = function(callback) {
var postBody = null;
-
+
var pathParams = {
};
@@ -155,24 +196,31 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the getOrderById operation.
+ * @callback module:api/StoreApi~getOrderByIdCallback
+ * @param {String} error Error message, if any.
+ * @param {module:model/Order} data The data returned by the service call.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Find purchase order by ID
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
* @param {String} orderId ID of pet that needs to be fetched
- * @param {function} callback the callback function, accepting three arguments: error, data, response
- * data is of type: Order
+ * @param {module:api/StoreApi~getOrderByIdCallback} callback The callback function, accepting three arguments: error, data, response
+ * data is of type: {module:model/Order}
*/
- self.getOrderById = function(orderId, callback) {
+ this.getOrderById = function(orderId, callback) {
var postBody = null;
-
+
// verify the required parameter 'orderId' is set
- if (orderId == null) {
+ if (orderId == undefined || orderId == null) {
throw "Missing the required parameter 'orderId' when calling getOrderById";
}
-
+
var pathParams = {
'orderId': orderId
@@ -184,7 +232,7 @@
var formParams = {
};
- var authNames = ['test_api_key_query', 'test_api_key_header'];
+ var authNames = ['test_api_key_header', 'test_api_key_query'];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var returnType = Order;
@@ -194,20 +242,28 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the placeOrder operation.
+ * @callback module:api/StoreApi~placeOrderCallback
+ * @param {String} error Error message, if any.
+ * @param {module:model/Order} data The data returned by the service call.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Place an order for a pet
*
- * @param {Order} opts['body'] order placed for purchasing the pet
- * @param {function} callback the callback function, accepting three arguments: error, data, response
- * data is of type: Order
+ * @param {Object} opts Optional parameters
+ * @param {module:model/Order} opts.body order placed for purchasing the pet
+ * @param {module:api/StoreApi~placeOrderCallback} callback The callback function, accepting three arguments: error, data, response
+ * data is of type: {module:model/Order}
*/
- self.placeOrder = function(opts, callback) {
+ this.placeOrder = function(opts, callback) {
opts = opts || {};
var postBody = opts['body'];
-
+
var pathParams = {
};
@@ -228,11 +284,8 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
-
};
- return StoreApi;
+ return exports;
}));
diff --git a/samples/client/petstore/javascript/src/api/UserApi.js b/samples/client/petstore/javascript/src/api/UserApi.js
index e6b14e6e45a..bf23fe550a5 100644
--- a/samples/client/petstore/javascript/src/api/UserApi.js
+++ b/samples/client/petstore/javascript/src/api/UserApi.js
@@ -15,22 +15,42 @@
}(this, function(ApiClient, User) {
'use strict';
- var UserApi = function UserApi(apiClient) {
- this.apiClient = apiClient || ApiClient.default;
+ /**
+ * User service.
+ * @module api/UserApi
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new UserApi.
+ * @alias module:api/UserApi
+ * @class
+ * @param {module:ApiClient} apiClient Optional API client implementation to use, defaulting to {@link module:ApiClient#instance}
+ * if unspecified.
+ */
+ var exports = function(apiClient) {
+ this.apiClient = apiClient || ApiClient.instance;
+
+
+ /**
+ * Callback function to receive the result of the createUser operation.
+ * @callback module:api/UserApi~createUserCallback
+ * @param {String} error Error message, if any.
+ * @param data This operation does not return a value.
+ * @param {String} response The complete HTTP response.
+ */
- var self = this;
-
-
/**
* Create user
* This can only be done by the logged in user.
- * @param {User} opts['body'] Created user object
- * @param {function} callback the callback function, accepting three arguments: error, data, response
+ * @param {Object} opts Optional parameters
+ * @param {module:model/User} opts.body Created user object
+ * @param {module:api/UserApi~createUserCallback} callback The callback function, accepting three arguments: error, data, response
*/
- self.createUser = function(opts, callback) {
+ this.createUser = function(opts, callback) {
opts = opts || {};
var postBody = opts['body'];
-
+
var pathParams = {
};
@@ -51,19 +71,27 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the createUsersWithArrayInput operation.
+ * @callback module:api/UserApi~createUsersWithArrayInputCallback
+ * @param {String} error Error message, if any.
+ * @param data This operation does not return a value.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Creates list of users with given input array
*
- * @param {[User]} opts['body'] List of user object
- * @param {function} callback the callback function, accepting three arguments: error, data, response
+ * @param {Object} opts Optional parameters
+ * @param {Array.} opts.body List of user object
+ * @param {module:api/UserApi~createUsersWithArrayInputCallback} callback The callback function, accepting three arguments: error, data, response
*/
- self.createUsersWithArrayInput = function(opts, callback) {
+ this.createUsersWithArrayInput = function(opts, callback) {
opts = opts || {};
var postBody = opts['body'];
-
+
var pathParams = {
};
@@ -84,19 +112,27 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the createUsersWithListInput operation.
+ * @callback module:api/UserApi~createUsersWithListInputCallback
+ * @param {String} error Error message, if any.
+ * @param data This operation does not return a value.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Creates list of users with given input array
*
- * @param {[User]} opts['body'] List of user object
- * @param {function} callback the callback function, accepting three arguments: error, data, response
+ * @param {Object} opts Optional parameters
+ * @param {Array.} opts.body List of user object
+ * @param {module:api/UserApi~createUsersWithListInputCallback} callback The callback function, accepting three arguments: error, data, response
*/
- self.createUsersWithListInput = function(opts, callback) {
+ this.createUsersWithListInput = function(opts, callback) {
opts = opts || {};
var postBody = opts['body'];
-
+
var pathParams = {
};
@@ -117,23 +153,30 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the deleteUser operation.
+ * @callback module:api/UserApi~deleteUserCallback
+ * @param {String} error Error message, if any.
+ * @param data This operation does not return a value.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Delete user
* This can only be done by the logged in user.
* @param {String} username The name that needs to be deleted
- * @param {function} callback the callback function, accepting three arguments: error, data, response
+ * @param {module:api/UserApi~deleteUserCallback} callback The callback function, accepting three arguments: error, data, response
*/
- self.deleteUser = function(username, callback) {
+ this.deleteUser = function(username, callback) {
var postBody = null;
-
+
// verify the required parameter 'username' is set
- if (username == null) {
+ if (username == undefined || username == null) {
throw "Missing the required parameter 'username' when calling deleteUser";
}
-
+
var pathParams = {
'username': username
@@ -155,24 +198,31 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the getUserByName operation.
+ * @callback module:api/UserApi~getUserByNameCallback
+ * @param {String} error Error message, if any.
+ * @param {module:model/User} data The data returned by the service call.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Get user by user name
*
* @param {String} username The name that needs to be fetched. Use user1 for testing.
- * @param {function} callback the callback function, accepting three arguments: error, data, response
- * data is of type: User
+ * @param {module:api/UserApi~getUserByNameCallback} callback The callback function, accepting three arguments: error, data, response
+ * data is of type: {module:model/User}
*/
- self.getUserByName = function(username, callback) {
+ this.getUserByName = function(username, callback) {
var postBody = null;
-
+
// verify the required parameter 'username' is set
- if (username == null) {
+ if (username == undefined || username == null) {
throw "Missing the required parameter 'username' when calling getUserByName";
}
-
+
var pathParams = {
'username': username
@@ -194,21 +244,29 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the loginUser operation.
+ * @callback module:api/UserApi~loginUserCallback
+ * @param {String} error Error message, if any.
+ * @param {'String'} data The data returned by the service call.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Logs user into the system
*
- * @param {String} opts['username'] The user name for login
- * @param {String} opts['password'] The password for login in clear text
- * @param {function} callback the callback function, accepting three arguments: error, data, response
- * data is of type: 'String'
+ * @param {Object} opts Optional parameters
+ * @param {String} opts.username The user name for login
+ * @param {String} opts.password The password for login in clear text
+ * @param {module:api/UserApi~loginUserCallback} callback The callback function, accepting three arguments: error, data, response
+ * data is of type: {'String'}
*/
- self.loginUser = function(opts, callback) {
+ this.loginUser = function(opts, callback) {
opts = opts || {};
var postBody = null;
-
+
var pathParams = {
};
@@ -231,17 +289,24 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the logoutUser operation.
+ * @callback module:api/UserApi~logoutUserCallback
+ * @param {String} error Error message, if any.
+ * @param data This operation does not return a value.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Logs out current logged in user session
*
- * @param {function} callback the callback function, accepting three arguments: error, data, response
+ * @param {module:api/UserApi~logoutUserCallback} callback The callback function, accepting three arguments: error, data, response
*/
- self.logoutUser = function(callback) {
+ this.logoutUser = function(callback) {
var postBody = null;
-
+
var pathParams = {
};
@@ -262,25 +327,33 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
+
+ /**
+ * Callback function to receive the result of the updateUser operation.
+ * @callback module:api/UserApi~updateUserCallback
+ * @param {String} error Error message, if any.
+ * @param data This operation does not return a value.
+ * @param {String} response The complete HTTP response.
+ */
+
/**
* Updated user
* This can only be done by the logged in user.
* @param {String} username name that need to be deleted
- * @param {User} opts['body'] Updated user object
- * @param {function} callback the callback function, accepting three arguments: error, data, response
+ * @param {Object} opts Optional parameters
+ * @param {module:model/User} opts.body Updated user object
+ * @param {module:api/UserApi~updateUserCallback} callback The callback function, accepting three arguments: error, data, response
*/
- self.updateUser = function(username, opts, callback) {
+ this.updateUser = function(username, opts, callback) {
opts = opts || {};
var postBody = opts['body'];
-
+
// verify the required parameter 'username' is set
- if (username == null) {
+ if (username == undefined || username == null) {
throw "Missing the required parameter 'username' when calling updateUser";
}
-
+
var pathParams = {
'username': username
@@ -302,11 +375,8 @@
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
-
}
-
-
};
- return UserApi;
+ return exports;
}));
diff --git a/samples/client/petstore/javascript/src/index.js b/samples/client/petstore/javascript/src/index.js
index dfc123e3584..4c0cd3040c7 100644
--- a/samples/client/petstore/javascript/src/index.js
+++ b/samples/client/petstore/javascript/src/index.js
@@ -9,20 +9,109 @@
}(function(ApiClient, Category, InlineResponse200, Model200Response, ModelReturn, Name, Order, Pet, SpecialModelName, Tag, User, PetApi, StoreApi, UserApi) {
'use strict';
- return {
+ /**
+ * This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters.
+ * The index
module provides access to constructors for all the classes which comprise the public API.
+ *
+ * An AMD (recommended!) or CommonJS application will generally do something equivalent to the following:
+ *
+ * var SwaggerPetstore = require('./index'); // See note below*.
+ * var xxxSvc = new SwaggerPetstore.XxxApi(); // Allocate the API class we're going to use.
+ * var yyyModel = new SwaggerPetstore.Yyy(); // Construct a model instance.
+ * yyyModel.someProperty = 'someValue';
+ * ...
+ * var zzz = xxxSvc.doSomething(yyyModel); // Invoke the service.
+ * ...
+ *
+ * *NOTE: For a top-level AMD script, use require(['./index'], function(){...}) and put the application logic within the
+ * callback function.
+ *
+ *
+ * A non-AMD browser application (discouraged) might do something like this:
+ *
+ * var xxxSvc = new SwaggerPetstore.XxxApi(); // Allocate the API class we're going to use.
+ * var yyy = new SwaggerPetstore.Yyy(); // Construct a model instance.
+ * yyyModel.someProperty = 'someValue';
+ * ...
+ * var zzz = xxxSvc.doSomething(yyyModel); // Invoke the service.
+ * ...
+ *
+ *
+ * @module index
+ * @version 1.0.0
+ */
+ var exports = {
+ /**
+ * The ApiClient constructor.
+ * @property {module:ApiClient}
+ */
ApiClient: ApiClient,
+ /**
+ * The Category model constructor.
+ * @property {module:model/Category}
+ */
Category: Category,
+ /**
+ * The InlineResponse200 model constructor.
+ * @property {module:model/InlineResponse200}
+ */
InlineResponse200: InlineResponse200,
+ /**
+ * The Model200Response model constructor.
+ * @property {module:model/Model200Response}
+ */
Model200Response: Model200Response,
+ /**
+ * The ModelReturn model constructor.
+ * @property {module:model/ModelReturn}
+ */
ModelReturn: ModelReturn,
+ /**
+ * The Name model constructor.
+ * @property {module:model/Name}
+ */
Name: Name,
+ /**
+ * The Order model constructor.
+ * @property {module:model/Order}
+ */
Order: Order,
+ /**
+ * The Pet model constructor.
+ * @property {module:model/Pet}
+ */
Pet: Pet,
+ /**
+ * The SpecialModelName model constructor.
+ * @property {module:model/SpecialModelName}
+ */
SpecialModelName: SpecialModelName,
+ /**
+ * The Tag model constructor.
+ * @property {module:model/Tag}
+ */
Tag: Tag,
+ /**
+ * The User model constructor.
+ * @property {module:model/User}
+ */
User: User,
+ /**
+ * The PetApi service constructor.
+ * @property {module:api/PetApi}
+ */
PetApi: PetApi,
+ /**
+ * The StoreApi service constructor.
+ * @property {module:api/StoreApi}
+ */
StoreApi: StoreApi,
+ /**
+ * The UserApi service constructor.
+ * @property {module:api/UserApi}
+ */
UserApi: UserApi
};
+
+ return exports;
}));
diff --git a/samples/client/petstore/javascript/src/model/Category.js b/samples/client/petstore/javascript/src/model/Category.js
index de7e6a15ddd..473f4b783d5 100644
--- a/samples/client/petstore/javascript/src/model/Category.js
+++ b/samples/client/petstore/javascript/src/model/Category.js
@@ -14,64 +14,58 @@
}
}(this, function(ApiClient) {
'use strict';
-
-
- var Category = function Category() {
-
+
+ /**
+ * The Category model module.
+ * @module model/Category
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new Category
.
+ * @alias module:model/Category
+ * @class
+ */
+ var exports = function() {
+
+
+
};
- Category.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a Category
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/Category} obj Optional instance to populate.
+ * @return {module:model/Category} The populated Category
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('id')) {
+ obj['id'] = ApiClient.convertToType(data['id'], 'Integer');
+ }
+ if (data.hasOwnProperty('name')) {
+ obj['name'] = ApiClient.convertToType(data['name'], 'String');
+ }
}
- var _this = new Category();
-
- if (data['id']) {
- _this['id'] = ApiClient.convertToType(data['id'], 'Integer');
- }
-
- if (data['name']) {
- _this['name'] = ApiClient.convertToType(data['name'], 'String');
- }
-
- return _this;
+ return obj;
}
-
-
- /**
- * @return {Integer}
- **/
- Category.prototype.getId = function() {
- return this['id'];
- }
/**
- * @param {Integer} id
- **/
- Category.prototype.setId = function(id) {
- this['id'] = id;
- }
-
- /**
- * @return {String}
- **/
- Category.prototype.getName = function() {
- return this['name'];
- }
+ * @member {Integer} id
+ */
+ exports.prototype['id'] = undefined;
/**
- * @param {String} name
- **/
- Category.prototype.setName = function(name) {
- this['name'] = name;
- }
-
-
+ * @member {String} name
+ */
+ exports.prototype['name'] = undefined;
-
- return Category;
-
-
+
+
+ return exports;
}));
diff --git a/samples/client/petstore/javascript/src/model/InlineResponse200.js b/samples/client/petstore/javascript/src/model/InlineResponse200.js
index 2afc6996266..f9ecda79491 100644
--- a/samples/client/petstore/javascript/src/model/InlineResponse200.js
+++ b/samples/client/petstore/javascript/src/model/InlineResponse200.js
@@ -14,162 +14,119 @@
}
}(this, function(ApiClient, Tag) {
'use strict';
-
-
- var InlineResponse200 = function InlineResponse200(id) {
+
+ /**
+ * The InlineResponse200 model module.
+ * @module model/InlineResponse200
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new InlineResponse200
.
+ * @alias module:model/InlineResponse200
+ * @class
+ * @param id
+ */
+ var exports = function(id) {
+
+
+ this['id'] = id;
+
+
+
+
+ };
+
+ /**
+ * Constructs a InlineResponse200
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/InlineResponse200} obj Optional instance to populate.
+ * @return {module:model/InlineResponse200} The populated InlineResponse200
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('tags')) {
+ obj['tags'] = ApiClient.convertToType(data['tags'], [Tag]);
+ }
+ if (data.hasOwnProperty('id')) {
+ obj['id'] = ApiClient.convertToType(data['id'], 'Integer');
+ }
+ if (data.hasOwnProperty('category')) {
+ obj['category'] = ApiClient.convertToType(data['category'], Object);
+ }
+ if (data.hasOwnProperty('status')) {
+ obj['status'] = ApiClient.convertToType(data['status'], 'String');
+ }
+ if (data.hasOwnProperty('name')) {
+ obj['name'] = ApiClient.convertToType(data['name'], 'String');
+ }
+ if (data.hasOwnProperty('photoUrls')) {
+ obj['photoUrls'] = ApiClient.convertToType(data['photoUrls'], ['String']);
+ }
+ }
+ return obj;
+ }
+
+
+ /**
+ * @member {Array.} tags
+ */
+ exports.prototype['tags'] = undefined;
+
+ /**
+ * @member {Integer} id
+ */
+ exports.prototype['id'] = undefined;
+
+ /**
+ * @member {Object} category
+ */
+ exports.prototype['category'] = undefined;
+
+ /**
+ * pet status in the store
+ * @member {module:model/InlineResponse200.StatusEnum} status
+ */
+ exports.prototype['status'] = undefined;
+
+ /**
+ * @member {String} name
+ */
+ exports.prototype['name'] = undefined;
+
+ /**
+ * @member {Array.} photoUrls
+ */
+ exports.prototype['photoUrls'] = undefined;
+
+
+ /**
+ * Allowed values for the status
property.
+ * @enum {String}
+ * @readonly
+ */
+ exports.StatusEnum = {
+ /**
+ * value: available
+ * @const
+ */
+ AVAILABLE: "available",
/**
- * datatype: Integer
- * required
- **/
- this['id'] = id;
+ * value: pending
+ * @const
+ */
+ PENDING: "pending",
+
+ /**
+ * value: sold
+ * @const
+ */
+ SOLD: "sold"
};
- InlineResponse200.constructFromObject = function(data) {
- if (!data) {
- return null;
- }
- var _this = new InlineResponse200();
-
- if (data['photoUrls']) {
- _this['photoUrls'] = ApiClient.convertToType(data['photoUrls'], ['String']);
- }
-
- if (data['name']) {
- _this['name'] = ApiClient.convertToType(data['name'], 'String');
- }
-
- if (data['id']) {
- _this['id'] = ApiClient.convertToType(data['id'], 'Integer');
- }
-
- if (data['category']) {
- _this['category'] = ApiClient.convertToType(data['category'], Object);
- }
-
- if (data['tags']) {
- _this['tags'] = ApiClient.convertToType(data['tags'], [Tag]);
- }
-
- if (data['status']) {
- _this['status'] = ApiClient.convertToType(data['status'], 'String');
- }
-
- return _this;
- }
-
-
-
- /**
- * @return {[String]}
- **/
- InlineResponse200.prototype.getPhotoUrls = function() {
- return this['photoUrls'];
- }
-
- /**
- * @param {[String]} photoUrls
- **/
- InlineResponse200.prototype.setPhotoUrls = function(photoUrls) {
- this['photoUrls'] = photoUrls;
- }
-
- /**
- * @return {String}
- **/
- InlineResponse200.prototype.getName = function() {
- return this['name'];
- }
-
- /**
- * @param {String} name
- **/
- InlineResponse200.prototype.setName = function(name) {
- this['name'] = name;
- }
-
- /**
- * @return {Integer}
- **/
- InlineResponse200.prototype.getId = function() {
- return this['id'];
- }
-
- /**
- * @param {Integer} id
- **/
- InlineResponse200.prototype.setId = function(id) {
- this['id'] = id;
- }
-
- /**
- * @return {Object}
- **/
- InlineResponse200.prototype.getCategory = function() {
- return this['category'];
- }
-
- /**
- * @param {Object} category
- **/
- InlineResponse200.prototype.setCategory = function(category) {
- this['category'] = category;
- }
-
- /**
- * @return {[Tag]}
- **/
- InlineResponse200.prototype.getTags = function() {
- return this['tags'];
- }
-
- /**
- * @param {[Tag]} tags
- **/
- InlineResponse200.prototype.setTags = function(tags) {
- this['tags'] = tags;
- }
-
- /**
- * get pet status in the store
- * @return {StatusEnum}
- **/
- InlineResponse200.prototype.getStatus = function() {
- return this['status'];
- }
-
- /**
- * set pet status in the store
- * @param {StatusEnum} status
- **/
- InlineResponse200.prototype.setStatus = function(status) {
- this['status'] = status;
- }
-
-
-
- var StatusEnum = {
-
- /**
- * @const
- */
- AVAILABLE: "available",
-
- /**
- * @const
- */
- PENDING: "pending",
-
- /**
- * @const
- */
- SOLD: "sold"
- };
-
- InlineResponse200.StatusEnum = StatusEnum;
-
-
- return InlineResponse200;
-
-
+ return exports;
}));
diff --git a/samples/client/petstore/javascript/src/model/Model200Response.js b/samples/client/petstore/javascript/src/model/Model200Response.js
index eab775e7476..fb559f5ebaa 100644
--- a/samples/client/petstore/javascript/src/model/Model200Response.js
+++ b/samples/client/petstore/javascript/src/model/Model200Response.js
@@ -14,46 +14,49 @@
}
}(this, function(ApiClient) {
'use strict';
-
-
- var Model200Response = function Model200Response() {
-
+
+ /**
+ * The Model200Response model module.
+ * @module model/Model200Response
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new Model200Response
.
+ * @alias module:model/Model200Response
+ * @class
+ */
+ var exports = function() {
+
+
};
- Model200Response.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a Model200Response
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/Model200Response} obj Optional instance to populate.
+ * @return {module:model/Model200Response} The populated Model200Response
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('name')) {
+ obj['name'] = ApiClient.convertToType(data['name'], 'Integer');
+ }
}
- var _this = new Model200Response();
-
- if (data['name']) {
- _this['name'] = ApiClient.convertToType(data['name'], 'Integer');
- }
-
- return _this;
+ return obj;
}
-
-
- /**
- * @return {Integer}
- **/
- Model200Response.prototype.getName = function() {
- return this['name'];
- }
/**
- * @param {Integer} name
- **/
- Model200Response.prototype.setName = function(name) {
- this['name'] = name;
- }
-
-
+ * @member {Integer} name
+ */
+ exports.prototype['name'] = undefined;
-
- return Model200Response;
-
-
+
+
+ return exports;
}));
diff --git a/samples/client/petstore/javascript/src/model/ModelReturn.js b/samples/client/petstore/javascript/src/model/ModelReturn.js
index e93e4de28f6..d5036e230ea 100644
--- a/samples/client/petstore/javascript/src/model/ModelReturn.js
+++ b/samples/client/petstore/javascript/src/model/ModelReturn.js
@@ -14,46 +14,49 @@
}
}(this, function(ApiClient) {
'use strict';
-
-
- var ModelReturn = function ModelReturn() {
-
+
+ /**
+ * The ModelReturn model module.
+ * @module model/ModelReturn
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new ModelReturn
.
+ * @alias module:model/ModelReturn
+ * @class
+ */
+ var exports = function() {
+
+
};
- ModelReturn.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a ModelReturn
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/ModelReturn} obj Optional instance to populate.
+ * @return {module:model/ModelReturn} The populated ModelReturn
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('return')) {
+ obj['return'] = ApiClient.convertToType(data['return'], 'Integer');
+ }
}
- var _this = new ModelReturn();
-
- if (data['return']) {
- _this['return'] = ApiClient.convertToType(data['return'], 'Integer');
- }
-
- return _this;
+ return obj;
}
-
-
- /**
- * @return {Integer}
- **/
- ModelReturn.prototype.getReturn = function() {
- return this['return'];
- }
/**
- * @param {Integer} _return
- **/
- ModelReturn.prototype.setReturn = function(_return) {
- this['return'] = _return;
- }
-
-
+ * @member {Integer} return
+ */
+ exports.prototype['return'] = undefined;
-
- return ModelReturn;
-
-
+
+
+ return exports;
}));
diff --git a/samples/client/petstore/javascript/src/model/Name.js b/samples/client/petstore/javascript/src/model/Name.js
index 8367c1b1e62..20aa186bd97 100644
--- a/samples/client/petstore/javascript/src/model/Name.js
+++ b/samples/client/petstore/javascript/src/model/Name.js
@@ -14,46 +14,49 @@
}
}(this, function(ApiClient) {
'use strict';
-
-
- var Name = function Name() {
-
+
+ /**
+ * The Name model module.
+ * @module model/Name
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new Name
.
+ * @alias module:model/Name
+ * @class
+ */
+ var exports = function() {
+
+
};
- Name.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a Name
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/Name} obj Optional instance to populate.
+ * @return {module:model/Name} The populated Name
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('name')) {
+ obj['name'] = ApiClient.convertToType(data['name'], 'Integer');
+ }
}
- var _this = new Name();
-
- if (data['name']) {
- _this['name'] = ApiClient.convertToType(data['name'], 'Integer');
- }
-
- return _this;
+ return obj;
}
-
-
- /**
- * @return {Integer}
- **/
- Name.prototype.getName = function() {
- return this['name'];
- }
/**
- * @param {Integer} name
- **/
- Name.prototype.setName = function(name) {
- this['name'] = name;
- }
-
-
+ * @member {Integer} name
+ */
+ exports.prototype['name'] = undefined;
-
- return Name;
-
-
+
+
+ return exports;
}));
diff --git a/samples/client/petstore/javascript/src/model/ObjectReturn.js b/samples/client/petstore/javascript/src/model/ObjectReturn.js
deleted file mode 100644
index b0da87d8465..00000000000
--- a/samples/client/petstore/javascript/src/model/ObjectReturn.js
+++ /dev/null
@@ -1,59 +0,0 @@
-(function(root, factory) {
- if (typeof define === 'function' && define.amd) {
- // AMD. Register as an anonymous module.
- define(['../ApiClient'], factory);
- } else if (typeof module === 'object' && module.exports) {
- // CommonJS-like environments that support module.exports, like Node.
- module.exports = factory(require('../ApiClient'));
- } else {
- // Browser globals (root is window)
- if (!root.SwaggerPetstore) {
- root.SwaggerPetstore = {};
- }
- root.SwaggerPetstore.ObjectReturn = factory(root.SwaggerPetstore.ApiClient);
- }
-}(this, function(ApiClient) {
- 'use strict';
-
-
- var ObjectReturn = function ObjectReturn() {
-
- };
-
- ObjectReturn.constructFromObject = function(data) {
- if (!data) {
- return null;
- }
- var _this = new ObjectReturn();
-
- if (data['return']) {
- _this['return'] = ApiClient.convertToType(data['return'], 'Integer');
- }
-
- return _this;
- }
-
-
-
- /**
- * @return {Integer}
- **/
- ObjectReturn.prototype.getReturn = function() {
- return this['return'];
- }
-
- /**
- * @param {Integer} _return
- **/
- ObjectReturn.prototype.setReturn = function(_return) {
- this['return'] = _return;
- }
-
-
-
-
-
- return ObjectReturn;
-
-
-}));
diff --git a/samples/client/petstore/javascript/src/model/Order.js b/samples/client/petstore/javascript/src/model/Order.js
index a33323e8ca3..81f1feb7800 100644
--- a/samples/client/petstore/javascript/src/model/Order.js
+++ b/samples/client/petstore/javascript/src/model/Order.js
@@ -14,157 +14,118 @@
}
}(this, function(ApiClient) {
'use strict';
-
-
- var Order = function Order() {
-
+
+ /**
+ * The Order model module.
+ * @module model/Order
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new Order
.
+ * @alias module:model/Order
+ * @class
+ */
+ var exports = function() {
+
+
+
+
+
+
+
};
- Order.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a Order
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/Order} obj Optional instance to populate.
+ * @return {module:model/Order} The populated Order
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('id')) {
+ obj['id'] = ApiClient.convertToType(data['id'], 'Integer');
+ }
+ if (data.hasOwnProperty('petId')) {
+ obj['petId'] = ApiClient.convertToType(data['petId'], 'Integer');
+ }
+ if (data.hasOwnProperty('quantity')) {
+ obj['quantity'] = ApiClient.convertToType(data['quantity'], 'Integer');
+ }
+ if (data.hasOwnProperty('shipDate')) {
+ obj['shipDate'] = ApiClient.convertToType(data['shipDate'], 'Date');
+ }
+ if (data.hasOwnProperty('status')) {
+ obj['status'] = ApiClient.convertToType(data['status'], 'String');
+ }
+ if (data.hasOwnProperty('complete')) {
+ obj['complete'] = ApiClient.convertToType(data['complete'], 'Boolean');
+ }
}
- var _this = new Order();
+ return obj;
+ }
+
+
+ /**
+ * @member {Integer} id
+ */
+ exports.prototype['id'] = undefined;
+
+ /**
+ * @member {Integer} petId
+ */
+ exports.prototype['petId'] = undefined;
+
+ /**
+ * @member {Integer} quantity
+ */
+ exports.prototype['quantity'] = undefined;
+
+ /**
+ * @member {Date} shipDate
+ */
+ exports.prototype['shipDate'] = undefined;
+
+ /**
+ * Order Status
+ * @member {module:model/Order.StatusEnum} status
+ */
+ exports.prototype['status'] = undefined;
+
+ /**
+ * @member {Boolean} complete
+ */
+ exports.prototype['complete'] = undefined;
+
+
+ /**
+ * Allowed values for the status
property.
+ * @enum {String}
+ * @readonly
+ */
+ exports.StatusEnum = {
+ /**
+ * value: placed
+ * @const
+ */
+ PLACED: "placed",
- if (data['id']) {
- _this['id'] = ApiClient.convertToType(data['id'], 'Integer');
- }
+ /**
+ * value: approved
+ * @const
+ */
+ APPROVED: "approved",
- if (data['petId']) {
- _this['petId'] = ApiClient.convertToType(data['petId'], 'Integer');
- }
-
- if (data['quantity']) {
- _this['quantity'] = ApiClient.convertToType(data['quantity'], 'Integer');
- }
-
- if (data['shipDate']) {
- _this['shipDate'] = ApiClient.convertToType(data['shipDate'], 'Date');
- }
-
- if (data['status']) {
- _this['status'] = ApiClient.convertToType(data['status'], 'String');
- }
-
- if (data['complete']) {
- _this['complete'] = ApiClient.convertToType(data['complete'], 'Boolean');
- }
-
- return _this;
- }
-
-
-
- /**
- * @return {Integer}
- **/
- Order.prototype.getId = function() {
- return this['id'];
- }
-
- /**
- * @param {Integer} id
- **/
- Order.prototype.setId = function(id) {
- this['id'] = id;
- }
-
- /**
- * @return {Integer}
- **/
- Order.prototype.getPetId = function() {
- return this['petId'];
- }
-
- /**
- * @param {Integer} petId
- **/
- Order.prototype.setPetId = function(petId) {
- this['petId'] = petId;
- }
-
- /**
- * @return {Integer}
- **/
- Order.prototype.getQuantity = function() {
- return this['quantity'];
- }
-
- /**
- * @param {Integer} quantity
- **/
- Order.prototype.setQuantity = function(quantity) {
- this['quantity'] = quantity;
- }
-
- /**
- * @return {Date}
- **/
- Order.prototype.getShipDate = function() {
- return this['shipDate'];
- }
-
- /**
- * @param {Date} shipDate
- **/
- Order.prototype.setShipDate = function(shipDate) {
- this['shipDate'] = shipDate;
- }
-
- /**
- * get Order Status
- * @return {StatusEnum}
- **/
- Order.prototype.getStatus = function() {
- return this['status'];
- }
-
- /**
- * set Order Status
- * @param {StatusEnum} status
- **/
- Order.prototype.setStatus = function(status) {
- this['status'] = status;
- }
-
- /**
- * @return {Boolean}
- **/
- Order.prototype.getComplete = function() {
- return this['complete'];
- }
-
- /**
- * @param {Boolean} complete
- **/
- Order.prototype.setComplete = function(complete) {
- this['complete'] = complete;
- }
-
-
-
- var StatusEnum = {
-
- /**
- * @const
- */
- PLACED: "placed",
-
- /**
- * @const
- */
- APPROVED: "approved",
-
- /**
- * @const
- */
- DELIVERED: "delivered"
+ /**
+ * value: delivered
+ * @const
+ */
+ DELIVERED: "delivered"
};
- Order.StatusEnum = StatusEnum;
-
-
- return Order;
-
-
+ return exports;
}));
diff --git a/samples/client/petstore/javascript/src/model/Pet.js b/samples/client/petstore/javascript/src/model/Pet.js
index f2290772a17..39a09b47170 100644
--- a/samples/client/petstore/javascript/src/model/Pet.js
+++ b/samples/client/petstore/javascript/src/model/Pet.js
@@ -14,167 +14,120 @@
}
}(this, function(ApiClient, Category, Tag) {
'use strict';
-
-
- var Pet = function Pet(name, photoUrls) {
-
- /**
- * datatype: String
- * required
- **/
+
+ /**
+ * The Pet model module.
+ * @module model/Pet
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new Pet
.
+ * @alias module:model/Pet
+ * @class
+ * @param name
+ * @param photoUrls
+ */
+ var exports = function(name, photoUrls) {
+
+
+
this['name'] = name;
- /**
- * datatype: [String]
- * required
- **/
this['photoUrls'] = photoUrls;
+
+
};
- Pet.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a Pet
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/Pet} obj Optional instance to populate.
+ * @return {module:model/Pet} The populated Pet
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('id')) {
+ obj['id'] = ApiClient.convertToType(data['id'], 'Integer');
+ }
+ if (data.hasOwnProperty('category')) {
+ obj['category'] = Category.constructFromObject(data['category']);
+ }
+ if (data.hasOwnProperty('name')) {
+ obj['name'] = ApiClient.convertToType(data['name'], 'String');
+ }
+ if (data.hasOwnProperty('photoUrls')) {
+ obj['photoUrls'] = ApiClient.convertToType(data['photoUrls'], ['String']);
+ }
+ if (data.hasOwnProperty('tags')) {
+ obj['tags'] = ApiClient.convertToType(data['tags'], [Tag]);
+ }
+ if (data.hasOwnProperty('status')) {
+ obj['status'] = ApiClient.convertToType(data['status'], 'String');
+ }
}
- var _this = new Pet();
+ return obj;
+ }
+
+
+ /**
+ * @member {Integer} id
+ */
+ exports.prototype['id'] = undefined;
+
+ /**
+ * @member {module:model/Category} category
+ */
+ exports.prototype['category'] = undefined;
+
+ /**
+ * @member {String} name
+ */
+ exports.prototype['name'] = undefined;
+
+ /**
+ * @member {Array.} photoUrls
+ */
+ exports.prototype['photoUrls'] = undefined;
+
+ /**
+ * @member {Array.} tags
+ */
+ exports.prototype['tags'] = undefined;
+
+ /**
+ * pet status in the store
+ * @member {module:model/Pet.StatusEnum} status
+ */
+ exports.prototype['status'] = undefined;
+
+
+ /**
+ * Allowed values for the status
property.
+ * @enum {String}
+ * @readonly
+ */
+ exports.StatusEnum = {
+ /**
+ * value: available
+ * @const
+ */
+ AVAILABLE: "available",
- if (data['id']) {
- _this['id'] = ApiClient.convertToType(data['id'], 'Integer');
- }
+ /**
+ * value: pending
+ * @const
+ */
+ PENDING: "pending",
- if (data['category']) {
- _this['category'] = Category.constructFromObject(data['category']);
- }
-
- if (data['name']) {
- _this['name'] = ApiClient.convertToType(data['name'], 'String');
- }
-
- if (data['photoUrls']) {
- _this['photoUrls'] = ApiClient.convertToType(data['photoUrls'], ['String']);
- }
-
- if (data['tags']) {
- _this['tags'] = ApiClient.convertToType(data['tags'], [Tag]);
- }
-
- if (data['status']) {
- _this['status'] = ApiClient.convertToType(data['status'], 'String');
- }
-
- return _this;
- }
-
-
-
- /**
- * @return {Integer}
- **/
- Pet.prototype.getId = function() {
- return this['id'];
- }
-
- /**
- * @param {Integer} id
- **/
- Pet.prototype.setId = function(id) {
- this['id'] = id;
- }
-
- /**
- * @return {Category}
- **/
- Pet.prototype.getCategory = function() {
- return this['category'];
- }
-
- /**
- * @param {Category} category
- **/
- Pet.prototype.setCategory = function(category) {
- this['category'] = category;
- }
-
- /**
- * @return {String}
- **/
- Pet.prototype.getName = function() {
- return this['name'];
- }
-
- /**
- * @param {String} name
- **/
- Pet.prototype.setName = function(name) {
- this['name'] = name;
- }
-
- /**
- * @return {[String]}
- **/
- Pet.prototype.getPhotoUrls = function() {
- return this['photoUrls'];
- }
-
- /**
- * @param {[String]} photoUrls
- **/
- Pet.prototype.setPhotoUrls = function(photoUrls) {
- this['photoUrls'] = photoUrls;
- }
-
- /**
- * @return {[Tag]}
- **/
- Pet.prototype.getTags = function() {
- return this['tags'];
- }
-
- /**
- * @param {[Tag]} tags
- **/
- Pet.prototype.setTags = function(tags) {
- this['tags'] = tags;
- }
-
- /**
- * get pet status in the store
- * @return {StatusEnum}
- **/
- Pet.prototype.getStatus = function() {
- return this['status'];
- }
-
- /**
- * set pet status in the store
- * @param {StatusEnum} status
- **/
- Pet.prototype.setStatus = function(status) {
- this['status'] = status;
- }
-
-
-
- var StatusEnum = {
-
- /**
- * @const
- */
- AVAILABLE: "available",
-
- /**
- * @const
- */
- PENDING: "pending",
-
- /**
- * @const
- */
- SOLD: "sold"
+ /**
+ * value: sold
+ * @const
+ */
+ SOLD: "sold"
};
- Pet.StatusEnum = StatusEnum;
-
-
- return Pet;
-
-
+ return exports;
}));
diff --git a/samples/client/petstore/javascript/src/model/SpecialModelName.js b/samples/client/petstore/javascript/src/model/SpecialModelName.js
index 7daf60e985e..fb6b4765d3f 100644
--- a/samples/client/petstore/javascript/src/model/SpecialModelName.js
+++ b/samples/client/petstore/javascript/src/model/SpecialModelName.js
@@ -14,46 +14,49 @@
}
}(this, function(ApiClient) {
'use strict';
-
-
- var SpecialModelName = function SpecialModelName() {
-
+
+ /**
+ * The SpecialModelName model module.
+ * @module model/SpecialModelName
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new SpecialModelName
.
+ * @alias module:model/SpecialModelName
+ * @class
+ */
+ var exports = function() {
+
+
};
- SpecialModelName.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a SpecialModelName
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/SpecialModelName} obj Optional instance to populate.
+ * @return {module:model/SpecialModelName} The populated SpecialModelName
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('$special[property.name]')) {
+ obj['$special[property.name]'] = ApiClient.convertToType(data['$special[property.name]'], 'Integer');
+ }
}
- var _this = new SpecialModelName();
-
- if (data['$special[property.name]']) {
- _this['$special[property.name]'] = ApiClient.convertToType(data['$special[property.name]'], 'Integer');
- }
-
- return _this;
+ return obj;
}
-
-
- /**
- * @return {Integer}
- **/
- SpecialModelName.prototype.getSpecialPropertyName = function() {
- return this['$special[property.name]'];
- }
/**
- * @param {Integer} specialPropertyName
- **/
- SpecialModelName.prototype.setSpecialPropertyName = function(specialPropertyName) {
- this['$special[property.name]'] = specialPropertyName;
- }
-
-
+ * @member {Integer} $special[property.name]
+ */
+ exports.prototype['$special[property.name]'] = undefined;
-
- return SpecialModelName;
-
-
+
+
+ return exports;
}));
diff --git a/samples/client/petstore/javascript/src/model/Tag.js b/samples/client/petstore/javascript/src/model/Tag.js
index 793fc7f1730..8a0739b2ef5 100644
--- a/samples/client/petstore/javascript/src/model/Tag.js
+++ b/samples/client/petstore/javascript/src/model/Tag.js
@@ -14,64 +14,58 @@
}
}(this, function(ApiClient) {
'use strict';
-
-
- var Tag = function Tag() {
-
+
+ /**
+ * The Tag model module.
+ * @module model/Tag
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new Tag
.
+ * @alias module:model/Tag
+ * @class
+ */
+ var exports = function() {
+
+
+
};
- Tag.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a Tag
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/Tag} obj Optional instance to populate.
+ * @return {module:model/Tag} The populated Tag
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('id')) {
+ obj['id'] = ApiClient.convertToType(data['id'], 'Integer');
+ }
+ if (data.hasOwnProperty('name')) {
+ obj['name'] = ApiClient.convertToType(data['name'], 'String');
+ }
}
- var _this = new Tag();
-
- if (data['id']) {
- _this['id'] = ApiClient.convertToType(data['id'], 'Integer');
- }
-
- if (data['name']) {
- _this['name'] = ApiClient.convertToType(data['name'], 'String');
- }
-
- return _this;
+ return obj;
}
-
-
- /**
- * @return {Integer}
- **/
- Tag.prototype.getId = function() {
- return this['id'];
- }
/**
- * @param {Integer} id
- **/
- Tag.prototype.setId = function(id) {
- this['id'] = id;
- }
-
- /**
- * @return {String}
- **/
- Tag.prototype.getName = function() {
- return this['name'];
- }
+ * @member {Integer} id
+ */
+ exports.prototype['id'] = undefined;
/**
- * @param {String} name
- **/
- Tag.prototype.setName = function(name) {
- this['name'] = name;
- }
-
-
+ * @member {String} name
+ */
+ exports.prototype['name'] = undefined;
-
- return Tag;
-
-
+
+
+ return exports;
}));
diff --git a/samples/client/petstore/javascript/src/model/User.js b/samples/client/petstore/javascript/src/model/User.js
index a012f200e8e..1d960a89914 100644
--- a/samples/client/petstore/javascript/src/model/User.js
+++ b/samples/client/petstore/javascript/src/model/User.js
@@ -14,174 +14,113 @@
}
}(this, function(ApiClient) {
'use strict';
-
-
- var User = function User() {
-
+
+ /**
+ * The User model module.
+ * @module model/User
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new User
.
+ * @alias module:model/User
+ * @class
+ */
+ var exports = function() {
+
+
+
+
+
+
+
+
+
};
- User.constructFromObject = function(data) {
- if (!data) {
- return null;
+ /**
+ * Constructs a User
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/User} obj Optional instance to populate.
+ * @return {module:model/User} The populated User
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('id')) {
+ obj['id'] = ApiClient.convertToType(data['id'], 'Integer');
+ }
+ if (data.hasOwnProperty('username')) {
+ obj['username'] = ApiClient.convertToType(data['username'], 'String');
+ }
+ if (data.hasOwnProperty('firstName')) {
+ obj['firstName'] = ApiClient.convertToType(data['firstName'], 'String');
+ }
+ if (data.hasOwnProperty('lastName')) {
+ obj['lastName'] = ApiClient.convertToType(data['lastName'], 'String');
+ }
+ if (data.hasOwnProperty('email')) {
+ obj['email'] = ApiClient.convertToType(data['email'], 'String');
+ }
+ if (data.hasOwnProperty('password')) {
+ obj['password'] = ApiClient.convertToType(data['password'], 'String');
+ }
+ if (data.hasOwnProperty('phone')) {
+ obj['phone'] = ApiClient.convertToType(data['phone'], 'String');
+ }
+ if (data.hasOwnProperty('userStatus')) {
+ obj['userStatus'] = ApiClient.convertToType(data['userStatus'], 'Integer');
+ }
}
- var _this = new User();
-
- if (data['id']) {
- _this['id'] = ApiClient.convertToType(data['id'], 'Integer');
- }
-
- if (data['username']) {
- _this['username'] = ApiClient.convertToType(data['username'], 'String');
- }
-
- if (data['firstName']) {
- _this['firstName'] = ApiClient.convertToType(data['firstName'], 'String');
- }
-
- if (data['lastName']) {
- _this['lastName'] = ApiClient.convertToType(data['lastName'], 'String');
- }
-
- if (data['email']) {
- _this['email'] = ApiClient.convertToType(data['email'], 'String');
- }
-
- if (data['password']) {
- _this['password'] = ApiClient.convertToType(data['password'], 'String');
- }
-
- if (data['phone']) {
- _this['phone'] = ApiClient.convertToType(data['phone'], 'String');
- }
-
- if (data['userStatus']) {
- _this['userStatus'] = ApiClient.convertToType(data['userStatus'], 'Integer');
- }
-
- return _this;
+ return obj;
}
-
-
- /**
- * @return {Integer}
- **/
- User.prototype.getId = function() {
- return this['id'];
- }
/**
- * @param {Integer} id
- **/
- User.prototype.setId = function(id) {
- this['id'] = id;
- }
-
- /**
- * @return {String}
- **/
- User.prototype.getUsername = function() {
- return this['username'];
- }
+ * @member {Integer} id
+ */
+ exports.prototype['id'] = undefined;
/**
- * @param {String} username
- **/
- User.prototype.setUsername = function(username) {
- this['username'] = username;
- }
-
- /**
- * @return {String}
- **/
- User.prototype.getFirstName = function() {
- return this['firstName'];
- }
+ * @member {String} username
+ */
+ exports.prototype['username'] = undefined;
/**
- * @param {String} firstName
- **/
- User.prototype.setFirstName = function(firstName) {
- this['firstName'] = firstName;
- }
-
- /**
- * @return {String}
- **/
- User.prototype.getLastName = function() {
- return this['lastName'];
- }
+ * @member {String} firstName
+ */
+ exports.prototype['firstName'] = undefined;
/**
- * @param {String} lastName
- **/
- User.prototype.setLastName = function(lastName) {
- this['lastName'] = lastName;
- }
-
- /**
- * @return {String}
- **/
- User.prototype.getEmail = function() {
- return this['email'];
- }
+ * @member {String} lastName
+ */
+ exports.prototype['lastName'] = undefined;
/**
- * @param {String} email
- **/
- User.prototype.setEmail = function(email) {
- this['email'] = email;
- }
-
- /**
- * @return {String}
- **/
- User.prototype.getPassword = function() {
- return this['password'];
- }
+ * @member {String} email
+ */
+ exports.prototype['email'] = undefined;
/**
- * @param {String} password
- **/
- User.prototype.setPassword = function(password) {
- this['password'] = password;
- }
-
- /**
- * @return {String}
- **/
- User.prototype.getPhone = function() {
- return this['phone'];
- }
+ * @member {String} password
+ */
+ exports.prototype['password'] = undefined;
/**
- * @param {String} phone
- **/
- User.prototype.setPhone = function(phone) {
- this['phone'] = phone;
- }
-
- /**
- * get User Status
- * @return {Integer}
- **/
- User.prototype.getUserStatus = function() {
- return this['userStatus'];
- }
+ * @member {String} phone
+ */
+ exports.prototype['phone'] = undefined;
/**
- * set User Status
- * @param {Integer} userStatus
- **/
- User.prototype.setUserStatus = function(userStatus) {
- this['userStatus'] = userStatus;
- }
-
-
+ * User Status
+ * @member {Integer} userStatus
+ */
+ exports.prototype['userStatus'] = undefined;
-
- return User;
-
-
+
+
+ return exports;
}));
diff --git a/samples/client/petstore/javascript/test/ApiClientTest.js b/samples/client/petstore/javascript/test/ApiClientTest.js
index e061de358b4..d259ad54c14 100644
--- a/samples/client/petstore/javascript/test/ApiClientTest.js
+++ b/samples/client/petstore/javascript/test/ApiClientTest.js
@@ -4,7 +4,7 @@ if (typeof module === 'object' && module.exports) {
var sinon = require('sinon');
}
-var apiClient = SwaggerPetstore.ApiClient.default;
+var apiClient = SwaggerPetstore.ApiClient.instance;
describe('ApiClient', function() {
describe('defaults', function() {
@@ -13,26 +13,26 @@ describe('ApiClient', function() {
expect(apiClient.basePath).to.be('http://petstore.swagger.io/v2');
expect(apiClient.authentications).to.eql({
petstore_auth: {type: 'oauth2'},
- api_key: {type: 'apiKey', in: 'header', name: 'api_key'},
+ api_key: {type: 'apiKey', 'in': 'header', name: 'api_key'},
test_http_basic: {type: 'basic'},
test_api_client_id: {
type: 'apiKey',
- in: 'header',
+ 'in': 'header',
name: 'x-test_api_client_id'
},
test_api_client_secret: {
type: 'apiKey',
- in: 'header',
+ 'in': 'header',
name: 'x-test_api_client_secret'
},
test_api_key_query: {
type: 'apiKey',
- in: 'query',
+ 'in': 'query',
name: 'test_api_key_query'
},
test_api_key_header: {
type: 'apiKey',
- in: 'header',
+ 'in': 'header',
name: 'test_api_key_header'
}
});
@@ -275,7 +275,7 @@ describe('ApiClient', function() {
var apiKeyAuth, oauth2;
beforeEach(function() {
- newClient.authentications[apiKeyAuthName] = {type: 'apiKey', name: 'api_key', in: 'query'};
+ newClient.authentications[apiKeyAuthName] = {type: 'apiKey', name: 'api_key', 'in': 'query'};
newClient.authentications[oauth2Name] = {type: 'oauth2'};
apiKeyAuth = newClient.authentications[apiKeyAuthName];
oauth2 = newClient.authentications[oauth2Name];
diff --git a/samples/client/petstore/javascript/test/api/PetApiTest.js b/samples/client/petstore/javascript/test/api/PetApiTest.js
index 3cde6ef4761..d5f7ba3424c 100644
--- a/samples/client/petstore/javascript/test/api/PetApiTest.js
+++ b/samples/client/petstore/javascript/test/api/PetApiTest.js
@@ -18,20 +18,36 @@
api = new SwaggerPetstore.PetApi();
});
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
var createRandomPet = function() {
var id = new Date().getTime();
var pet = new SwaggerPetstore.Pet();
- pet.setId(id);
- pet.setName("pet" + id);
+ setProperty(pet, "setId", "id", id);
+ setProperty(pet, "setName", "name", "pet" + id);
var category = new SwaggerPetstore.Category();
- category.setId(id);
- category.setName("category" + id);
- pet.setCategory(category);
+ setProperty(category, "setId", "id", id);
+ setProperty(category, "setName", "name", "category" + id);
+ setProperty(pet, "setCategory", "category", category);
- pet.setStatus('available');
+ setProperty(pet, "setStatus", "status", "available");
var photos = ["http://foo.bar.com/1", "http://foo.bar.com/2"];
- pet.setPhotoUrls(photos);
+ setProperty(pet, "setPhotoUrls", "photoUrls", photos);
return pet;
};
@@ -50,9 +66,12 @@
expect(fetched).to.be.a(SwaggerPetstore.Pet);
expect(fetched.id).to.be(pet.id);
- expect(fetched.getPhotoUrls()).to.eql(pet.getPhotoUrls());
- expect(fetched.getCategory()).to.be.a(SwaggerPetstore.Category);
- expect(fetched.getCategory().getName()).to.be(pet.getCategory().getName());
+ expect(getProperty(fetched, "getPhotoUrls", "photoUrls"))
+ .to.eql(getProperty(pet, "getPhotoUrls", "photoUrls"));
+ expect(getProperty(fetched, "getCategory", "category"))
+ .to.be.a(SwaggerPetstore.Category);
+ expect(getProperty(getProperty(fetched, "getCategory", "category"), "getName", "name"))
+ .to.be(getProperty(getProperty(pet, "getCategory", "category"), "getName", "name"));
api.deletePet(pet.id);
done();
@@ -75,8 +94,10 @@
var categoryObj = fetched.category;
expect(categoryObj).to.be.a(Object);
expect(categoryObj).not.to.be.a(SwaggerPetstore.Category);
- expect(categoryObj.id).to.be(pet.getCategory().getId());
- expect(categoryObj.name).to.be(pet.getCategory().getName());
+ expect(categoryObj.id)
+ .to.be(getProperty(getProperty(pet, "getCategory", "category"), "getId", "id"));
+ expect(categoryObj.name)
+ .to.be(getProperty(getProperty(pet, "getCategory", "category"), "getName", "name"));
api.deletePet(pet.id);
done();