better enum support for JS

This commit is contained in:
wing328
2016-05-02 23:26:47 +08:00
parent 6e8a19bc5b
commit d35e30d578
34 changed files with 933 additions and 263 deletions

View File

@@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/Javascript -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l javascript -o samples/client/petstore/javascript"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/Javascript -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l javascript -o samples/client/petstore/javascript"
java -DappName=PetstoreClient $JAVA_OPTS -jar $executable $ags

View File

@@ -892,7 +892,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
}
}
enumVar.put("name", toEnumVarName(enumName, var.datatype));
enumVar.put("value", value.toString());
enumVar.put("value",toEnumValue(value.toString(), var.datatype));
enumVars.add(enumVar);
}
allowableValues.put("enumVars", enumVars);
@@ -938,15 +938,6 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
return prefix.replaceAll("[a-zA-Z0-9]+\\z", "");
}
*/
@Override
public String toEnumVarName(String value, String datatype) {
String var = value.replaceAll("\\W+", "_").toUpperCase();
if (var.matches("\\d.*")) {
return "_" + var;
} else {
return var;
}
}
private static CodegenModel reconcileInlineEnums(CodegenModel codegenModel, CodegenModel parentCodegenModel) {
// This generator uses inline classes to define enums, which breaks when
@@ -1005,4 +996,41 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
return packageName;
}
@Override
public String toEnumName(CodegenProperty property) {
return sanitizeName(camelize(property.name)) + "Enum";
}
@Override
public String toEnumVarName(String value, String datatype) {
return value;
/*
// number
if ("Integer".equals(datatype) || "Number".equals(datatype)) {
String varName = "NUMBER_" + value;
varName = varName.replaceAll("-", "MINUS_");
varName = varName.replaceAll("\\+", "PLUS_");
varName = varName.replaceAll("\\.", "_DOT_");
return varName;
}
// string
String var = value.replaceAll("\\W+", "_").replaceAll("_+", "_").toUpperCase();
if (var.matches("\\d.*")) {
return "_" + var;
} else {
return var;
}
*/
}
@Override
public String toEnumValue(String value, String datatype) {
if ("Integer".equals(datatype) || "Number".equals(datatype)) {
return value;
} else {
return "\"" + escapeText(value) + "\"";
}
}
}

View File

@@ -3,11 +3,17 @@
* @enum {{=<% %>=}}{<%datatype%>}<%={{ }}=%>
* @readonly
*/{{/emitJSDoc}}
exports.{{datatypeWithEnum}} = { {{#allowableValues}}{{#enumVars}}
{{#emitJSDoc}} /**
* value: {{value}}
exports.{{datatypeWithEnum}} = {
{{#allowableValues}}
{{#enumVars}}
{{#emitJSDoc}}
/**
* value: {{{value}}}
* @const
*/
{{/emitJSDoc}} {{name}}: "{{value}}"{{^-last}},
{{/-last}}{{/enumVars}}{{/allowableValues}}
{{/emitJSDoc}}
"{{name}}": {{{value}}}{{^-last}},
{{/-last}}
{{/enumVars}}
{{/allowableValues}}
};

View File

@@ -1,12 +1,12 @@
# swagger-petstore
SwaggerPetstore - JavaScript client for swagger-petstore
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
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose.
This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
- API version: 1.0.0
- Package version: 1.0.0
- Build date: 2016-05-02T22:07:48.077+08:00
- Build date: 2016-05-02T23:24:54.621+08:00
- Build package: class io.swagger.codegen.languages.JavascriptClientCodegen
## Installation
@@ -53,16 +53,25 @@ Please follow the [installation](#installation) instruction and execute the foll
```javascript
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
var api = new SwaggerPetstore.FakeApi()
// Configure OAuth2 access token for authorization: petstore_auth
var petstore_auth = defaultClient.authentications['petstore_auth'];
petstore_auth.accessToken = "YOUR ACCESS TOKEN"
var _number = 3.4; // {Number} None
var api = new SwaggerPetstore.PetApi()
var _double = 1.2; // {Number} None
var _string = "_string_example"; // {String} None
var _byte = "B"; // {String} None
var opts = {
'body': new SwaggerPetstore.Pet() // {Pet} Pet object that needs to be added to the store
'integer': 56, // {Integer} None
'int32': 56, // {Integer} None
'int64': 789, // {Integer} None
'_float': 3.4, // {Number} None
'binary': "B", // {String} None
'_date': new Date("2013-10-20"), // {Date} None
'dateTime': new Date("2013-10-20T19:20:30+01:00"), // {Date} None
'password': "password_example" // {String} None
};
var callback = function(error, data, response) {
@@ -72,7 +81,7 @@ var callback = function(error, data, response) {
console.log('API called successfully.');
}
};
api.addPet(opts, callback);
api.testEndpointParameters(_number, _double, _string, _byte, opts, callback);
```
@@ -82,6 +91,7 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*SwaggerPetstore.FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters
*SwaggerPetstore.PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store
*SwaggerPetstore.PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet
*SwaggerPetstore.PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
@@ -106,9 +116,20 @@ Class | Method | HTTP request | Description
## Documentation for Models
- [SwaggerPetstore.Animal](docs/Animal.md)
- [SwaggerPetstore.ApiResponse](docs/ApiResponse.md)
- [SwaggerPetstore.Cat](docs/Cat.md)
- [SwaggerPetstore.Category](docs/Category.md)
- [SwaggerPetstore.Dog](docs/Dog.md)
- [SwaggerPetstore.EnumClass](docs/EnumClass.md)
- [SwaggerPetstore.EnumTest](docs/EnumTest.md)
- [SwaggerPetstore.FormatTest](docs/FormatTest.md)
- [SwaggerPetstore.Model200Response](docs/Model200Response.md)
- [SwaggerPetstore.ModelReturn](docs/ModelReturn.md)
- [SwaggerPetstore.Name](docs/Name.md)
- [SwaggerPetstore.Order](docs/Order.md)
- [SwaggerPetstore.Pet](docs/Pet.md)
- [SwaggerPetstore.SpecialModelName](docs/SpecialModelName.md)
- [SwaggerPetstore.Tag](docs/Tag.md)
- [SwaggerPetstore.User](docs/User.md)

View File

@@ -0,0 +1,10 @@
# SwaggerPetstore.ApiResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**code** | **Integer** | | [optional]
**type** | **String** | | [optional]
**message** | **String** | | [optional]

View File

@@ -0,0 +1,7 @@
# SwaggerPetstore.EnumClass
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------

View File

@@ -0,0 +1,10 @@
# SwaggerPetstore.EnumTest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**enumString** | **String** | | [optional]
**enumInteger** | **Integer** | | [optional]
**enumNumber** | **Number** | | [optional]

View File

@@ -0,0 +1,82 @@
# SwaggerPetstore.FakeApi
All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters
<a name="testEndpointParameters"></a>
# **testEndpointParameters**
> testEndpointParameters(_number, _double, _string, _byte, opts)
Fake endpoint for testing various parameters
Fake endpoint for testing various parameters
### Example
```javascript
var SwaggerPetstore = require('swagger-petstore');
var apiInstance = new SwaggerPetstore.FakeApi();
var _number = 3.4; // Number | None
var _double = 1.2; // Number | None
var _string = "_string_example"; // String | None
var _byte = "B"; // String | None
var opts = {
'integer': 56, // Integer | None
'int32': 56, // Integer | None
'int64': 789, // Integer | None
'_float': 3.4, // Number | None
'binary': "B", // String | None
'_date': new Date("2013-10-20"), // Date | None
'dateTime': new Date("2013-10-20T19:20:30+01:00"), // Date | None
'password': "password_example" // String | None
};
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully.');
}
};
apiInstance.testEndpointParameters(_number, _double, _string, _byte, opts, callback);
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**_number** | **Number**| None |
**_double** | **Number**| None |
**_string** | **String**| None |
**_byte** | **String**| None |
**integer** | **Integer**| None | [optional]
**int32** | **Integer**| None | [optional]
**int64** | **Integer**| None | [optional]
**_float** | **Number**| None | [optional]
**binary** | **String**| None | [optional]
**_date** | **Date**| None | [optional]
**dateTime** | **Date**| None | [optional]
**password** | **String**| None | [optional]
### Return type
null (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json

View File

@@ -10,9 +10,11 @@ Name | Type | Description | Notes
**_float** | **Number** | | [optional]
**_double** | **Number** | | [optional]
**_string** | **String** | | [optional]
**_byte** | **String** | | [optional]
**_byte** | **String** | |
**binary** | **String** | | [optional]
**_date** | **Date** | | [optional]
**dateTime** | **String** | | [optional]
**_date** | **Date** | |
**dateTime** | **Date** | | [optional]
**uuid** | **String** | | [optional]
**password** | **String** | |

View File

@@ -5,5 +5,6 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **Integer** | |
**snakeCase** | **Integer** | | [optional]
**property** | **String** | | [optional]

View File

@@ -8,6 +8,6 @@ Name | Type | Description | Notes
**quantity** | **Integer** | | [optional]
**shipDate** | **Date** | | [optional]
**status** | **String** | Order Status | [optional]
**complete** | **Boolean** | | [optional]
**complete** | **Boolean** | | [optional] [default to false]

View File

@@ -16,7 +16,7 @@ Method | HTTP request | Description
<a name="addPet"></a>
# **addPet**
> addPet(opts)
> addPet(body)
Add a new pet to the store
@@ -33,9 +33,8 @@ petstore_auth.accessToken = 'YOUR ACCESS TOKEN';
var apiInstance = new SwaggerPetstore.PetApi();
var opts = {
'body': new SwaggerPetstore.Pet() // Pet | Pet object that needs to be added to the store
};
var body = new SwaggerPetstore.Pet(); // Pet | Pet object that needs to be added to the store
var callback = function(error, data, response) {
if (error) {
@@ -44,14 +43,14 @@ var callback = function(error, data, response) {
console.log('API called successfully.');
}
};
apiInstance.addPet(opts, callback);
apiInstance.addPet(body, callback);
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional]
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type
@@ -64,7 +63,7 @@ null (empty response body)
### HTTP request headers
- **Content-Type**: application/json, application/xml
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="deletePet"></a>
# **deletePet**
@@ -119,15 +118,15 @@ null (empty response body)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="findPetsByStatus"></a>
# **findPetsByStatus**
> [Pet] findPetsByStatus(opts)
> [Pet] findPetsByStatus(status)
Finds Pets by status
Multiple status values can be provided with comma seperated strings
Multiple status values can be provided with comma separated strings
### Example
```javascript
@@ -140,9 +139,8 @@ petstore_auth.accessToken = 'YOUR ACCESS TOKEN';
var apiInstance = new SwaggerPetstore.PetApi();
var opts = {
'status': ["available"] // [String] | Status values that need to be considered for filter
};
var status = ["status_example"]; // [String] | Status values that need to be considered for filter
var callback = function(error, data, response) {
if (error) {
@@ -151,14 +149,14 @@ var callback = function(error, data, response) {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.findPetsByStatus(opts, callback);
apiInstance.findPetsByStatus(status, callback);
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**status** | [**[String]**](String.md)| Status values that need to be considered for filter | [optional] [default to available]
**status** | [**[String]**](String.md)| Status values that need to be considered for filter |
### Return type
@@ -171,15 +169,15 @@ Name | Type | Description | Notes
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="findPetsByTags"></a>
# **findPetsByTags**
> [Pet] findPetsByTags(opts)
> [Pet] findPetsByTags(tags)
Finds Pets by tags
Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
### Example
```javascript
@@ -192,9 +190,8 @@ petstore_auth.accessToken = 'YOUR ACCESS TOKEN';
var apiInstance = new SwaggerPetstore.PetApi();
var opts = {
'tags': ["tags_example"] // [String] | Tags to filter by
};
var tags = ["tags_example"]; // [String] | Tags to filter by
var callback = function(error, data, response) {
if (error) {
@@ -203,14 +200,14 @@ var callback = function(error, data, response) {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.findPetsByTags(opts, callback);
apiInstance.findPetsByTags(tags, callback);
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**tags** | [**[String]**](String.md)| Tags to filter by | [optional]
**tags** | [**[String]**](String.md)| Tags to filter by |
### Return type
@@ -223,7 +220,7 @@ Name | Type | Description | Notes
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="getPetById"></a>
# **getPetById**
@@ -231,7 +228,7 @@ Name | Type | Description | Notes
Find pet by ID
Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
Returns a single pet
### Example
```javascript
@@ -244,13 +241,9 @@ 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 = '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
var petId = 789; // Integer | ID of pet to return
var callback = function(error, data, response) {
@@ -267,7 +260,7 @@ apiInstance.getPetById(petId, callback);
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **Integer**| ID of pet that needs to be fetched |
**petId** | **Integer**| ID of pet to return |
### Return type
@@ -275,16 +268,16 @@ Name | Type | Description | Notes
### Authorization
[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
[api_key](../README.md#api_key)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="updatePet"></a>
# **updatePet**
> updatePet(opts)
> updatePet(body)
Update an existing pet
@@ -301,9 +294,8 @@ petstore_auth.accessToken = 'YOUR ACCESS TOKEN';
var apiInstance = new SwaggerPetstore.PetApi();
var opts = {
'body': new SwaggerPetstore.Pet() // Pet | Pet object that needs to be added to the store
};
var body = new SwaggerPetstore.Pet(); // Pet | Pet object that needs to be added to the store
var callback = function(error, data, response) {
if (error) {
@@ -312,14 +304,14 @@ var callback = function(error, data, response) {
console.log('API called successfully.');
}
};
apiInstance.updatePet(opts, callback);
apiInstance.updatePet(body, callback);
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional]
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type
@@ -332,7 +324,7 @@ null (empty response body)
### HTTP request headers
- **Content-Type**: application/json, application/xml
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="updatePetWithForm"></a>
# **updatePetWithForm**
@@ -353,7 +345,7 @@ petstore_auth.accessToken = 'YOUR ACCESS TOKEN';
var apiInstance = new SwaggerPetstore.PetApi();
var petId = "petId_example"; // String | ID of pet that needs to be updated
var petId = 789; // Integer | ID of pet that needs to be updated
var opts = {
'name': "name_example", // String | Updated name of the pet
@@ -374,7 +366,7 @@ apiInstance.updatePetWithForm(petId, opts, callback);
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **String**| ID of pet that needs to be updated |
**petId** | **Integer**| ID of pet that needs to be updated |
**name** | **String**| Updated name of the pet | [optional]
**status** | **String**| Updated status of the pet | [optional]
@@ -389,11 +381,11 @@ null (empty response body)
### HTTP request headers
- **Content-Type**: application/x-www-form-urlencoded
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="uploadFile"></a>
# **uploadFile**
> uploadFile(petId, opts)
> ApiResponse uploadFile(petId, opts)
uploads an image
@@ -421,7 +413,7 @@ var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully.');
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.uploadFile(petId, opts, callback);
@@ -437,7 +429,7 @@ Name | Type | Description | Notes
### Return type
null (empty response body)
[**ApiResponse**](ApiResponse.md)
### Authorization
@@ -446,5 +438,5 @@ null (empty response body)
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: application/json, application/xml
- **Accept**: application/json

View File

@@ -54,7 +54,7 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="getInventory"></a>
# **getInventory**
@@ -101,7 +101,7 @@ This endpoint does not need any parameter.
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
- **Accept**: application/json
<a name="getOrderById"></a>
# **getOrderById**
@@ -117,7 +117,7 @@ var SwaggerPetstore = require('swagger-petstore');
var apiInstance = new SwaggerPetstore.StoreApi();
var orderId = "orderId_example"; // String | ID of pet that needs to be fetched
var orderId = 789; // Integer | ID of pet that needs to be fetched
var callback = function(error, data, response) {
@@ -134,7 +134,7 @@ apiInstance.getOrderById(orderId, callback);
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**orderId** | **String**| ID of pet that needs to be fetched |
**orderId** | **Integer**| ID of pet that needs to be fetched |
### Return type
@@ -147,11 +147,11 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="placeOrder"></a>
# **placeOrder**
> Order placeOrder(opts)
> Order placeOrder(body)
Place an order for a pet
@@ -163,9 +163,8 @@ var SwaggerPetstore = require('swagger-petstore');
var apiInstance = new SwaggerPetstore.StoreApi();
var opts = {
'body': new SwaggerPetstore.Order() // Order | order placed for purchasing the pet
};
var body = new SwaggerPetstore.Order(); // Order | order placed for purchasing the pet
var callback = function(error, data, response) {
if (error) {
@@ -174,14 +173,14 @@ var callback = function(error, data, response) {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.placeOrder(opts, callback);
apiInstance.placeOrder(body, callback);
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Order**](Order.md)| order placed for purchasing the pet | [optional]
**body** | [**Order**](Order.md)| order placed for purchasing the pet |
### Return type
@@ -194,5 +193,5 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json

View File

@@ -16,7 +16,7 @@ Method | HTTP request | Description
<a name="createUser"></a>
# **createUser**
> createUser(opts)
> createUser(body)
Create user
@@ -28,9 +28,8 @@ var SwaggerPetstore = require('swagger-petstore');
var apiInstance = new SwaggerPetstore.UserApi();
var opts = {
'body': new SwaggerPetstore.User() // User | Created user object
};
var body = new SwaggerPetstore.User(); // User | Created user object
var callback = function(error, data, response) {
if (error) {
@@ -39,14 +38,14 @@ var callback = function(error, data, response) {
console.log('API called successfully.');
}
};
apiInstance.createUser(opts, callback);
apiInstance.createUser(body, callback);
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**User**](User.md)| Created user object | [optional]
**body** | [**User**](User.md)| Created user object |
### Return type
@@ -59,11 +58,11 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="createUsersWithArrayInput"></a>
# **createUsersWithArrayInput**
> createUsersWithArrayInput(opts)
> createUsersWithArrayInput(body)
Creates list of users with given input array
@@ -75,9 +74,8 @@ var SwaggerPetstore = require('swagger-petstore');
var apiInstance = new SwaggerPetstore.UserApi();
var opts = {
'body': [new SwaggerPetstore.User()] // [User] | List of user object
};
var body = [new SwaggerPetstore.User()]; // [User] | List of user object
var callback = function(error, data, response) {
if (error) {
@@ -86,14 +84,14 @@ var callback = function(error, data, response) {
console.log('API called successfully.');
}
};
apiInstance.createUsersWithArrayInput(opts, callback);
apiInstance.createUsersWithArrayInput(body, callback);
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**[User]**](User.md)| List of user object | [optional]
**body** | [**[User]**](User.md)| List of user object |
### Return type
@@ -106,11 +104,11 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="createUsersWithListInput"></a>
# **createUsersWithListInput**
> createUsersWithListInput(opts)
> createUsersWithListInput(body)
Creates list of users with given input array
@@ -122,9 +120,8 @@ var SwaggerPetstore = require('swagger-petstore');
var apiInstance = new SwaggerPetstore.UserApi();
var opts = {
'body': [new SwaggerPetstore.User()] // [User] | List of user object
};
var body = [new SwaggerPetstore.User()]; // [User] | List of user object
var callback = function(error, data, response) {
if (error) {
@@ -133,14 +130,14 @@ var callback = function(error, data, response) {
console.log('API called successfully.');
}
};
apiInstance.createUsersWithListInput(opts, callback);
apiInstance.createUsersWithListInput(body, callback);
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**[User]**](User.md)| List of user object | [optional]
**body** | [**[User]**](User.md)| List of user object |
### Return type
@@ -153,7 +150,7 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="deleteUser"></a>
# **deleteUser**
@@ -199,7 +196,7 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="getUserByName"></a>
# **getUserByName**
@@ -245,11 +242,11 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="loginUser"></a>
# **loginUser**
> &#39;String&#39; loginUser(opts)
> &#39;String&#39; loginUser(username, password)
Logs user into the system
@@ -261,10 +258,10 @@ var SwaggerPetstore = require('swagger-petstore');
var apiInstance = new SwaggerPetstore.UserApi();
var opts = {
'username': "username_example", // String | The user name for login
'password': "password_example" // String | The password for login in clear text
};
var username = "username_example"; // String | The user name for login
var password = "password_example"; // String | The password for login in clear text
var callback = function(error, data, response) {
if (error) {
@@ -273,15 +270,15 @@ var callback = function(error, data, response) {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.loginUser(opts, callback);
apiInstance.loginUser(username, password, callback);
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The user name for login | [optional]
**password** | **String**| The password for login in clear text | [optional]
**username** | **String**| The user name for login |
**password** | **String**| The password for login in clear text |
### Return type
@@ -294,7 +291,7 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="logoutUser"></a>
# **logoutUser**
@@ -334,11 +331,11 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json
<a name="updateUser"></a>
# **updateUser**
> updateUser(username, opts)
> updateUser(username, body)
Updated user
@@ -352,9 +349,8 @@ var apiInstance = new SwaggerPetstore.UserApi();
var username = "username_example"; // String | name that need to be deleted
var opts = {
'body': new SwaggerPetstore.User() // User | Updated user object
};
var body = new SwaggerPetstore.User(); // User | Updated user object
var callback = function(error, data, response) {
if (error) {
@@ -363,7 +359,7 @@ var callback = function(error, data, response) {
console.log('API called successfully.');
}
};
apiInstance.updateUser(username, opts, callback);
apiInstance.updateUser(username, body, callback);
```
### Parameters
@@ -371,7 +367,7 @@ apiInstance.updateUser(username, opts, callback);
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| name that need to be deleted |
**body** | [**User**](User.md)| Updated user object | [optional]
**body** | [**User**](User.md)| Updated user object |
### Return type
@@ -384,5 +380,5 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
- **Accept**: application/xml, application/json

View File

@@ -1,7 +1,7 @@
{
"name": "swagger-petstore",
"version": "1.0.0",
"description": "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",
"description": "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose.",
"license": "Apache 2.0",
"main": "src/index.js",
"scripts": {

View File

@@ -0,0 +1,121 @@
(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.FakeApi = factory(root.SwaggerPetstore.ApiClient);
}
}(this, function(ApiClient) {
'use strict';
/**
* Fake service.
* @module api/FakeApi
* @version 1.0.0
*/
/**
* Constructs a new FakeApi.
* @alias module:api/FakeApi
* @class
* @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;
/**
* Callback function to receive the result of the testEndpointParameters operation.
* @callback module:api/FakeApi~testEndpointParametersCallback
* @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 for testing various parameters
* Fake endpoint for testing various parameters
* @param {Number} _number None
* @param {Number} _double None
* @param {String} _string None
* @param {String} _byte None
* @param {Object} opts Optional parameters
* @param {Integer} opts.integer None
* @param {Integer} opts.int32 None
* @param {Integer} opts.int64 None
* @param {Number} opts._float None
* @param {String} opts.binary None
* @param {Date} opts._date None
* @param {Date} opts.dateTime None
* @param {String} opts.password None
* @param {module:api/FakeApi~testEndpointParametersCallback} callback The callback function, accepting three arguments: error, data, response
*/
this.testEndpointParameters = function(_number, _double, _string, _byte, opts, callback) {
opts = opts || {};
var postBody = null;
// verify the required parameter '_number' is set
if (_number == undefined || _number == null) {
throw "Missing the required parameter '_number' when calling testEndpointParameters";
}
// verify the required parameter '_double' is set
if (_double == undefined || _double == null) {
throw "Missing the required parameter '_double' when calling testEndpointParameters";
}
// verify the required parameter '_string' is set
if (_string == undefined || _string == null) {
throw "Missing the required parameter '_string' when calling testEndpointParameters";
}
// verify the required parameter '_byte' is set
if (_byte == undefined || _byte == null) {
throw "Missing the required parameter '_byte' when calling testEndpointParameters";
}
var pathParams = {
};
var queryParams = {
};
var headerParams = {
};
var formParams = {
'integer': opts['integer'],
'int32': opts['int32'],
'int64': opts['int64'],
'number': _number,
'float': opts['_float'],
'double': _double,
'string': _string,
'byte': _byte,
'binary': opts['binary'],
'date': opts['_date'],
'dateTime': opts['dateTime'],
'password': opts['password']
};
var authNames = [];
var contentTypes = [];
var accepts = ['application/xml', 'application/json'];
var returnType = null;
return this.apiClient.callApi(
'/fake', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
};
return exports;
}));

View File

@@ -1,18 +1,18 @@
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['ApiClient', 'model/Pet'], factory);
define(['ApiClient', 'model/Pet', 'model/ApiResponse'], 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'));
module.exports = factory(require('../ApiClient'), require('../model/Pet'), require('../model/ApiResponse'));
} else {
// Browser globals (root is window)
if (!root.SwaggerPetstore) {
root.SwaggerPetstore = {};
}
root.SwaggerPetstore.PetApi = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Pet);
root.SwaggerPetstore.PetApi = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Pet, root.SwaggerPetstore.ApiResponse);
}
}(this, function(ApiClient, Pet) {
}(this, function(ApiClient, Pet, ApiResponse) {
'use strict';
/**
@@ -43,13 +43,16 @@
/**
* Add a new pet to the store
*
* @param {Object} opts Optional parameters
* @param {module:model/Pet} opts.body Pet object that needs to be added to the store
* @param {module:model/Pet} 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
*/
this.addPet = function(opts, callback) {
opts = opts || {};
var postBody = opts['body'];
this.addPet = function(body, callback) {
var postBody = body;
// verify the required parameter 'body' is set
if (body == undefined || body == null) {
throw "Missing the required parameter 'body' when calling addPet";
}
var pathParams = {
@@ -63,7 +66,7 @@
var authNames = ['petstore_auth'];
var contentTypes = ['application/json', 'application/xml'];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = null;
return this.apiClient.callApi(
@@ -112,7 +115,7 @@
var authNames = ['petstore_auth'];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = null;
return this.apiClient.callApi(
@@ -132,21 +135,24 @@
/**
* Finds Pets by status
* Multiple status values can be provided with comma seperated strings
* @param {Object} opts Optional parameters
* @param {Array.<String>} opts.status Status values that need to be considered for filter (default to available)
* Multiple status values can be provided with comma separated strings
* @param {Array.<String>} status Status values that need to be considered for filter
* @param {module:api/PetApi~findPetsByStatusCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {Array.<module:model/Pet>}
*/
this.findPetsByStatus = function(opts, callback) {
opts = opts || {};
this.findPetsByStatus = function(status, callback) {
var postBody = null;
// verify the required parameter 'status' is set
if (status == undefined || status == null) {
throw "Missing the required parameter 'status' when calling findPetsByStatus";
}
var pathParams = {
};
var queryParams = {
'status': this.apiClient.buildCollectionParam(opts['status'], 'multi')
'status': this.apiClient.buildCollectionParam(status, 'csv')
};
var headerParams = {
};
@@ -155,7 +161,7 @@
var authNames = ['petstore_auth'];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = [Pet];
return this.apiClient.callApi(
@@ -175,21 +181,24 @@
/**
* Finds Pets by tags
* Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
* @param {Object} opts Optional parameters
* @param {Array.<String>} opts.tags Tags to filter by
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param {Array.<String>} 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.<module:model/Pet>}
*/
this.findPetsByTags = function(opts, callback) {
opts = opts || {};
this.findPetsByTags = function(tags, callback) {
var postBody = null;
// verify the required parameter 'tags' is set
if (tags == undefined || tags == null) {
throw "Missing the required parameter 'tags' when calling findPetsByTags";
}
var pathParams = {
};
var queryParams = {
'tags': this.apiClient.buildCollectionParam(opts['tags'], 'multi')
'tags': this.apiClient.buildCollectionParam(tags, 'csv')
};
var headerParams = {
};
@@ -198,7 +207,7 @@
var authNames = ['petstore_auth'];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = [Pet];
return this.apiClient.callApi(
@@ -218,8 +227,8 @@
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param {Integer} petId ID of pet that needs to be fetched
* Returns a single pet
* @param {Integer} petId ID of pet to return
* @param {module:api/PetApi~getPetByIdCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {module:model/Pet}
*/
@@ -242,9 +251,9 @@
var formParams = {
};
var authNames = ['api_key', 'petstore_auth'];
var authNames = ['api_key'];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = Pet;
return this.apiClient.callApi(
@@ -265,13 +274,16 @@
/**
* Update an existing pet
*
* @param {Object} opts Optional parameters
* @param {module:model/Pet} opts.body Pet object that needs to be added to the store
* @param {module:model/Pet} 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
*/
this.updatePet = function(opts, callback) {
opts = opts || {};
var postBody = opts['body'];
this.updatePet = function(body, callback) {
var postBody = body;
// verify the required parameter 'body' is set
if (body == undefined || body == null) {
throw "Missing the required parameter 'body' when calling updatePet";
}
var pathParams = {
@@ -285,7 +297,7 @@
var authNames = ['petstore_auth'];
var contentTypes = ['application/json', 'application/xml'];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = null;
return this.apiClient.callApi(
@@ -306,7 +318,7 @@
/**
* Updates a pet in the store with form data
*
* @param {String} petId ID of pet that needs to be updated
* @param {Integer} petId ID of pet that needs to be updated
* @param {Object} opts Optional parameters
* @param {String} opts.name Updated name of the pet
* @param {String} opts.status Updated status of the pet
@@ -336,7 +348,7 @@
var authNames = ['petstore_auth'];
var contentTypes = ['application/x-www-form-urlencoded'];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = null;
return this.apiClient.callApi(
@@ -350,7 +362,7 @@
* 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 {module:model/ApiResponse} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
@@ -362,6 +374,7 @@
* @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
* data is of type: {module:model/ApiResponse}
*/
this.uploadFile = function(petId, opts, callback) {
opts = opts || {};
@@ -387,8 +400,8 @@
var authNames = ['petstore_auth'];
var contentTypes = ['multipart/form-data'];
var accepts = ['application/json', 'application/xml'];
var returnType = null;
var accepts = ['application/json'];
var returnType = ApiResponse;
return this.apiClient.callApi(
'/pet/{petId}/uploadImage', 'POST',

View File

@@ -67,7 +67,7 @@
var authNames = [];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = null;
return this.apiClient.callApi(
@@ -106,7 +106,7 @@
var authNames = ['api_key'];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/json'];
var returnType = {'String': 'Integer'};
return this.apiClient.callApi(
@@ -127,7 +127,7 @@
/**
* Find purchase order by ID
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param {String} orderId ID of pet that needs to be fetched
* @param {Integer} orderId ID of pet that needs to be fetched
* @param {module:api/StoreApi~getOrderByIdCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {module:model/Order}
*/
@@ -152,7 +152,7 @@
var authNames = [];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = Order;
return this.apiClient.callApi(
@@ -173,14 +173,17 @@
/**
* Place an order for a pet
*
* @param {Object} opts Optional parameters
* @param {module:model/Order} opts.body order placed for purchasing the pet
* @param {module:model/Order} 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}
*/
this.placeOrder = function(opts, callback) {
opts = opts || {};
var postBody = opts['body'];
this.placeOrder = function(body, callback) {
var postBody = body;
// verify the required parameter 'body' is set
if (body == undefined || body == null) {
throw "Missing the required parameter 'body' when calling placeOrder";
}
var pathParams = {
@@ -194,7 +197,7 @@
var authNames = [];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = Order;
return this.apiClient.callApi(

View File

@@ -43,13 +43,16 @@
/**
* Create user
* This can only be done by the logged in user.
* @param {Object} opts Optional parameters
* @param {module:model/User} opts.body Created user object
* @param {module:model/User} body Created user object
* @param {module:api/UserApi~createUserCallback} callback The callback function, accepting three arguments: error, data, response
*/
this.createUser = function(opts, callback) {
opts = opts || {};
var postBody = opts['body'];
this.createUser = function(body, callback) {
var postBody = body;
// verify the required parameter 'body' is set
if (body == undefined || body == null) {
throw "Missing the required parameter 'body' when calling createUser";
}
var pathParams = {
@@ -63,7 +66,7 @@
var authNames = [];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = null;
return this.apiClient.callApi(
@@ -84,13 +87,16 @@
/**
* Creates list of users with given input array
*
* @param {Object} opts Optional parameters
* @param {Array.<module:model/User>} opts.body List of user object
* @param {Array.<module:model/User>} body List of user object
* @param {module:api/UserApi~createUsersWithArrayInputCallback} callback The callback function, accepting three arguments: error, data, response
*/
this.createUsersWithArrayInput = function(opts, callback) {
opts = opts || {};
var postBody = opts['body'];
this.createUsersWithArrayInput = function(body, callback) {
var postBody = body;
// verify the required parameter 'body' is set
if (body == undefined || body == null) {
throw "Missing the required parameter 'body' when calling createUsersWithArrayInput";
}
var pathParams = {
@@ -104,7 +110,7 @@
var authNames = [];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = null;
return this.apiClient.callApi(
@@ -125,13 +131,16 @@
/**
* Creates list of users with given input array
*
* @param {Object} opts Optional parameters
* @param {Array.<module:model/User>} opts.body List of user object
* @param {Array.<module:model/User>} body List of user object
* @param {module:api/UserApi~createUsersWithListInputCallback} callback The callback function, accepting three arguments: error, data, response
*/
this.createUsersWithListInput = function(opts, callback) {
opts = opts || {};
var postBody = opts['body'];
this.createUsersWithListInput = function(body, callback) {
var postBody = body;
// verify the required parameter 'body' is set
if (body == undefined || body == null) {
throw "Missing the required parameter 'body' when calling createUsersWithListInput";
}
var pathParams = {
@@ -145,7 +154,7 @@
var authNames = [];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = null;
return this.apiClient.callApi(
@@ -190,7 +199,7 @@
var authNames = [];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = null;
return this.apiClient.callApi(
@@ -236,7 +245,7 @@
var authNames = [];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = User;
return this.apiClient.callApi(
@@ -257,22 +266,30 @@
/**
* Logs user into the system
*
* @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 {String} username The user name for login
* @param {String} 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'}
*/
this.loginUser = function(opts, callback) {
opts = opts || {};
this.loginUser = function(username, password, callback) {
var postBody = null;
// verify the required parameter 'username' is set
if (username == undefined || username == null) {
throw "Missing the required parameter 'username' when calling loginUser";
}
// verify the required parameter 'password' is set
if (password == undefined || password == null) {
throw "Missing the required parameter 'password' when calling loginUser";
}
var pathParams = {
};
var queryParams = {
'username': opts['username'],
'password': opts['password']
'username': username,
'password': password
};
var headerParams = {
};
@@ -281,7 +298,7 @@
var authNames = [];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = 'String';
return this.apiClient.callApi(
@@ -319,7 +336,7 @@
var authNames = [];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = null;
return this.apiClient.callApi(
@@ -341,19 +358,22 @@
* Updated user
* This can only be done by the logged in user.
* @param {String} username name that need to be deleted
* @param {Object} opts Optional parameters
* @param {module:model/User} opts.body Updated user object
* @param {module:model/User} body Updated user object
* @param {module:api/UserApi~updateUserCallback} callback The callback function, accepting three arguments: error, data, response
*/
this.updateUser = function(username, opts, callback) {
opts = opts || {};
var postBody = opts['body'];
this.updateUser = function(username, body, callback) {
var postBody = body;
// verify the required parameter 'username' is set
if (username == undefined || username == null) {
throw "Missing the required parameter 'username' when calling updateUser";
}
// verify the required parameter 'body' is set
if (body == undefined || body == null) {
throw "Missing the required parameter 'body' when calling updateUser";
}
var pathParams = {
'username': username
@@ -367,7 +387,7 @@
var authNames = [];
var contentTypes = [];
var accepts = ['application/json', 'application/xml'];
var accepts = ['application/xml', 'application/json'];
var returnType = null;
return this.apiClient.callApi(

View File

@@ -1,16 +1,16 @@
(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/Animal', 'model/ApiResponse', 'model/Cat', 'model/Category', 'model/Dog', 'model/EnumClass', 'model/EnumTest', 'model/FormatTest', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/Order', 'model/Pet', 'model/SpecialModelName', 'model/Tag', 'model/User', 'api/FakeApi', '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'));
module.exports = factory(require('./ApiClient'), require('./model/Animal'), require('./model/ApiResponse'), require('./model/Cat'), require('./model/Category'), require('./model/Dog'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/FormatTest'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/Order'), require('./model/Pet'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/FakeApi'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi'));
}
}(function(ApiClient, Category, Order, Pet, Tag, User, PetApi, StoreApi, UserApi) {
}(function(ApiClient, Animal, ApiResponse, Cat, Category, Dog, EnumClass, EnumTest, FormatTest, Model200Response, ModelReturn, Name, Order, Pet, SpecialModelName, Tag, User, FakeApi, PetApi, StoreApi, UserApi) {
'use strict';
/**
* This is a sample server Petstore server. You can find out more about Swagger at &lt;a href&#x3D;\&quot;http://swagger.io\&quot;&gt;http://swagger.io&lt;/a&gt; or on irc.freenode.net, #swagger. For this sample, you can use the api key \&quot;special-key\&quot; to test the authorization filters.<br>
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose..<br>
* The <code>index</code> module provides access to constructors for all the classes which comprise the public API.
* <p>
* An AMD (recommended!) or CommonJS application will generally do something equivalent to the following:
@@ -46,11 +46,61 @@
* @property {module:ApiClient}
*/
ApiClient: ApiClient,
/**
* The Animal model constructor.
* @property {module:model/Animal}
*/
Animal: Animal,
/**
* The ApiResponse model constructor.
* @property {module:model/ApiResponse}
*/
ApiResponse: ApiResponse,
/**
* The Cat model constructor.
* @property {module:model/Cat}
*/
Cat: Cat,
/**
* The Category model constructor.
* @property {module:model/Category}
*/
Category: Category,
/**
* The Dog model constructor.
* @property {module:model/Dog}
*/
Dog: Dog,
/**
* The EnumClass model constructor.
* @property {module:model/EnumClass}
*/
EnumClass: EnumClass,
/**
* The EnumTest model constructor.
* @property {module:model/EnumTest}
*/
EnumTest: EnumTest,
/**
* The FormatTest model constructor.
* @property {module:model/FormatTest}
*/
FormatTest: FormatTest,
/**
* 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}
@@ -61,6 +111,11 @@
* @property {module:model/Pet}
*/
Pet: Pet,
/**
* The SpecialModelName model constructor.
* @property {module:model/SpecialModelName}
*/
SpecialModelName: SpecialModelName,
/**
* The Tag model constructor.
* @property {module:model/Tag}
@@ -71,6 +126,11 @@
* @property {module:model/User}
*/
User: User,
/**
* The FakeApi service constructor.
* @property {module:api/FakeApi}
*/
FakeApi: FakeApi,
/**
* The PetApi service constructor.
* @property {module:api/PetApi}

View File

@@ -1,7 +1,7 @@
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['../ApiClient'], factory);
define(['ApiClient'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'));
@@ -28,8 +28,9 @@
* @param className
*/
var exports = function(className) {
var _this = this;
this['className'] = className;
_this['className'] = className;
};
/**

View File

@@ -0,0 +1,81 @@
(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.ApiResponse = factory(root.SwaggerPetstore.ApiClient);
}
}(this, function(ApiClient) {
'use strict';
/**
* The ApiResponse model module.
* @module model/ApiResponse
* @version 1.0.0
*/
/**
* Constructs a new <code>ApiResponse</code>.
* @alias module:model/ApiResponse
* @class
*/
var exports = function() {
var _this = this;
};
/**
* Constructs a <code>ApiResponse</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {module:model/ApiResponse} obj Optional instance to populate.
* @return {module:model/ApiResponse} The populated <code>ApiResponse</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('code')) {
obj['code'] = ApiClient.convertToType(data['code'], 'Integer');
}
if (data.hasOwnProperty('type')) {
obj['type'] = ApiClient.convertToType(data['type'], 'String');
}
if (data.hasOwnProperty('message')) {
obj['message'] = ApiClient.convertToType(data['message'], 'String');
}
}
return obj;
}
/**
* @member {Integer} code
*/
exports.prototype['code'] = undefined;
/**
* @member {String} type
*/
exports.prototype['type'] = undefined;
/**
* @member {String} message
*/
exports.prototype['message'] = undefined;
return exports;
}));

View File

@@ -1,7 +1,7 @@
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['../ApiClient', './Animal'], factory);
define(['ApiClient', 'model/Animal'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'), require('./Animal'));
@@ -29,7 +29,8 @@
* @param className
*/
var exports = function(className) {
Animal.call(this, className);
var _this = this;
Animal.call(_this, className);
};

View File

@@ -1,7 +1,7 @@
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['../ApiClient', './Animal'], factory);
define(['ApiClient', 'model/Animal'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'), require('./Animal'));
@@ -29,7 +29,8 @@
* @param className
*/
var exports = function(className) {
Animal.call(this, className);
var _this = this;
Animal.call(_this, className);
};

View File

@@ -0,0 +1,54 @@
(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.EnumClass = factory(root.SwaggerPetstore.ApiClient);
}
}(this, function(ApiClient) {
'use strict';
/**
* The EnumClass model module.
* @module model/EnumClass
* @version 1.0.0
*/
/**
* Constructs a new <code>EnumClass</code>.
* @alias module:model/EnumClass
* @class
*/
var exports = function() {
var _this = this;
};
/**
* Constructs a <code>EnumClass</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {module:model/EnumClass} obj Optional instance to populate.
* @return {module:model/EnumClass} The populated <code>EnumClass</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
obj = obj || new exports();
}
return obj;
}
return exports;
}));

View File

@@ -0,0 +1,129 @@
(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.EnumTest = factory(root.SwaggerPetstore.ApiClient);
}
}(this, function(ApiClient) {
'use strict';
/**
* The EnumTest model module.
* @module model/EnumTest
* @version 1.0.0
*/
/**
* Constructs a new <code>EnumTest</code>.
* @alias module:model/EnumTest
* @class
*/
var exports = function() {
var _this = this;
};
/**
* Constructs a <code>EnumTest</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {module:model/EnumTest} obj Optional instance to populate.
* @return {module:model/EnumTest} The populated <code>EnumTest</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('enum_string')) {
obj['enum_string'] = ApiClient.convertToType(data['enum_string'], 'String');
}
if (data.hasOwnProperty('enum_integer')) {
obj['enum_integer'] = ApiClient.convertToType(data['enum_integer'], 'Integer');
}
if (data.hasOwnProperty('enum_number')) {
obj['enum_number'] = ApiClient.convertToType(data['enum_number'], 'Number');
}
}
return obj;
}
/**
* @member {module:model/EnumTest.EnumStringEnum} enum_string
*/
exports.prototype['enum_string'] = undefined;
/**
* @member {module:model/EnumTest.EnumIntegerEnum} enum_integer
*/
exports.prototype['enum_integer'] = undefined;
/**
* @member {module:model/EnumTest.EnumNumberEnum} enum_number
*/
exports.prototype['enum_number'] = undefined;
/**
* Allowed values for the <code>enum_string</code> property.
* @enum {String}
* @readonly
*/
exports.EnumStringEnum = {
/**
* value: "UPPER"
* @const
*/
"UPPER": "UPPER",
/**
* value: "lower"
* @const
*/
"lower": "lower" };
/**
* Allowed values for the <code>enum_integer</code> property.
* @enum {Integer}
* @readonly
*/
exports.EnumIntegerEnum = {
/**
* value: 1
* @const
*/
"1": 1,
/**
* value: -1
* @const
*/
"-1": -1 };
/**
* Allowed values for the <code>enum_number</code> property.
* @enum {Number}
* @readonly
*/
exports.EnumNumberEnum = {
/**
* value: 1.1
* @const
*/
"1.1": 1.1,
/**
* value: -1.2
* @const
*/
"-1.2": -1.2 };
return exports;
}));

View File

@@ -1,7 +1,7 @@
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['../ApiClient'], factory);
define(['ApiClient'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'));
@@ -26,20 +26,26 @@
* @alias module:model/FormatTest
* @class
* @param _number
* @param _byte
* @param _date
* @param password
*/
var exports = function(_number) {
var exports = function(_number, _byte, _date, password) {
var _this = this;
this['number'] = _number;
_this['number'] = _number;
_this['byte'] = _byte;
_this['date'] = _date;
_this['password'] = password;
};
/**
@@ -84,7 +90,13 @@
obj['date'] = ApiClient.convertToType(data['date'], 'Date');
}
if (data.hasOwnProperty('dateTime')) {
obj['dateTime'] = ApiClient.convertToType(data['dateTime'], 'String');
obj['dateTime'] = ApiClient.convertToType(data['dateTime'], 'Date');
}
if (data.hasOwnProperty('uuid')) {
obj['uuid'] = ApiClient.convertToType(data['uuid'], 'String');
}
if (data.hasOwnProperty('password')) {
obj['password'] = ApiClient.convertToType(data['password'], 'String');
}
}
return obj;
@@ -142,10 +154,20 @@
exports.prototype['date'] = undefined;
/**
* @member {String} dateTime
* @member {Date} dateTime
*/
exports.prototype['dateTime'] = undefined;
/**
* @member {String} uuid
*/
exports.prototype['uuid'] = undefined;
/**
* @member {String} password
*/
exports.prototype['password'] = undefined;

View File

@@ -28,6 +28,7 @@
* @class
*/
var exports = function() {
var _this = this;
};

View File

@@ -28,6 +28,7 @@
* @class
*/
var exports = function() {
var _this = this;
};

View File

@@ -29,8 +29,10 @@
* @param name
*/
var exports = function(name) {
var _this = this;
_this['name'] = name;
this['name'] = name;
};
@@ -51,6 +53,9 @@
if (data.hasOwnProperty('snake_case')) {
obj['snake_case'] = ApiClient.convertToType(data['snake_case'], 'Integer');
}
if (data.hasOwnProperty('property')) {
obj['property'] = ApiClient.convertToType(data['property'], 'String');
}
}
return obj;
}
@@ -66,6 +71,11 @@
*/
exports.prototype['snake_case'] = undefined;
/**
* @member {String} property
*/
exports.prototype['property'] = undefined;

View File

@@ -99,8 +99,9 @@
/**
* @member {Boolean} complete
* @default false
*/
exports.prototype['complete'] = undefined;
exports.prototype['complete'] = false;
/**
@@ -110,23 +111,21 @@
*/
exports.StatusEnum = {
/**
* value: placed
* value: "placed"
* @const
*/
PLACED: "placed",
"placed": "placed",
/**
* value: approved
* value: "approved"
* @const
*/
APPROVED: "approved",
"approved": "approved",
/**
* value: delivered
* value: "delivered"
* @const
*/
DELIVERED: "delivered"
};
"delivered": "delivered" };
return exports;
}));

View File

@@ -112,23 +112,21 @@
*/
exports.StatusEnum = {
/**
* value: available
* value: "available"
* @const
*/
AVAILABLE: "available",
"available": "available",
/**
* value: pending
* value: "pending"
* @const
*/
PENDING: "pending",
"pending": "pending",
/**
* value: sold
* value: "sold"
* @const
*/
SOLD: "sold"
};
"sold": "sold" };
return exports;
}));

View File

@@ -27,6 +27,7 @@
* @class
*/
var exports = function() {
var _this = this;
};

View File

@@ -55,7 +55,7 @@
describe('PetApi', function() {
it('should create and get pet', function(done) {
var pet = createRandomPet();
api.addPet({body: pet}, function(error) {
api.addPet(pet, function(error) {
if (error) throw error;
api.getPetById(pet.id, function(error, fetched, response) {