From 7a245e31894c30a050e59cffefb97739005c0013 Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 8 Aug 2016 18:52:24 +0800 Subject: [PATCH] [JavaScript] add enum tests cases for JS generator (java) (#3546) * add enum tests cases for JS generator (java) * fix typo quote --- bin/javascript-petstore-all.sh | 4 + .../io/swagger/codegen/DefaultCodegen.java | 14 ++ .../languages/JavascriptClientCodegen.java | 21 +-- .../javascript/JavaScriptModelEnumTest.java | 59 ++++++++ .../petstore/javascript-promise/README.md | 40 ++---- .../javascript-promise/docs/Client.md | 8 ++ .../javascript-promise/docs/EnumArrays.md | 31 ++++ .../javascript-promise/docs/FakeApi.md | 42 ++++++ .../petstore/javascript-promise/docs/List.md | 8 ++ .../javascript-promise/docs/MapTest.md | 4 + .../javascript-promise/src/ApiClient.js | 4 +- .../javascript-promise/src/api/FakeApi.js | 44 +++++- .../petstore/javascript-promise/src/index.js | 21 ++- .../javascript-promise/src/model/Client.js | 90 ++++++++++++ .../src/model/EnumArrays.js | 132 ++++++++++++++++++ .../javascript-promise/src/model/List.js | 90 ++++++++++++ .../test/model/Client.spec.js | 76 ++++++++++ .../test/model/EnumArrays.spec.js | 82 +++++++++++ .../test/model/List.spec.js | 76 ++++++++++ samples/client/petstore/javascript/README.md | 40 ++---- .../client/petstore/javascript/docs/Client.md | 8 ++ .../petstore/javascript/docs/EnumArrays.md | 31 ++++ .../petstore/javascript/docs/FakeApi.md | 45 ++++++ .../client/petstore/javascript/docs/List.md | 8 ++ .../petstore/javascript/docs/MapTest.md | 4 + .../petstore/javascript/src/ApiClient.js | 4 +- .../petstore/javascript/src/api/FakeApi.js | 52 ++++++- .../client/petstore/javascript/src/index.js | 21 ++- .../petstore/javascript/src/model/Client.js | 90 ++++++++++++ .../javascript/src/model/EnumArrays.js | 132 ++++++++++++++++++ .../petstore/javascript/src/model/List.js | 90 ++++++++++++ .../javascript/test/model/Client.spec.js | 76 ++++++++++ .../javascript/test/model/EnumArrays.spec.js | 82 +++++++++++ .../javascript/test/model/List.spec.js | 76 ++++++++++ 34 files changed, 1518 insertions(+), 87 deletions(-) create mode 100755 bin/javascript-petstore-all.sh create mode 100644 samples/client/petstore/javascript-promise/docs/Client.md create mode 100644 samples/client/petstore/javascript-promise/docs/EnumArrays.md create mode 100644 samples/client/petstore/javascript-promise/docs/List.md create mode 100644 samples/client/petstore/javascript-promise/src/model/Client.js create mode 100644 samples/client/petstore/javascript-promise/src/model/EnumArrays.js create mode 100644 samples/client/petstore/javascript-promise/src/model/List.js create mode 100644 samples/client/petstore/javascript-promise/test/model/Client.spec.js create mode 100644 samples/client/petstore/javascript-promise/test/model/EnumArrays.spec.js create mode 100644 samples/client/petstore/javascript-promise/test/model/List.spec.js create mode 100644 samples/client/petstore/javascript/docs/Client.md create mode 100644 samples/client/petstore/javascript/docs/EnumArrays.md create mode 100644 samples/client/petstore/javascript/docs/List.md create mode 100644 samples/client/petstore/javascript/src/model/Client.js create mode 100644 samples/client/petstore/javascript/src/model/EnumArrays.js create mode 100644 samples/client/petstore/javascript/src/model/List.js create mode 100644 samples/client/petstore/javascript/test/model/Client.spec.js create mode 100644 samples/client/petstore/javascript/test/model/EnumArrays.spec.js create mode 100644 samples/client/petstore/javascript/test/model/List.spec.js diff --git a/bin/javascript-petstore-all.sh b/bin/javascript-petstore-all.sh new file mode 100755 index 00000000000..7bfb29e41f8 --- /dev/null +++ b/bin/javascript-petstore-all.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +./bin/javascript-petstore.sh +./bin/javascript-promise-petstore.sh diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index c00e9917215..1aaad2d834f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -806,6 +806,20 @@ public class DefaultCodegen { specialCharReplacements.put("<", "Less_Than"); specialCharReplacements.put(".", "Period"); specialCharReplacements.put("_", "Underscore"); + specialCharReplacements.put("?", "Question_Mark"); + specialCharReplacements.put(",", "Comma"); + specialCharReplacements.put("'", "Quote"); + specialCharReplacements.put("\"", "Double_Quote"); + specialCharReplacements.put("/", "Slash"); + specialCharReplacements.put("\\", "Back_Slash"); + specialCharReplacements.put("(", "Left_Parenthesis"); + specialCharReplacements.put(")", "Right_Parenthesis"); + specialCharReplacements.put("{", "Left_Curly_Bracket"); + specialCharReplacements.put("}", "Right_Curly_Bracket"); + specialCharReplacements.put("[", "Left_Square_Bracket"); + specialCharReplacements.put("]", "Right_Square_Bracket"); + specialCharReplacements.put("~", "Tilde"); + specialCharReplacements.put("`", "Backtick"); specialCharReplacements.put("<=", "Less_Than_Or_Equal_To"); specialCharReplacements.put(">=", "Greater_Than_Or_Equal_To"); 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 d80afd1d310..d0b0492d4d7 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 @@ -1008,25 +1008,12 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo @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; + // for symbol, e.g. $, # + if (getSymbolName(value) != null) { + return (getSymbolName(value)).toUpperCase(); } - // string - String var = value.replaceAll("\\W+", "_").replaceAll("_+", "_").toUpperCase(); - if (var.matches("\\d.*")) { - return "_" + var; - } else { - return var; - } - */ + return value; } @Override diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/javascript/JavaScriptModelEnumTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/javascript/JavaScriptModelEnumTest.java index 5e2306d73fb..e87c78e78ba 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/javascript/JavaScriptModelEnumTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/javascript/JavaScriptModelEnumTest.java @@ -11,6 +11,8 @@ import io.swagger.models.ModelImpl; import io.swagger.models.RefModel; import io.swagger.models.properties.Property; import io.swagger.models.properties.StringProperty; +import io.swagger.models.Swagger; +import io.swagger.parser.SwaggerParser; import org.testng.Assert; import org.testng.annotations.Test; @@ -92,4 +94,61 @@ public class JavaScriptModelEnumTest { Assert.assertEquals(enumVar.datatypeWithEnum, "UnsharedThingEnum"); Assert.assertTrue(enumVar.isEnum); } + + @Test(description = "test enum array model") + public void enumArrayMdoelTest() { + final Swagger model = new SwaggerParser().read("src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml"); + final DefaultCodegen codegen = new JavascriptClientCodegen(); + final Model definition = model.getDefinitions().get("EnumArrays"); + + Property property = definition.getProperties().get("array_enum"); + CodegenProperty prope = codegen.fromProperty("array_enum", property); + codegen.updateCodegenPropertyEnum(prope); + Assert.assertEquals(prope.datatypeWithEnum, "[ArrayEnumEnum]"); + Assert.assertEquals(prope.enumName, "ArrayEnumEnum"); + Assert.assertTrue(prope.isEnum); + Assert.assertEquals(prope.allowableValues.get("values"), Arrays.asList("fish", "crab")); + + HashMap fish= new HashMap(); + fish.put("name", "fish"); + fish.put("value", "\"fish\""); + HashMap crab= new HashMap(); + crab.put("name", "crab"); + crab.put("value", "\"crab\""); + Assert.assertEquals(prope.allowableValues.get("enumVars"), Arrays.asList(fish, crab)); + + // assert inner items + Assert.assertEquals(prope.datatypeWithEnum, "[ArrayEnumEnum]"); + Assert.assertEquals(prope.enumName, "ArrayEnumEnum"); + Assert.assertTrue(prope.items.isEnum); + Assert.assertEquals(prope.items.allowableValues.get("values"), Arrays.asList("fish", "crab")); + Assert.assertEquals(prope.items.allowableValues.get("enumVars"), Arrays.asList(fish, crab)); + + } + + @Test(description = "test enum model for values (numeric, string, etc)") + public void enumMdoelValueTest() { + final Swagger model = new SwaggerParser().read("src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml"); + final DefaultCodegen codegen = new JavascriptClientCodegen(); + final Model definition = model.getDefinitions().get("Enum_Test"); + + Property property = definition.getProperties().get("enum_integer"); + CodegenProperty prope = codegen.fromProperty("enum_integer", property); + codegen.updateCodegenPropertyEnum(prope); + Assert.assertEquals(prope.datatypeWithEnum, "EnumIntegerEnum"); + Assert.assertEquals(prope.enumName, "EnumIntegerEnum"); + Assert.assertTrue(prope.isEnum); + Assert.assertNull(prope.isContainer); + Assert.assertNull(prope.items); + Assert.assertEquals(prope.allowableValues.get("values"), Arrays.asList(1, -1)); + + HashMap one = new HashMap(); + one.put("name", "1"); + one.put("value", "1"); + HashMap minusOne = new HashMap(); + minusOne.put("name", "-1"); + minusOne.put("value", "-1"); + Assert.assertEquals(prope.allowableValues.get("enumVars"), Arrays.asList(one, minusOne)); + + } } diff --git a/samples/client/petstore/javascript-promise/README.md b/samples/client/petstore/javascript-promise/README.md index 1c2855d1cc3..26422f437c3 100644 --- a/samples/client/petstore/javascript-promise/README.md +++ b/samples/client/petstore/javascript-promise/README.md @@ -6,7 +6,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-07-11T21:45:36.147-07:00 +- Build date: 2016-08-06T16:38:11.935+08:00 - Build package: class io.swagger.codegen.languages.JavascriptClientCodegen ## Installation @@ -55,26 +55,10 @@ var SwaggerPetstore = require('swagger_petstore'); var api = new SwaggerPetstore.FakeApi() -var _number = 3.4; // {Number} None +var body = new SwaggerPetstore.Client(); // {Client} client model -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 -}; -api.testEndpointParameters(_number, _double, _string, _byte, opts).then(function() { - console.log('API called successfully.'); +api.testClientModel(body).then(function(data) { + console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); @@ -88,6 +72,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*SwaggerPetstore.FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model *SwaggerPetstore.FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *SwaggerPetstore.FakeApi* | [**testEnumQueryParameters**](docs/FakeApi.md#testEnumQueryParameters) | **GET** /fake | To test enum query parameters *SwaggerPetstore.PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -123,11 +108,14 @@ Class | Method | HTTP request | Description - [SwaggerPetstore.ArrayTest](docs/ArrayTest.md) - [SwaggerPetstore.Cat](docs/Cat.md) - [SwaggerPetstore.Category](docs/Category.md) + - [SwaggerPetstore.Client](docs/Client.md) - [SwaggerPetstore.Dog](docs/Dog.md) + - [SwaggerPetstore.EnumArrays](docs/EnumArrays.md) - [SwaggerPetstore.EnumClass](docs/EnumClass.md) - [SwaggerPetstore.EnumTest](docs/EnumTest.md) - [SwaggerPetstore.FormatTest](docs/FormatTest.md) - [SwaggerPetstore.HasOnlyReadOnly](docs/HasOnlyReadOnly.md) + - [SwaggerPetstore.List](docs/List.md) - [SwaggerPetstore.MapTest](docs/MapTest.md) - [SwaggerPetstore.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) - [SwaggerPetstore.Model200Response](docs/Model200Response.md) @@ -145,6 +133,12 @@ Class | Method | HTTP request | Description ## Documentation for Authorization +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + ### petstore_auth - **Type**: OAuth @@ -154,9 +148,3 @@ Class | Method | HTTP request | Description - write:pets: modify pets in your account - read:pets: read your pets -### api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - diff --git a/samples/client/petstore/javascript-promise/docs/Client.md b/samples/client/petstore/javascript-promise/docs/Client.md new file mode 100644 index 00000000000..6ba28319684 --- /dev/null +++ b/samples/client/petstore/javascript-promise/docs/Client.md @@ -0,0 +1,8 @@ +# SwaggerPetstore.Client + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**client** | **String** | | [optional] + + diff --git a/samples/client/petstore/javascript-promise/docs/EnumArrays.md b/samples/client/petstore/javascript-promise/docs/EnumArrays.md new file mode 100644 index 00000000000..449a96fdbbd --- /dev/null +++ b/samples/client/petstore/javascript-promise/docs/EnumArrays.md @@ -0,0 +1,31 @@ +# SwaggerPetstore.EnumArrays + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**justSymbol** | **String** | | [optional] +**arrayEnum** | **[String]** | | [optional] + + + +## Enum: JustSymbolEnum + + +* `GREATER_THAN_OR_EQUAL_TO` (value: `">="`) + +* `DOLLAR` (value: `"$"`) + + + + + +## Enum: [ArrayEnumEnum] + + +* `fish` (value: `"fish"`) + +* `crab` (value: `"crab"`) + + + + diff --git a/samples/client/petstore/javascript-promise/docs/FakeApi.md b/samples/client/petstore/javascript-promise/docs/FakeApi.md index b7bfed32a85..339dbad7e48 100644 --- a/samples/client/petstore/javascript-promise/docs/FakeApi.md +++ b/samples/client/petstore/javascript-promise/docs/FakeApi.md @@ -4,10 +4,52 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumQueryParameters**](FakeApi.md#testEnumQueryParameters) | **GET** /fake | To test enum query parameters + +# **testClientModel** +> Client testClientModel(body) + +To test \"client\" model + +### Example +```javascript +var SwaggerPetstore = require('swagger_petstore'); + +var apiInstance = new SwaggerPetstore.FakeApi(); + +var body = new SwaggerPetstore.Client(); // Client | client model + +apiInstance.testClientModel(body).then(function(data) { + console.log('API called successfully. Returned data: ' + data); +}, function(error) { + console.error(error); +}); + +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + # **testEndpointParameters** > testEndpointParameters(_number, _double, _string, _byte, opts) diff --git a/samples/client/petstore/javascript-promise/docs/List.md b/samples/client/petstore/javascript-promise/docs/List.md new file mode 100644 index 00000000000..12166562e89 --- /dev/null +++ b/samples/client/petstore/javascript-promise/docs/List.md @@ -0,0 +1,8 @@ +# SwaggerPetstore.List + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123List** | **String** | | [optional] + + diff --git a/samples/client/petstore/javascript-promise/docs/MapTest.md b/samples/client/petstore/javascript-promise/docs/MapTest.md index ae77813d9ce..8550252a3f1 100644 --- a/samples/client/petstore/javascript-promise/docs/MapTest.md +++ b/samples/client/petstore/javascript-promise/docs/MapTest.md @@ -11,6 +11,10 @@ Name | Type | Description | Notes ## Enum: {String: String} +* `UPPER` (value: `"UPPER"`) + +* `lower` (value: `"lower"`) + diff --git a/samples/client/petstore/javascript-promise/src/ApiClient.js b/samples/client/petstore/javascript-promise/src/ApiClient.js index 4562a9bac40..06c6c73ce05 100644 --- a/samples/client/petstore/javascript-promise/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise/src/ApiClient.js @@ -64,8 +64,8 @@ * @type {Array.} */ this.authentications = { - 'petstore_auth': {type: 'oauth2'}, - 'api_key': {type: 'apiKey', 'in': 'header', name: 'api_key'} + 'api_key': {type: 'apiKey', 'in': 'header', name: 'api_key'}, + 'petstore_auth': {type: 'oauth2'} }; /** * The default HTTP headers to be included for all API calls. diff --git a/samples/client/petstore/javascript-promise/src/api/FakeApi.js b/samples/client/petstore/javascript-promise/src/api/FakeApi.js index 4cec53e3652..dd1e7242c90 100644 --- a/samples/client/petstore/javascript-promise/src/api/FakeApi.js +++ b/samples/client/petstore/javascript-promise/src/api/FakeApi.js @@ -25,18 +25,18 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['ApiClient'], factory); + define(['ApiClient', 'model/Client'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('../ApiClient')); + module.exports = factory(require('../ApiClient'), require('../model/Client')); } else { // Browser globals (root is window) if (!root.SwaggerPetstore) { root.SwaggerPetstore = {}; } - root.SwaggerPetstore.FakeApi = factory(root.SwaggerPetstore.ApiClient); + root.SwaggerPetstore.FakeApi = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Client); } -}(this, function(ApiClient) { +}(this, function(ApiClient, Client) { 'use strict'; /** @@ -57,6 +57,42 @@ + /** + * To test \"client\" model + * @param {module:model/Client} body client model + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/Client} + */ + this.testClientModel = function(body) { + var postBody = body; + + // verify the required parameter 'body' is set + if (body == undefined || body == null) { + throw "Missing the required parameter 'body' when calling testClientModel"; + } + + + var pathParams = { + }; + var queryParams = { + }; + var headerParams = { + }; + var formParams = { + }; + + var authNames = []; + var contentTypes = ['application/json']; + var accepts = ['application/json']; + var returnType = Client; + + return this.apiClient.callApi( + '/fake', 'PATCH', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType + ); + } + + /** * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 diff --git a/samples/client/petstore/javascript-promise/src/index.js b/samples/client/petstore/javascript-promise/src/index.js index 84d30e0c98f..5bf5e2c8304 100644 --- a/samples/client/petstore/javascript-promise/src/index.js +++ b/samples/client/petstore/javascript-promise/src/index.js @@ -25,12 +25,12 @@ (function(factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['ApiClient', 'model/AdditionalPropertiesClass', 'model/Animal', 'model/AnimalFarm', 'model/ApiResponse', 'model/ArrayOfArrayOfNumberOnly', 'model/ArrayOfNumberOnly', 'model/ArrayTest', 'model/Cat', 'model/Category', 'model/Dog', 'model/EnumClass', 'model/EnumTest', 'model/FormatTest', 'model/HasOnlyReadOnly', 'model/MapTest', 'model/MixedPropertiesAndAdditionalPropertiesClass', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/NumberOnly', 'model/Order', 'model/Pet', 'model/ReadOnlyFirst', 'model/SpecialModelName', 'model/Tag', 'model/User', 'api/FakeApi', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory); + define(['ApiClient', 'model/AdditionalPropertiesClass', 'model/Animal', 'model/AnimalFarm', 'model/ApiResponse', 'model/ArrayOfArrayOfNumberOnly', 'model/ArrayOfNumberOnly', 'model/ArrayTest', 'model/Cat', 'model/Category', 'model/Client', 'model/Dog', 'model/EnumArrays', 'model/EnumClass', 'model/EnumTest', 'model/FormatTest', 'model/HasOnlyReadOnly', 'model/List', 'model/MapTest', 'model/MixedPropertiesAndAdditionalPropertiesClass', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/NumberOnly', 'model/Order', 'model/Pet', 'model/ReadOnlyFirst', '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/AdditionalPropertiesClass'), require('./model/Animal'), require('./model/AnimalFarm'), require('./model/ApiResponse'), require('./model/ArrayOfArrayOfNumberOnly'), require('./model/ArrayOfNumberOnly'), require('./model/ArrayTest'), require('./model/Cat'), require('./model/Category'), require('./model/Dog'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/FormatTest'), require('./model/HasOnlyReadOnly'), require('./model/MapTest'), require('./model/MixedPropertiesAndAdditionalPropertiesClass'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/NumberOnly'), require('./model/Order'), require('./model/Pet'), require('./model/ReadOnlyFirst'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/FakeApi'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); + module.exports = factory(require('./ApiClient'), require('./model/AdditionalPropertiesClass'), require('./model/Animal'), require('./model/AnimalFarm'), require('./model/ApiResponse'), require('./model/ArrayOfArrayOfNumberOnly'), require('./model/ArrayOfNumberOnly'), require('./model/ArrayTest'), require('./model/Cat'), require('./model/Category'), require('./model/Client'), require('./model/Dog'), require('./model/EnumArrays'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/FormatTest'), require('./model/HasOnlyReadOnly'), require('./model/List'), require('./model/MapTest'), require('./model/MixedPropertiesAndAdditionalPropertiesClass'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/NumberOnly'), require('./model/Order'), require('./model/Pet'), require('./model/ReadOnlyFirst'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/FakeApi'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); } -}(function(ApiClient, AdditionalPropertiesClass, Animal, AnimalFarm, ApiResponse, ArrayOfArrayOfNumberOnly, ArrayOfNumberOnly, ArrayTest, Cat, Category, Dog, EnumClass, EnumTest, FormatTest, HasOnlyReadOnly, MapTest, MixedPropertiesAndAdditionalPropertiesClass, Model200Response, ModelReturn, Name, NumberOnly, Order, Pet, ReadOnlyFirst, SpecialModelName, Tag, User, FakeApi, PetApi, StoreApi, UserApi) { +}(function(ApiClient, AdditionalPropertiesClass, Animal, AnimalFarm, ApiResponse, ArrayOfArrayOfNumberOnly, ArrayOfNumberOnly, ArrayTest, Cat, Category, Client, Dog, EnumArrays, EnumClass, EnumTest, FormatTest, HasOnlyReadOnly, List, MapTest, MixedPropertiesAndAdditionalPropertiesClass, Model200Response, ModelReturn, Name, NumberOnly, Order, Pet, ReadOnlyFirst, SpecialModelName, Tag, User, FakeApi, PetApi, StoreApi, UserApi) { 'use strict'; /** @@ -115,11 +115,21 @@ * @property {module:model/Category} */ Category: Category, + /** + * The Client model constructor. + * @property {module:model/Client} + */ + Client: Client, /** * The Dog model constructor. * @property {module:model/Dog} */ Dog: Dog, + /** + * The EnumArrays model constructor. + * @property {module:model/EnumArrays} + */ + EnumArrays: EnumArrays, /** * The EnumClass model constructor. * @property {module:model/EnumClass} @@ -140,6 +150,11 @@ * @property {module:model/HasOnlyReadOnly} */ HasOnlyReadOnly: HasOnlyReadOnly, + /** + * The List model constructor. + * @property {module:model/List} + */ + List: List, /** * The MapTest model constructor. * @property {module:model/MapTest} diff --git a/samples/client/petstore/javascript-promise/src/model/Client.js b/samples/client/petstore/javascript-promise/src/model/Client.js new file mode 100644 index 00000000000..5ecb176007c --- /dev/null +++ b/samples/client/petstore/javascript-promise/src/model/Client.js @@ -0,0 +1,90 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(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.Client = factory(root.SwaggerPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + + + + /** + * The Client model module. + * @module model/Client + * @version 1.0.0 + */ + + /** + * Constructs a new Client. + * @alias module:model/Client + * @class + */ + var exports = function() { + var _this = this; + + + }; + + /** + * Constructs a Client 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/Client} obj Optional instance to populate. + * @return {module:model/Client} The populated Client instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + + if (data.hasOwnProperty('client')) { + obj['client'] = ApiClient.convertToType(data['client'], 'String'); + } + } + return obj; + } + + /** + * @member {String} client + */ + exports.prototype['client'] = undefined; + + + + return exports; +})); + + diff --git a/samples/client/petstore/javascript-promise/src/model/EnumArrays.js b/samples/client/petstore/javascript-promise/src/model/EnumArrays.js new file mode 100644 index 00000000000..adfd91990df --- /dev/null +++ b/samples/client/petstore/javascript-promise/src/model/EnumArrays.js @@ -0,0 +1,132 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(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.EnumArrays = factory(root.SwaggerPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + + + + /** + * The EnumArrays model module. + * @module model/EnumArrays + * @version 1.0.0 + */ + + /** + * Constructs a new EnumArrays. + * @alias module:model/EnumArrays + * @class + */ + var exports = function() { + var _this = this; + + + + }; + + /** + * Constructs a EnumArrays 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/EnumArrays} obj Optional instance to populate. + * @return {module:model/EnumArrays} The populated EnumArrays instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + + if (data.hasOwnProperty('just_symbol')) { + obj['just_symbol'] = ApiClient.convertToType(data['just_symbol'], 'String'); + } + if (data.hasOwnProperty('array_enum')) { + obj['array_enum'] = ApiClient.convertToType(data['array_enum'], ['String']); + } + } + return obj; + } + + /** + * @member {module:model/EnumArrays.JustSymbolEnum} just_symbol + */ + exports.prototype['just_symbol'] = undefined; + /** + * @member {Array.} array_enum + */ + exports.prototype['array_enum'] = undefined; + + + /** + * Allowed values for the just_symbol property. + * @enum {String} + * @readonly + */ + exports.JustSymbolEnum = { + /** + * value: ">=" + * @const + */ + "GREATER_THAN_OR_EQUAL_TO": ">=", + /** + * value: "$" + * @const + */ + "DOLLAR": "$" }; + + /** + * Allowed values for the arrayEnum property. + * @enum {String} + * @readonly + */ + exports.ArrayEnumEnum = { + /** + * value: "fish" + * @const + */ + "fish": "fish", + /** + * value: "crab" + * @const + */ + "crab": "crab" }; + + + return exports; +})); + + diff --git a/samples/client/petstore/javascript-promise/src/model/List.js b/samples/client/petstore/javascript-promise/src/model/List.js new file mode 100644 index 00000000000..7e88e470df8 --- /dev/null +++ b/samples/client/petstore/javascript-promise/src/model/List.js @@ -0,0 +1,90 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(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.List = factory(root.SwaggerPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + + + + /** + * The List model module. + * @module model/List + * @version 1.0.0 + */ + + /** + * Constructs a new List. + * @alias module:model/List + * @class + */ + var exports = function() { + var _this = this; + + + }; + + /** + * Constructs a List 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/List} obj Optional instance to populate. + * @return {module:model/List} The populated List instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + + if (data.hasOwnProperty('123-list')) { + obj['123-list'] = ApiClient.convertToType(data['123-list'], 'String'); + } + } + return obj; + } + + /** + * @member {String} 123-list + */ + exports.prototype['123-list'] = undefined; + + + + return exports; +})); + + diff --git a/samples/client/petstore/javascript-promise/test/model/Client.spec.js b/samples/client/petstore/javascript-promise/test/model/Client.spec.js new file mode 100644 index 00000000000..7bba630a29c --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/Client.spec.js @@ -0,0 +1,76 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Client(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Client', function() { + it('should create an instance of Client', function() { + // uncomment below and update the code to test Client + //var instane = new SwaggerPetstore.Client(); + //expect(instance).to.be.a(SwaggerPetstore.Client); + }); + + it('should have the property client (base name: "client")', function() { + // uncomment below and update the code to test the property client + //var instane = new SwaggerPetstore.Client(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/EnumArrays.spec.js b/samples/client/petstore/javascript-promise/test/model/EnumArrays.spec.js new file mode 100644 index 00000000000..2d26fb9920f --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/EnumArrays.spec.js @@ -0,0 +1,82 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.EnumArrays(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('EnumArrays', function() { + it('should create an instance of EnumArrays', function() { + // uncomment below and update the code to test EnumArrays + //var instane = new SwaggerPetstore.EnumArrays(); + //expect(instance).to.be.a(SwaggerPetstore.EnumArrays); + }); + + it('should have the property justSymbol (base name: "just_symbol")', function() { + // uncomment below and update the code to test the property justSymbol + //var instane = new SwaggerPetstore.EnumArrays(); + //expect(instance).to.be(); + }); + + it('should have the property arrayEnum (base name: "array_enum")', function() { + // uncomment below and update the code to test the property arrayEnum + //var instane = new SwaggerPetstore.EnumArrays(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/List.spec.js b/samples/client/petstore/javascript-promise/test/model/List.spec.js new file mode 100644 index 00000000000..e73583f9ebc --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/List.spec.js @@ -0,0 +1,76 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.List(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('List', function() { + it('should create an instance of List', function() { + // uncomment below and update the code to test List + //var instane = new SwaggerPetstore.List(); + //expect(instance).to.be.a(SwaggerPetstore.List); + }); + + it('should have the property _123List (base name: "123-list")', function() { + // uncomment below and update the code to test the property _123List + //var instane = new SwaggerPetstore.List(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/README.md b/samples/client/petstore/javascript/README.md index e650247fb8d..04abcd44676 100644 --- a/samples/client/petstore/javascript/README.md +++ b/samples/client/petstore/javascript/README.md @@ -6,7 +6,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-07-11T21:45:28.055-07:00 +- Build date: 2016-08-06T16:38:09.393+08:00 - Build package: class io.swagger.codegen.languages.JavascriptClientCodegen ## Installation @@ -55,33 +55,17 @@ var SwaggerPetstore = require('swagger_petstore'); var api = new SwaggerPetstore.FakeApi() -var _number = 3.4; // {Number} None +var body = new SwaggerPetstore.Client(); // {Client} client model -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.'); + console.log('API called successfully. Returned data: ' + data); } }; -api.testEndpointParameters(_number, _double, _string, _byte, opts, callback); +api.testClientModel(body, callback); ``` @@ -91,6 +75,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*SwaggerPetstore.FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model *SwaggerPetstore.FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *SwaggerPetstore.FakeApi* | [**testEnumQueryParameters**](docs/FakeApi.md#testEnumQueryParameters) | **GET** /fake | To test enum query parameters *SwaggerPetstore.PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -126,11 +111,14 @@ Class | Method | HTTP request | Description - [SwaggerPetstore.ArrayTest](docs/ArrayTest.md) - [SwaggerPetstore.Cat](docs/Cat.md) - [SwaggerPetstore.Category](docs/Category.md) + - [SwaggerPetstore.Client](docs/Client.md) - [SwaggerPetstore.Dog](docs/Dog.md) + - [SwaggerPetstore.EnumArrays](docs/EnumArrays.md) - [SwaggerPetstore.EnumClass](docs/EnumClass.md) - [SwaggerPetstore.EnumTest](docs/EnumTest.md) - [SwaggerPetstore.FormatTest](docs/FormatTest.md) - [SwaggerPetstore.HasOnlyReadOnly](docs/HasOnlyReadOnly.md) + - [SwaggerPetstore.List](docs/List.md) - [SwaggerPetstore.MapTest](docs/MapTest.md) - [SwaggerPetstore.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) - [SwaggerPetstore.Model200Response](docs/Model200Response.md) @@ -148,6 +136,12 @@ Class | Method | HTTP request | Description ## Documentation for Authorization +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + ### petstore_auth - **Type**: OAuth @@ -157,9 +151,3 @@ Class | Method | HTTP request | Description - write:pets: modify pets in your account - read:pets: read your pets -### api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - diff --git a/samples/client/petstore/javascript/docs/Client.md b/samples/client/petstore/javascript/docs/Client.md new file mode 100644 index 00000000000..6ba28319684 --- /dev/null +++ b/samples/client/petstore/javascript/docs/Client.md @@ -0,0 +1,8 @@ +# SwaggerPetstore.Client + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**client** | **String** | | [optional] + + diff --git a/samples/client/petstore/javascript/docs/EnumArrays.md b/samples/client/petstore/javascript/docs/EnumArrays.md new file mode 100644 index 00000000000..449a96fdbbd --- /dev/null +++ b/samples/client/petstore/javascript/docs/EnumArrays.md @@ -0,0 +1,31 @@ +# SwaggerPetstore.EnumArrays + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**justSymbol** | **String** | | [optional] +**arrayEnum** | **[String]** | | [optional] + + + +## Enum: JustSymbolEnum + + +* `GREATER_THAN_OR_EQUAL_TO` (value: `">="`) + +* `DOLLAR` (value: `"$"`) + + + + + +## Enum: [ArrayEnumEnum] + + +* `fish` (value: `"fish"`) + +* `crab` (value: `"crab"`) + + + + diff --git a/samples/client/petstore/javascript/docs/FakeApi.md b/samples/client/petstore/javascript/docs/FakeApi.md index 03c118a892c..ac881b1d4f1 100644 --- a/samples/client/petstore/javascript/docs/FakeApi.md +++ b/samples/client/petstore/javascript/docs/FakeApi.md @@ -4,10 +4,55 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumQueryParameters**](FakeApi.md#testEnumQueryParameters) | **GET** /fake | To test enum query parameters + +# **testClientModel** +> Client testClientModel(body) + +To test \"client\" model + +### Example +```javascript +var SwaggerPetstore = require('swagger_petstore'); + +var apiInstance = new SwaggerPetstore.FakeApi(); + +var body = new SwaggerPetstore.Client(); // Client | client model + + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully. Returned data: ' + data); + } +}; +apiInstance.testClientModel(body, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + # **testEndpointParameters** > testEndpointParameters(_number, _double, _string, _byte, opts) diff --git a/samples/client/petstore/javascript/docs/List.md b/samples/client/petstore/javascript/docs/List.md new file mode 100644 index 00000000000..12166562e89 --- /dev/null +++ b/samples/client/petstore/javascript/docs/List.md @@ -0,0 +1,8 @@ +# SwaggerPetstore.List + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123List** | **String** | | [optional] + + diff --git a/samples/client/petstore/javascript/docs/MapTest.md b/samples/client/petstore/javascript/docs/MapTest.md index ae77813d9ce..8550252a3f1 100644 --- a/samples/client/petstore/javascript/docs/MapTest.md +++ b/samples/client/petstore/javascript/docs/MapTest.md @@ -11,6 +11,10 @@ Name | Type | Description | Notes ## Enum: {String: String} +* `UPPER` (value: `"UPPER"`) + +* `lower` (value: `"lower"`) + diff --git a/samples/client/petstore/javascript/src/ApiClient.js b/samples/client/petstore/javascript/src/ApiClient.js index b18565469a0..0c78f7fdf49 100644 --- a/samples/client/petstore/javascript/src/ApiClient.js +++ b/samples/client/petstore/javascript/src/ApiClient.js @@ -64,8 +64,8 @@ * @type {Array.} */ this.authentications = { - 'petstore_auth': {type: 'oauth2'}, - 'api_key': {type: 'apiKey', 'in': 'header', name: 'api_key'} + 'api_key': {type: 'apiKey', 'in': 'header', name: 'api_key'}, + 'petstore_auth': {type: 'oauth2'} }; /** * The default HTTP headers to be included for all API calls. diff --git a/samples/client/petstore/javascript/src/api/FakeApi.js b/samples/client/petstore/javascript/src/api/FakeApi.js index 3c91e974df4..377d8568d9f 100644 --- a/samples/client/petstore/javascript/src/api/FakeApi.js +++ b/samples/client/petstore/javascript/src/api/FakeApi.js @@ -25,18 +25,18 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['ApiClient'], factory); + define(['ApiClient', 'model/Client'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('../ApiClient')); + module.exports = factory(require('../ApiClient'), require('../model/Client')); } else { // Browser globals (root is window) if (!root.SwaggerPetstore) { root.SwaggerPetstore = {}; } - root.SwaggerPetstore.FakeApi = factory(root.SwaggerPetstore.ApiClient); + root.SwaggerPetstore.FakeApi = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Client); } -}(this, function(ApiClient) { +}(this, function(ApiClient, Client) { 'use strict'; /** @@ -56,6 +56,50 @@ this.apiClient = apiClient || ApiClient.instance; + /** + * Callback function to receive the result of the testClientModel operation. + * @callback module:api/FakeApi~testClientModelCallback + * @param {String} error Error message, if any. + * @param {module:model/Client} data The data returned by the service call. + * @param {String} response The complete HTTP response. + */ + + /** + * To test \"client\" model + * @param {module:model/Client} body client model + * @param {module:api/FakeApi~testClientModelCallback} callback The callback function, accepting three arguments: error, data, response + * data is of type: {@link module:model/Client} + */ + this.testClientModel = 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 testClientModel"; + } + + + var pathParams = { + }; + var queryParams = { + }; + var headerParams = { + }; + var formParams = { + }; + + var authNames = []; + var contentTypes = ['application/json']; + var accepts = ['application/json']; + var returnType = Client; + + return this.apiClient.callApi( + '/fake', 'PATCH', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, callback + ); + } + /** * Callback function to receive the result of the testEndpointParameters operation. * @callback module:api/FakeApi~testEndpointParametersCallback diff --git a/samples/client/petstore/javascript/src/index.js b/samples/client/petstore/javascript/src/index.js index 84d30e0c98f..5bf5e2c8304 100644 --- a/samples/client/petstore/javascript/src/index.js +++ b/samples/client/petstore/javascript/src/index.js @@ -25,12 +25,12 @@ (function(factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['ApiClient', 'model/AdditionalPropertiesClass', 'model/Animal', 'model/AnimalFarm', 'model/ApiResponse', 'model/ArrayOfArrayOfNumberOnly', 'model/ArrayOfNumberOnly', 'model/ArrayTest', 'model/Cat', 'model/Category', 'model/Dog', 'model/EnumClass', 'model/EnumTest', 'model/FormatTest', 'model/HasOnlyReadOnly', 'model/MapTest', 'model/MixedPropertiesAndAdditionalPropertiesClass', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/NumberOnly', 'model/Order', 'model/Pet', 'model/ReadOnlyFirst', 'model/SpecialModelName', 'model/Tag', 'model/User', 'api/FakeApi', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory); + define(['ApiClient', 'model/AdditionalPropertiesClass', 'model/Animal', 'model/AnimalFarm', 'model/ApiResponse', 'model/ArrayOfArrayOfNumberOnly', 'model/ArrayOfNumberOnly', 'model/ArrayTest', 'model/Cat', 'model/Category', 'model/Client', 'model/Dog', 'model/EnumArrays', 'model/EnumClass', 'model/EnumTest', 'model/FormatTest', 'model/HasOnlyReadOnly', 'model/List', 'model/MapTest', 'model/MixedPropertiesAndAdditionalPropertiesClass', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/NumberOnly', 'model/Order', 'model/Pet', 'model/ReadOnlyFirst', '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/AdditionalPropertiesClass'), require('./model/Animal'), require('./model/AnimalFarm'), require('./model/ApiResponse'), require('./model/ArrayOfArrayOfNumberOnly'), require('./model/ArrayOfNumberOnly'), require('./model/ArrayTest'), require('./model/Cat'), require('./model/Category'), require('./model/Dog'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/FormatTest'), require('./model/HasOnlyReadOnly'), require('./model/MapTest'), require('./model/MixedPropertiesAndAdditionalPropertiesClass'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/NumberOnly'), require('./model/Order'), require('./model/Pet'), require('./model/ReadOnlyFirst'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/FakeApi'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); + module.exports = factory(require('./ApiClient'), require('./model/AdditionalPropertiesClass'), require('./model/Animal'), require('./model/AnimalFarm'), require('./model/ApiResponse'), require('./model/ArrayOfArrayOfNumberOnly'), require('./model/ArrayOfNumberOnly'), require('./model/ArrayTest'), require('./model/Cat'), require('./model/Category'), require('./model/Client'), require('./model/Dog'), require('./model/EnumArrays'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/FormatTest'), require('./model/HasOnlyReadOnly'), require('./model/List'), require('./model/MapTest'), require('./model/MixedPropertiesAndAdditionalPropertiesClass'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/NumberOnly'), require('./model/Order'), require('./model/Pet'), require('./model/ReadOnlyFirst'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/FakeApi'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); } -}(function(ApiClient, AdditionalPropertiesClass, Animal, AnimalFarm, ApiResponse, ArrayOfArrayOfNumberOnly, ArrayOfNumberOnly, ArrayTest, Cat, Category, Dog, EnumClass, EnumTest, FormatTest, HasOnlyReadOnly, MapTest, MixedPropertiesAndAdditionalPropertiesClass, Model200Response, ModelReturn, Name, NumberOnly, Order, Pet, ReadOnlyFirst, SpecialModelName, Tag, User, FakeApi, PetApi, StoreApi, UserApi) { +}(function(ApiClient, AdditionalPropertiesClass, Animal, AnimalFarm, ApiResponse, ArrayOfArrayOfNumberOnly, ArrayOfNumberOnly, ArrayTest, Cat, Category, Client, Dog, EnumArrays, EnumClass, EnumTest, FormatTest, HasOnlyReadOnly, List, MapTest, MixedPropertiesAndAdditionalPropertiesClass, Model200Response, ModelReturn, Name, NumberOnly, Order, Pet, ReadOnlyFirst, SpecialModelName, Tag, User, FakeApi, PetApi, StoreApi, UserApi) { 'use strict'; /** @@ -115,11 +115,21 @@ * @property {module:model/Category} */ Category: Category, + /** + * The Client model constructor. + * @property {module:model/Client} + */ + Client: Client, /** * The Dog model constructor. * @property {module:model/Dog} */ Dog: Dog, + /** + * The EnumArrays model constructor. + * @property {module:model/EnumArrays} + */ + EnumArrays: EnumArrays, /** * The EnumClass model constructor. * @property {module:model/EnumClass} @@ -140,6 +150,11 @@ * @property {module:model/HasOnlyReadOnly} */ HasOnlyReadOnly: HasOnlyReadOnly, + /** + * The List model constructor. + * @property {module:model/List} + */ + List: List, /** * The MapTest model constructor. * @property {module:model/MapTest} diff --git a/samples/client/petstore/javascript/src/model/Client.js b/samples/client/petstore/javascript/src/model/Client.js new file mode 100644 index 00000000000..5ecb176007c --- /dev/null +++ b/samples/client/petstore/javascript/src/model/Client.js @@ -0,0 +1,90 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(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.Client = factory(root.SwaggerPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + + + + /** + * The Client model module. + * @module model/Client + * @version 1.0.0 + */ + + /** + * Constructs a new Client. + * @alias module:model/Client + * @class + */ + var exports = function() { + var _this = this; + + + }; + + /** + * Constructs a Client 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/Client} obj Optional instance to populate. + * @return {module:model/Client} The populated Client instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + + if (data.hasOwnProperty('client')) { + obj['client'] = ApiClient.convertToType(data['client'], 'String'); + } + } + return obj; + } + + /** + * @member {String} client + */ + exports.prototype['client'] = undefined; + + + + return exports; +})); + + diff --git a/samples/client/petstore/javascript/src/model/EnumArrays.js b/samples/client/petstore/javascript/src/model/EnumArrays.js new file mode 100644 index 00000000000..adfd91990df --- /dev/null +++ b/samples/client/petstore/javascript/src/model/EnumArrays.js @@ -0,0 +1,132 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(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.EnumArrays = factory(root.SwaggerPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + + + + /** + * The EnumArrays model module. + * @module model/EnumArrays + * @version 1.0.0 + */ + + /** + * Constructs a new EnumArrays. + * @alias module:model/EnumArrays + * @class + */ + var exports = function() { + var _this = this; + + + + }; + + /** + * Constructs a EnumArrays 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/EnumArrays} obj Optional instance to populate. + * @return {module:model/EnumArrays} The populated EnumArrays instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + + if (data.hasOwnProperty('just_symbol')) { + obj['just_symbol'] = ApiClient.convertToType(data['just_symbol'], 'String'); + } + if (data.hasOwnProperty('array_enum')) { + obj['array_enum'] = ApiClient.convertToType(data['array_enum'], ['String']); + } + } + return obj; + } + + /** + * @member {module:model/EnumArrays.JustSymbolEnum} just_symbol + */ + exports.prototype['just_symbol'] = undefined; + /** + * @member {Array.} array_enum + */ + exports.prototype['array_enum'] = undefined; + + + /** + * Allowed values for the just_symbol property. + * @enum {String} + * @readonly + */ + exports.JustSymbolEnum = { + /** + * value: ">=" + * @const + */ + "GREATER_THAN_OR_EQUAL_TO": ">=", + /** + * value: "$" + * @const + */ + "DOLLAR": "$" }; + + /** + * Allowed values for the arrayEnum property. + * @enum {String} + * @readonly + */ + exports.ArrayEnumEnum = { + /** + * value: "fish" + * @const + */ + "fish": "fish", + /** + * value: "crab" + * @const + */ + "crab": "crab" }; + + + return exports; +})); + + diff --git a/samples/client/petstore/javascript/src/model/List.js b/samples/client/petstore/javascript/src/model/List.js new file mode 100644 index 00000000000..7e88e470df8 --- /dev/null +++ b/samples/client/petstore/javascript/src/model/List.js @@ -0,0 +1,90 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(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.List = factory(root.SwaggerPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + + + + /** + * The List model module. + * @module model/List + * @version 1.0.0 + */ + + /** + * Constructs a new List. + * @alias module:model/List + * @class + */ + var exports = function() { + var _this = this; + + + }; + + /** + * Constructs a List 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/List} obj Optional instance to populate. + * @return {module:model/List} The populated List instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + + if (data.hasOwnProperty('123-list')) { + obj['123-list'] = ApiClient.convertToType(data['123-list'], 'String'); + } + } + return obj; + } + + /** + * @member {String} 123-list + */ + exports.prototype['123-list'] = undefined; + + + + return exports; +})); + + diff --git a/samples/client/petstore/javascript/test/model/Client.spec.js b/samples/client/petstore/javascript/test/model/Client.spec.js new file mode 100644 index 00000000000..7bba630a29c --- /dev/null +++ b/samples/client/petstore/javascript/test/model/Client.spec.js @@ -0,0 +1,76 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Client(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Client', function() { + it('should create an instance of Client', function() { + // uncomment below and update the code to test Client + //var instane = new SwaggerPetstore.Client(); + //expect(instance).to.be.a(SwaggerPetstore.Client); + }); + + it('should have the property client (base name: "client")', function() { + // uncomment below and update the code to test the property client + //var instane = new SwaggerPetstore.Client(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/EnumArrays.spec.js b/samples/client/petstore/javascript/test/model/EnumArrays.spec.js new file mode 100644 index 00000000000..2d26fb9920f --- /dev/null +++ b/samples/client/petstore/javascript/test/model/EnumArrays.spec.js @@ -0,0 +1,82 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.EnumArrays(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('EnumArrays', function() { + it('should create an instance of EnumArrays', function() { + // uncomment below and update the code to test EnumArrays + //var instane = new SwaggerPetstore.EnumArrays(); + //expect(instance).to.be.a(SwaggerPetstore.EnumArrays); + }); + + it('should have the property justSymbol (base name: "just_symbol")', function() { + // uncomment below and update the code to test the property justSymbol + //var instane = new SwaggerPetstore.EnumArrays(); + //expect(instance).to.be(); + }); + + it('should have the property arrayEnum (base name: "array_enum")', function() { + // uncomment below and update the code to test the property arrayEnum + //var instane = new SwaggerPetstore.EnumArrays(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/List.spec.js b/samples/client/petstore/javascript/test/model/List.spec.js new file mode 100644 index 00000000000..e73583f9ebc --- /dev/null +++ b/samples/client/petstore/javascript/test/model/List.spec.js @@ -0,0 +1,76 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.List(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('List', function() { + it('should create an instance of List', function() { + // uncomment below and update the code to test List + //var instane = new SwaggerPetstore.List(); + //expect(instance).to.be.a(SwaggerPetstore.List); + }); + + it('should have the property _123List (base name: "123-list")', function() { + // uncomment below and update the code to test the property _123List + //var instane = new SwaggerPetstore.List(); + //expect(instance).to.be(); + }); + + }); + +}));