diff --git a/bin/javascript-petstore.sh b/bin/javascript-petstore.sh index 11fadd17d49..2eb26210e0a 100755 --- a/bin/javascript-petstore.sh +++ b/bin/javascript-petstore.sh @@ -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 diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java index 4ba6a224781..feec76d8de2 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java @@ -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) + "\""; + } + } + } diff --git a/modules/swagger-codegen/src/main/resources/Javascript/enumClass.mustache b/modules/swagger-codegen/src/main/resources/Javascript/enumClass.mustache index d245084042a..fb1e228577c 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/enumClass.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/enumClass.mustache @@ -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}} - }; \ No newline at end of file +{{/emitJSDoc}} + "{{name}}": {{{value}}}{{^-last}}, + {{/-last}} + {{/enumVars}} + {{/allowableValues}} + }; diff --git a/samples/client/petstore/javascript/README.md b/samples/client/petstore/javascript/README.md index 2ddda0aa351..9c0393eb502 100644 --- a/samples/client/petstore/javascript/README.md +++ b/samples/client/petstore/javascript/README.md @@ -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 http://swagger.io 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) diff --git a/samples/client/petstore/javascript/docs/ApiResponse.md b/samples/client/petstore/javascript/docs/ApiResponse.md new file mode 100644 index 00000000000..0ee678b84af --- /dev/null +++ b/samples/client/petstore/javascript/docs/ApiResponse.md @@ -0,0 +1,10 @@ +# SwaggerPetstore.ApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **Integer** | | [optional] +**type** | **String** | | [optional] +**message** | **String** | | [optional] + + diff --git a/samples/client/petstore/javascript/docs/EnumClass.md b/samples/client/petstore/javascript/docs/EnumClass.md new file mode 100644 index 00000000000..5159ccfb454 --- /dev/null +++ b/samples/client/petstore/javascript/docs/EnumClass.md @@ -0,0 +1,7 @@ +# SwaggerPetstore.EnumClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + + diff --git a/samples/client/petstore/javascript/docs/EnumTest.md b/samples/client/petstore/javascript/docs/EnumTest.md new file mode 100644 index 00000000000..724eea8a25e --- /dev/null +++ b/samples/client/petstore/javascript/docs/EnumTest.md @@ -0,0 +1,10 @@ +# SwaggerPetstore.EnumTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**enumString** | **String** | | [optional] +**enumInteger** | **Integer** | | [optional] +**enumNumber** | **Number** | | [optional] + + diff --git a/samples/client/petstore/javascript/docs/FakeApi.md b/samples/client/petstore/javascript/docs/FakeApi.md new file mode 100644 index 00000000000..121056d1c56 --- /dev/null +++ b/samples/client/petstore/javascript/docs/FakeApi.md @@ -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 + + + +# **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 + diff --git a/samples/client/petstore/javascript/docs/FormatTest.md b/samples/client/petstore/javascript/docs/FormatTest.md index 57a4fb132d5..9600904ee6d 100644 --- a/samples/client/petstore/javascript/docs/FormatTest.md +++ b/samples/client/petstore/javascript/docs/FormatTest.md @@ -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** | | diff --git a/samples/client/petstore/javascript/docs/Name.md b/samples/client/petstore/javascript/docs/Name.md index f0e693f2f56..3bdb76be085 100644 --- a/samples/client/petstore/javascript/docs/Name.md +++ b/samples/client/petstore/javascript/docs/Name.md @@ -5,5 +5,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **Integer** | | **snakeCase** | **Integer** | | [optional] +**property** | **String** | | [optional] diff --git a/samples/client/petstore/javascript/docs/Order.md b/samples/client/petstore/javascript/docs/Order.md index b34b67d3a56..10503b58206 100644 --- a/samples/client/petstore/javascript/docs/Order.md +++ b/samples/client/petstore/javascript/docs/Order.md @@ -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] diff --git a/samples/client/petstore/javascript/docs/PetApi.md b/samples/client/petstore/javascript/docs/PetApi.md index 39b8726b0b6..8807e772687 100644 --- a/samples/client/petstore/javascript/docs/PetApi.md +++ b/samples/client/petstore/javascript/docs/PetApi.md @@ -16,7 +16,7 @@ Method | HTTP request | Description # **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 # **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 # **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 # **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 # **getPetById** @@ -231,7 +228,7 @@ Name | Type | Description | Notes Find pet by ID -Returns a pet when ID < 10. ID > 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 # **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 # **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 # **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 diff --git a/samples/client/petstore/javascript/docs/StoreApi.md b/samples/client/petstore/javascript/docs/StoreApi.md index 563157be5b0..39c66ed5430 100644 --- a/samples/client/petstore/javascript/docs/StoreApi.md +++ b/samples/client/petstore/javascript/docs/StoreApi.md @@ -54,7 +54,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **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 # **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 # **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 diff --git a/samples/client/petstore/javascript/docs/UserApi.md b/samples/client/petstore/javascript/docs/UserApi.md index 5f9faae29b5..6646acc83ee 100644 --- a/samples/client/petstore/javascript/docs/UserApi.md +++ b/samples/client/petstore/javascript/docs/UserApi.md @@ -16,7 +16,7 @@ Method | HTTP request | Description # **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 # **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 # **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 # **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 # **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 # **loginUser** -> 'String' loginUser(opts) +> 'String' 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 # **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 # **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 diff --git a/samples/client/petstore/javascript/package.json b/samples/client/petstore/javascript/package.json index 72a48ac71de..8ff02a78ae3 100644 --- a/samples/client/petstore/javascript/package.json +++ b/samples/client/petstore/javascript/package.json @@ -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 http://swagger.io 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": { diff --git a/samples/client/petstore/javascript/src/api/FakeApi.js b/samples/client/petstore/javascript/src/api/FakeApi.js new file mode 100644 index 00000000000..f75b8f55890 --- /dev/null +++ b/samples/client/petstore/javascript/src/api/FakeApi.js @@ -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; +})); diff --git a/samples/client/petstore/javascript/src/api/PetApi.js b/samples/client/petstore/javascript/src/api/PetApi.js index da88c3f34f9..6e7193bd53e 100644 --- a/samples/client/petstore/javascript/src/api/PetApi.js +++ b/samples/client/petstore/javascript/src/api/PetApi.js @@ -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.} 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.} 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.} */ - 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.} opts.tags Tags to filter by + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param {Array.} 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.} */ - 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 < 10. ID > 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', diff --git a/samples/client/petstore/javascript/src/api/StoreApi.js b/samples/client/petstore/javascript/src/api/StoreApi.js index 56c05b82aa4..8b9aa077de7 100644 --- a/samples/client/petstore/javascript/src/api/StoreApi.js +++ b/samples/client/petstore/javascript/src/api/StoreApi.js @@ -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 <= 5 or > 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( diff --git a/samples/client/petstore/javascript/src/api/UserApi.js b/samples/client/petstore/javascript/src/api/UserApi.js index 00c717cc3de..4bc7218fdce 100644 --- a/samples/client/petstore/javascript/src/api/UserApi.js +++ b/samples/client/petstore/javascript/src/api/UserApi.js @@ -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.} opts.body List of user object + * @param {Array.} 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.} opts.body List of user object + * @param {Array.} 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( diff --git a/samples/client/petstore/javascript/src/index.js b/samples/client/petstore/javascript/src/index.js index b0d17b3ef3a..2c3fb27ef65 100644 --- a/samples/client/petstore/javascript/src/index.js +++ b/samples/client/petstore/javascript/src/index.js @@ -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 <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..
* 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: @@ -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} diff --git a/samples/client/petstore/javascript/src/model/Animal.js b/samples/client/petstore/javascript/src/model/Animal.js index 674471a30ee..591b2530758 100644 --- a/samples/client/petstore/javascript/src/model/Animal.js +++ b/samples/client/petstore/javascript/src/model/Animal.js @@ -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; }; /** @@ -40,7 +41,7 @@ * @return {module:model/Animal} The populated Animal instance. */ exports.constructFromObject = function(data, obj) { - if (data) { + if (data) { obj = obj || new exports(); if (data.hasOwnProperty('className')) { diff --git a/samples/client/petstore/javascript/src/model/ApiResponse.js b/samples/client/petstore/javascript/src/model/ApiResponse.js new file mode 100644 index 00000000000..6d03d2767db --- /dev/null +++ b/samples/client/petstore/javascript/src/model/ApiResponse.js @@ -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 ApiResponse. + * @alias module:model/ApiResponse + * @class + */ + var exports = function() { + var _this = this; + + + + + }; + + /** + * Constructs a ApiResponse 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/ApiResponse} obj Optional instance to populate. + * @return {module:model/ApiResponse} The populated ApiResponse 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; +})); diff --git a/samples/client/petstore/javascript/src/model/Cat.js b/samples/client/petstore/javascript/src/model/Cat.js index c878af6edec..9a19820832a 100644 --- a/samples/client/petstore/javascript/src/model/Cat.js +++ b/samples/client/petstore/javascript/src/model/Cat.js @@ -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); }; @@ -41,7 +42,7 @@ * @return {module:model/Cat} The populated Cat instance. */ exports.constructFromObject = function(data, obj) { - if (data) { + if (data) { obj = obj || new exports(); Animal.constructFromObject(data, obj); if (data.hasOwnProperty('declawed')) { diff --git a/samples/client/petstore/javascript/src/model/Dog.js b/samples/client/petstore/javascript/src/model/Dog.js index e5e55581a70..2ec22654277 100644 --- a/samples/client/petstore/javascript/src/model/Dog.js +++ b/samples/client/petstore/javascript/src/model/Dog.js @@ -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); }; @@ -41,7 +42,7 @@ * @return {module:model/Dog} The populated Dog instance. */ exports.constructFromObject = function(data, obj) { - if (data) { + if (data) { obj = obj || new exports(); Animal.constructFromObject(data, obj); if (data.hasOwnProperty('breed')) { diff --git a/samples/client/petstore/javascript/src/model/EnumClass.js b/samples/client/petstore/javascript/src/model/EnumClass.js new file mode 100644 index 00000000000..2b26b447e8e --- /dev/null +++ b/samples/client/petstore/javascript/src/model/EnumClass.js @@ -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 EnumClass. + * @alias module:model/EnumClass + * @class + */ + var exports = function() { + var _this = this; + + }; + + /** + * Constructs a EnumClass 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/EnumClass} obj Optional instance to populate. + * @return {module:model/EnumClass} The populated EnumClass instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + + } + return obj; + } + + + + + + return exports; +})); diff --git a/samples/client/petstore/javascript/src/model/EnumTest.js b/samples/client/petstore/javascript/src/model/EnumTest.js new file mode 100644 index 00000000000..d4f6923dae2 --- /dev/null +++ b/samples/client/petstore/javascript/src/model/EnumTest.js @@ -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 EnumTest. + * @alias module:model/EnumTest + * @class + */ + var exports = function() { + var _this = this; + + + + + }; + + /** + * Constructs a EnumTest 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/EnumTest} obj Optional instance to populate. + * @return {module:model/EnumTest} The populated EnumTest 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 enum_string property. + * @enum {String} + * @readonly + */ + exports.EnumStringEnum = { + /** + * value: "UPPER" + * @const + */ + "UPPER": "UPPER", + /** + * value: "lower" + * @const + */ + "lower": "lower" }; + /** + * Allowed values for the enum_integer property. + * @enum {Integer} + * @readonly + */ + exports.EnumIntegerEnum = { + /** + * value: 1 + * @const + */ + "1": 1, + /** + * value: -1 + * @const + */ + "-1": -1 }; + /** + * Allowed values for the enum_number property. + * @enum {Number} + * @readonly + */ + exports.EnumNumberEnum = { + /** + * value: 1.1 + * @const + */ + "1.1": 1.1, + /** + * value: -1.2 + * @const + */ + "-1.2": -1.2 }; + + + return exports; +})); diff --git a/samples/client/petstore/javascript/src/model/FormatTest.js b/samples/client/petstore/javascript/src/model/FormatTest.js index 46a9bc854fc..8f3a531bad5 100644 --- a/samples/client/petstore/javascript/src/model/FormatTest.js +++ b/samples/client/petstore/javascript/src/model/FormatTest.js @@ -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; }; /** @@ -50,7 +56,7 @@ * @return {module:model/FormatTest} The populated FormatTest instance. */ exports.constructFromObject = function(data, obj) { - if (data) { + if (data) { obj = obj || new exports(); if (data.hasOwnProperty('integer')) { @@ -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; + diff --git a/samples/client/petstore/javascript/src/model/Model200Response.js b/samples/client/petstore/javascript/src/model/Model200Response.js index 8381185d9d0..908e264fe22 100644 --- a/samples/client/petstore/javascript/src/model/Model200Response.js +++ b/samples/client/petstore/javascript/src/model/Model200Response.js @@ -28,6 +28,7 @@ * @class */ var exports = function() { + var _this = this; }; @@ -40,7 +41,7 @@ * @return {module:model/Model200Response} The populated Model200Response instance. */ exports.constructFromObject = function(data, obj) { - if (data) { + if (data) { obj = obj || new exports(); if (data.hasOwnProperty('name')) { diff --git a/samples/client/petstore/javascript/src/model/ModelReturn.js b/samples/client/petstore/javascript/src/model/ModelReturn.js index 9549db64d46..156ee977eee 100644 --- a/samples/client/petstore/javascript/src/model/ModelReturn.js +++ b/samples/client/petstore/javascript/src/model/ModelReturn.js @@ -28,6 +28,7 @@ * @class */ var exports = function() { + var _this = this; }; @@ -40,7 +41,7 @@ * @return {module:model/ModelReturn} The populated ModelReturn instance. */ exports.constructFromObject = function(data, obj) { - if (data) { + if (data) { obj = obj || new exports(); if (data.hasOwnProperty('return')) { diff --git a/samples/client/petstore/javascript/src/model/Name.js b/samples/client/petstore/javascript/src/model/Name.js index 08a5a34c29a..63616e26d29 100644 --- a/samples/client/petstore/javascript/src/model/Name.js +++ b/samples/client/petstore/javascript/src/model/Name.js @@ -29,8 +29,10 @@ * @param name */ var exports = function(name) { + var _this = this; + + _this['name'] = name; - this['name'] = name; }; @@ -42,7 +44,7 @@ * @return {module:model/Name} The populated Name instance. */ exports.constructFromObject = function(data, obj) { - if (data) { + if (data) { obj = obj || new exports(); if (data.hasOwnProperty('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; + diff --git a/samples/client/petstore/javascript/src/model/Order.js b/samples/client/petstore/javascript/src/model/Order.js index 664908b77a9..f5c2ee1f4e0 100644 --- a/samples/client/petstore/javascript/src/model/Order.js +++ b/samples/client/petstore/javascript/src/model/Order.js @@ -99,8 +99,9 @@ /** * @member {Boolean} complete + * @default false */ - exports.prototype['complete'] = undefined; + exports.prototype['complete'] = false; /** @@ -108,25 +109,23 @@ * @enum {String} * @readonly */ - exports.StatusEnum = { + 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; })); diff --git a/samples/client/petstore/javascript/src/model/Pet.js b/samples/client/petstore/javascript/src/model/Pet.js index ae907d35ca2..c4f68d17eca 100644 --- a/samples/client/petstore/javascript/src/model/Pet.js +++ b/samples/client/petstore/javascript/src/model/Pet.js @@ -110,25 +110,23 @@ * @enum {String} * @readonly */ - exports.StatusEnum = { + 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; })); diff --git a/samples/client/petstore/javascript/src/model/SpecialModelName.js b/samples/client/petstore/javascript/src/model/SpecialModelName.js index 8694196cdd9..3f0ef79cebf 100644 --- a/samples/client/petstore/javascript/src/model/SpecialModelName.js +++ b/samples/client/petstore/javascript/src/model/SpecialModelName.js @@ -27,6 +27,7 @@ * @class */ var exports = function() { + var _this = this; }; @@ -39,7 +40,7 @@ * @return {module:model/SpecialModelName} The populated SpecialModelName instance. */ exports.constructFromObject = function(data, obj) { - if (data) { + if (data) { obj = obj || new exports(); if (data.hasOwnProperty('$special[property.name]')) { diff --git a/samples/client/petstore/javascript/test/api/PetApiTest.js b/samples/client/petstore/javascript/test/api/PetApiTest.js index 700b30ac505..213660d8058 100644 --- a/samples/client/petstore/javascript/test/api/PetApiTest.js +++ b/samples/client/petstore/javascript/test/api/PetApiTest.js @@ -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) {