update js samples

This commit is contained in:
wing328
2016-05-01 12:09:23 +08:00
parent 2d5cc50bd1
commit ab7b73ca21
20 changed files with 73 additions and 307 deletions

View File

@@ -6,11 +6,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/
- API version: 1.0.0
- Package version: 1.0.0
<<<<<<< HEAD
- Build date: 2016-04-30T20:22:59.696+08:00
=======
- Build date: 2016-03-25T16:32:33.021Z
>>>>>>> 7dfddd449ddc2ae8e7e35b6d5ab7fc10e52bc93d
- Build date: 2016-05-01T12:08:53.092+08:00
- Build package: class io.swagger.codegen.languages.JavascriptClientCodegen
## Installation

View File

@@ -59,58 +59,6 @@ null (empty response body)
[petstore_auth](../README.md#petstore_auth)
### HTTP request headers
<<<<<<< HEAD
=======
- **Content-Type**: application/json, application/xml
- **Accept**: application/json, application/xml
<a name="addPetUsingByteArray"></a>
# **addPetUsingByteArray**
> addPetUsingByteArray(opts)
Fake endpoint to test byte array in body parameter for adding a new pet to the store
### Example
```javascript
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"
var apiInstance = new SwaggerPetstore.PetApi()
var opts = {
'body': "B" // {String} Pet object in the form of byte array
};
apiInstance.addPetUsingByteArray(opts).then(function() {
console.log('API called successfully.');
}, function(error) {
console.error(error);
});
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | **String**| Pet object in the form of byte array | [optional]
### Return type
null (empty response body)
### Authorization
[petstore_auth](../README.md#petstore_auth)
### HTTP request headers
>>>>>>> 7dfddd449ddc2ae8e7e35b6d5ab7fc10e52bc93d
- **Content-Type**: application/json, application/xml
- **Accept**: application/json, application/xml
@@ -315,117 +263,6 @@ Name | Type | Description | Notes
[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
### HTTP request headers
<<<<<<< HEAD
=======
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
<a name="getPetByIdInObject"></a>
# **getPetByIdInObject**
> InlineResponse200 getPetByIdInObject(petId)
Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
### Example
```javascript
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
// 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 apiInstance = new SwaggerPetstore.PetApi()
var petId = 789; // {Integer} ID of pet that needs to be fetched
apiInstance.getPetByIdInObject(petId).then(function(data) {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **Integer**| ID of pet that needs to be fetched |
### Return type
[**InlineResponse200**](InlineResponse200.md)
### Authorization
[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
<a name="petPetIdtestingByteArraytrueGet"></a>
# **petPetIdtestingByteArraytrueGet**
> &#39;String&#39; petPetIdtestingByteArraytrueGet(petId)
Fake endpoint to test byte array return by &#39;Find pet by ID&#39;
Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
### Example
```javascript
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
// 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 apiInstance = new SwaggerPetstore.PetApi()
var petId = 789; // {Integer} ID of pet that needs to be fetched
apiInstance.petPetIdtestingByteArraytrueGet(petId).then(function(data) {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **Integer**| ID of pet that needs to be fetched |
### Return type
**&#39;String&#39;**
### Authorization
[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
### HTTP request headers
>>>>>>> 7dfddd449ddc2ae8e7e35b6d5ab7fc10e52bc93d
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml

View File

@@ -49,66 +49,6 @@ null (empty response body)
No authorization required
### HTTP request headers
<<<<<<< HEAD
=======
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
<a name="findOrdersByStatus"></a>
# **findOrdersByStatus**
> [Order] findOrdersByStatus(opts)
Finds orders by status
A single status value can be provided as a string
### Example
```javascript
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
// Configure API key authorization: test_api_client_id
var test_api_client_id = defaultClient.authentications['test_api_client_id'];
test_api_client_id.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//test_api_client_id.apiKeyPrefix['x-test_api_client_id'] = "Token"
// Configure API key authorization: test_api_client_secret
var test_api_client_secret = defaultClient.authentications['test_api_client_secret'];
test_api_client_secret.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//test_api_client_secret.apiKeyPrefix['x-test_api_client_secret'] = "Token"
var apiInstance = new SwaggerPetstore.StoreApi()
var opts = {
'status': "placed" // {String} Status value that needs to be considered for query
};
apiInstance.findOrdersByStatus(opts).then(function(data) {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**status** | **String**| Status value that needs to be considered for query | [optional] [default to placed]
### Return type
[**[Order]**](Order.md)
### Authorization
[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret)
### HTTP request headers
>>>>>>> 7dfddd449ddc2ae8e7e35b6d5ab7fc10e52bc93d
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
@@ -153,53 +93,6 @@ This endpoint does not need any parameter.
[api_key](../README.md#api_key)
### HTTP request headers
<<<<<<< HEAD
=======
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
<a name="getInventoryInObject"></a>
# **getInventoryInObject**
> Object getInventoryInObject
Fake endpoint to test arbitrary object return by &#39;Get inventory&#39;
Returns an arbitrary object which is actually a map of status codes to quantities
### Example
```javascript
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
// 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"
var apiInstance = new SwaggerPetstore.StoreApi()
apiInstance.getInventoryInObject().then(function(data) {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
```
### Parameters
This endpoint does not need any parameter.
### Return type
**Object**
### Authorization
[api_key](../README.md#api_key)
### HTTP request headers
>>>>>>> 7dfddd449ddc2ae8e7e35b6d5ab7fc10e52bc93d
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml

View File

@@ -451,6 +451,25 @@
}
};
/**
* Constructs a new map or array model from REST data.
* @param data {Object|Array} The REST data.
* @param obj {Object|Array} The target object or array.
*/
exports.constructFromObject = function(data, obj, itemType) {
if (Array.isArray(data)) {
for (var i = 0; i < data.length; i++) {
if (data.hasOwnProperty(i))
obj[i] = exports.convertToType(data[i], itemType);
}
} else {
for (var k in data) {
if (data.hasOwnProperty(k))
result[k] = exports.convertToType(data[k], itemType);
}
}
};
/**
* The default API client implementation.
* @type {module:ApiClient}

View File

@@ -1,11 +1,7 @@
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
<<<<<<< HEAD
define(['../ApiClient', '../model/Pet'], factory);
=======
define(['ApiClient', 'model/Pet', 'model/InlineResponse200'], factory);
>>>>>>> 7dfddd449ddc2ae8e7e35b6d5ab7fc10e52bc93d
define(['ApiClient', 'model/Pet'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'), require('../model/Pet'));

View File

@@ -1,11 +1,7 @@
(function(factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
<<<<<<< HEAD
define(['./ApiClient', './model/Category', './model/Order', './model/Pet', './model/Tag', './model/User', './api/PetApi', './api/StoreApi', './api/UserApi'], factory);
=======
define(['ApiClient', 'model/Category', 'model/InlineResponse200', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/Order', 'model/Pet', 'model/SpecialModelName', 'model/Tag', 'model/User', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory);
>>>>>>> 7dfddd449ddc2ae8e7e35b6d5ab7fc10e52bc93d
define(['ApiClient', 'model/Category', 'model/Order', 'model/Pet', 'model/Tag', 'model/User', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('./ApiClient'), require('./model/Category'), require('./model/Order'), require('./model/Pet'), require('./model/Tag'), require('./model/User'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi'));

View File

@@ -27,6 +27,7 @@
* @class
*/
var exports = function() {
var _this = this;
@@ -40,7 +41,7 @@
* @return {module:model/Category} The populated <code>Category</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('id')) {

View File

@@ -27,6 +27,7 @@
* @class
*/
var exports = function() {
var _this = this;
@@ -44,7 +45,7 @@
* @return {module:model/Order} The populated <code>Order</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('id')) {

View File

@@ -29,11 +29,12 @@
* @param photoUrls
*/
var exports = function(name, photoUrls) {
var _this = this;
this['name'] = name;
this['photoUrls'] = photoUrls;
_this['name'] = name;
_this['photoUrls'] = photoUrls;
};
@@ -46,7 +47,7 @@
* @return {module:model/Pet} The populated <code>Pet</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('id')) {

View File

@@ -27,6 +27,7 @@
* @class
*/
var exports = function() {
var _this = this;
@@ -40,7 +41,7 @@
* @return {module:model/Tag} The populated <code>Tag</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('id')) {

View File

@@ -27,6 +27,7 @@
* @class
*/
var exports = function() {
var _this = this;
@@ -46,7 +47,7 @@
* @return {module:model/User} The populated <code>User</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('id')) {

View File

@@ -6,7 +6,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/
- API version: 1.0.0
- Package version: 1.0.0
- Build date: 2016-04-30T20:20:04.619+08:00
- Build date: 2016-05-01T12:06:44.623+08:00
- Build package: class io.swagger.codegen.languages.JavascriptClientCodegen
## Installation

View File

@@ -463,6 +463,25 @@
}
};
/**
* Constructs a new map or array model from REST data.
* @param data {Object|Array} The REST data.
* @param obj {Object|Array} The target object or array.
*/
exports.constructFromObject = function(data, obj, itemType) {
if (Array.isArray(data)) {
for (var i = 0; i < data.length; i++) {
if (data.hasOwnProperty(i))
obj[i] = exports.convertToType(data[i], itemType);
}
} else {
for (var k in data) {
if (data.hasOwnProperty(k))
result[k] = exports.convertToType(data[k], itemType);
}
}
};
/**
* The default API client implementation.
* @type {module:ApiClient}

View File

@@ -1,7 +1,7 @@
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['../ApiClient', '../model/Pet'], factory);
define(['ApiClient', 'model/Pet'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'), require('../model/Pet'));
@@ -25,8 +25,8 @@
* Constructs a new PetApi.
* @alias module:api/PetApi
* @class
* @param {module:ApiClient} apiClient Optional API client implementation to use, default to {@link module:ApiClient#instance}
* if unspecified.
* @param {module:ApiClient} apiClient Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
var exports = function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;

View File

@@ -1,7 +1,7 @@
(function(factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['./ApiClient', './model/Category', './model/Order', './model/Pet', './model/Tag', './model/User', './api/PetApi', './api/StoreApi', './api/UserApi'], factory);
define(['ApiClient', 'model/Category', 'model/Order', 'model/Pet', 'model/Tag', 'model/User', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('./ApiClient'), require('./model/Category'), require('./model/Order'), require('./model/Pet'), require('./model/Tag'), require('./model/User'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi'));
@@ -15,7 +15,7 @@
* <p>
* An AMD (recommended!) or CommonJS application will generally do something equivalent to the following:
* <pre>
* var SwaggerPetstore = require('./index'); // See note below*.
* 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';
@@ -23,8 +23,8 @@
* var zzz = xxxSvc.doSomething(yyyModel); // Invoke the service.
* ...
* </pre>
* <em>*NOTE: For a top-level AMD script, use require(['./index'], function(){...}) and put the application logic within the
* callback function.</em>
* <em>*NOTE: For a top-level AMD script, use require(['index'], function(){...})
* and put the application logic within the callback function.</em>
* </p>
* <p>
* A non-AMD browser application (discouraged) might do something like this:

View File

@@ -27,6 +27,7 @@
* @class
*/
var exports = function() {
var _this = this;
@@ -40,7 +41,7 @@
* @return {module:model/Category} The populated <code>Category</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('id')) {

View File

@@ -27,6 +27,7 @@
* @class
*/
var exports = function() {
var _this = this;
@@ -44,7 +45,7 @@
* @return {module:model/Order} The populated <code>Order</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('id')) {

View File

@@ -29,11 +29,12 @@
* @param photoUrls
*/
var exports = function(name, photoUrls) {
var _this = this;
this['name'] = name;
this['photoUrls'] = photoUrls;
_this['name'] = name;
_this['photoUrls'] = photoUrls;
};
@@ -46,7 +47,7 @@
* @return {module:model/Pet} The populated <code>Pet</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('id')) {

View File

@@ -27,6 +27,7 @@
* @class
*/
var exports = function() {
var _this = this;
@@ -40,7 +41,7 @@
* @return {module:model/Tag} The populated <code>Tag</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('id')) {

View File

@@ -27,6 +27,7 @@
* @class
*/
var exports = function() {
var _this = this;
@@ -46,7 +47,7 @@
* @return {module:model/User} The populated <code>User</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('id')) {