diff --git a/README.md b/README.md index 98b69dee3c9..df4ff516334 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes If you're looking for the latest stable version, you can grab it directly from maven central (you'll need java 7 runtime at a minimum): ``` -wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.1.5/swagger-codegen-cli-2.1.5.jar -o swagger-codegen-cli.jar +wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.1.5/swagger-codegen-cli-2.1.5.jar -O swagger-codegen-cli.jar java -jar swagger-codegen-cli.jar help ``` diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java index c034e61f1e8..6fd620fc7f7 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java @@ -7,6 +7,7 @@ import java.util.*; public class CodegenModel { public String parent, parentSchema; public String name, classname, description, classVarName, modelJson, dataType; + public String classFilename; // store the class file name, mainly used for import public String unescapedDescription; public String discriminator; public String defaultValue; 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 97fd7f08283..d74f766160d 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 @@ -877,6 +877,7 @@ public class DefaultCodegen { m.unescapedDescription = model.getDescription(); m.classname = toModelName(name); m.classVarName = toVarName(name); + m.classFilename = toModelFilename(name); m.modelJson = Json.pretty(model); m.externalDocs = model.getExternalDocs(); m.vendorExtensions = model.getVendorExtensions(); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index 965291cd326..c966cf6ba66 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -754,7 +754,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { CodegenModel cm = config.fromModel(key, mm, allDefinitions); Map mo = new HashMap(); mo.put("model", cm); - mo.put("importPath", config.toModelImport(key)); + mo.put("importPath", config.toModelImport(cm.classname)); models.add(mo); allImports.addAll(cm.imports); 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 5bc69ad75cd..c51a16069bd 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 @@ -157,6 +157,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo typeMapping.put("number", "Number"); typeMapping.put("DateTime", "Date"); typeMapping.put("Date", "Date"); + typeMapping.put("file", "File"); // binary not supported in JavaScript client right now, using String as a workaround typeMapping.put("binary", "String"); @@ -293,6 +294,14 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo public String toModelName(String name) { name = sanitizeName(name); // FIXME parameter should not be assigned. Also declare it as "final" + if (!StringUtils.isEmpty(modelNamePrefix)) { + name = modelNamePrefix + "_" + name; + } + + if (!StringUtils.isEmpty(modelNameSuffix)) { + name = name + "_" + modelNameSuffix; + } + // camelize the model name // phone_number => PhoneNumber name = camelize(name); @@ -315,7 +324,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo @Override public String toModelImport(String name) { - return toModelName(name); + return name; } @Override diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index 09cc9665b02..965297cd4d3 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -101,7 +101,7 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { typeMapping.put("array", "array"); typeMapping.put("list", "array"); typeMapping.put("object", "object"); - typeMapping.put("binary", "ByteArray"); + typeMapping.put("binary", "string"); cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC)); cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC)); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java index 8f375519d68..40de0f9374f 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java @@ -212,8 +212,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig @Override public String toModelName(String name) { - name = sanitizeName(modelNamePrefix + name + modelNameSuffix); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. - + name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. // remove dollar sign name = name.replaceAll("$", ""); @@ -223,6 +222,14 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig name = "object_" + name; // e.g. return => ObjectReturn (after camelize) } + if (!StringUtils.isEmpty(modelNamePrefix)) { + name = modelNamePrefix + "_" + name; + } + + if (!StringUtils.isEmpty(modelNameSuffix)) { + name = name + "_" + modelNameSuffix; + } + // camelize the model name // phone_number => PhoneNumber return camelize(name); @@ -230,6 +237,10 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig @Override public String toModelFilename(String name) { + name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. + // remove dollar sign + name = name.replaceAll("$", ""); + // model name cannot use reserved keyword, e.g. return if (isReservedWord(name)) { LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + underscore(dropDots("object_" + name))); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java index d8469b599ff..e0e9eea1245 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java @@ -462,7 +462,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { @Override public String toModelImport(String name) { - return gemName + "/" + modelPackage() + "/" + toModelFilename(name); + return gemName + "/" + modelPackage() + "/" + underscore(name); } @Override diff --git a/modules/swagger-codegen/src/main/resources/csharp/api_test.mustache b/modules/swagger-codegen/src/main/resources/csharp/api_test.mustache index 2e638711b0f..d44ebca31b5 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/api_test.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/api_test.mustache @@ -14,6 +14,13 @@ using {{packageName}}.Api; namespace {{packageName}}.Test { + /// + /// Class for testing {{classname}} + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the API endpoint. + /// [TestFixture] public class {{classname}}Tests { diff --git a/modules/swagger-codegen/src/main/resources/csharp/model_test.mustache b/modules/swagger-codegen/src/main/resources/csharp/model_test.mustache index 5b70f3ebf80..c2e8d948050 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/model_test.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/model_test.mustache @@ -13,6 +13,13 @@ using System.Reflection; {{#model}} namespace {{packageName}}.Test { + /// + /// Class for testing {{classname}} + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// [TestFixture] public class {{classname}}Tests { diff --git a/modules/swagger-codegen/src/main/resources/perl/api_test.mustache b/modules/swagger-codegen/src/main/resources/perl/api_test.mustache index 2bab3f8aa86..98d1e9cce99 100644 --- a/modules/swagger-codegen/src/main/resources/perl/api_test.mustache +++ b/modules/swagger-codegen/src/main/resources/perl/api_test.mustache @@ -14,8 +14,8 @@ # limitations under the License. # # -# NOTE: This class is auto generated by the swagger code generator program. -# Do not edit the class manually. +# NOTE: This class is auto generated by Swagger Codegen +# Please update the test case below to test the API endpoints. # use Test::More tests => 1; #TODO update number of test cases use Test::Exception; diff --git a/modules/swagger-codegen/src/main/resources/perl/object_test.mustache b/modules/swagger-codegen/src/main/resources/perl/object_test.mustache index acefaf569d6..dd76f9ac2d7 100644 --- a/modules/swagger-codegen/src/main/resources/perl/object_test.mustache +++ b/modules/swagger-codegen/src/main/resources/perl/object_test.mustache @@ -1,3 +1,6 @@ +# NOTE: This class is auto generated by the Swagger Codegen +# Please update the test case below to test the model. + use Test::More tests => 2; use Test::Exception; diff --git a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache index a0a0b8fcf59..891149d8f55 100644 --- a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache @@ -230,7 +230,7 @@ class ApiClient throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null); } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) { // return raw body if response is a file - if ($responseType == '\SplFileObject' || $responseType == 'ByteArray') { + if ($responseType == '\SplFileObject' || $responseType == 'string') { return array($http_body, $response_info['http_code'], $http_header); } diff --git a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache index f961f5cd60c..39241038a6a 100644 --- a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache @@ -241,8 +241,6 @@ class ObjectSerializer $values[] = self::deserialize($value, $subClass); } $deserialized = $values; - } elseif ($class === 'ByteArray') { // byte array - $deserialized = unpack('C*', (string)$data); } elseif ($class === '\DateTime') { $deserialized = new \DateTime($data); } elseif (in_array($class, array({{&primitives}}))) { diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index d21301ee387..1740a380102 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -188,7 +188,7 @@ use \{{invokerPackage}}\ObjectSerializer; {{#bodyParams}}// body params $_tempBody = null; if (isset(${{paramName}})) { - {{^isBinary}}$_tempBody = ${{paramName}};{{/isBinary}}{{#isBinary}}$_tempBody = call_user_func_array('pack', array_merge(array('C*'), ${{paramName}}));{{/isBinary}} + $_tempBody = ${{paramName}}; }{{/bodyParams}} // for model (json/xml) diff --git a/modules/swagger-codegen/src/main/resources/php/api_test.mustache b/modules/swagger-codegen/src/main/resources/php/api_test.mustache index ee26ec31ff2..fc07d338301 100644 --- a/modules/swagger-codegen/src/main/resources/php/api_test.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api_test.mustache @@ -28,7 +28,7 @@ /** * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. + * Please update the test case below to test the endpoint. */ namespace {{apiPackage}}; diff --git a/modules/swagger-codegen/src/main/resources/php/model_test.mustache b/modules/swagger-codegen/src/main/resources/php/model_test.mustache index 086db341a32..0d615eca102 100644 --- a/modules/swagger-codegen/src/main/resources/php/model_test.mustache +++ b/modules/swagger-codegen/src/main/resources/php/model_test.mustache @@ -30,7 +30,7 @@ /** * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. + * Please update the test case below to test the model. */ namespace {{modelPackage}}; diff --git a/modules/swagger-codegen/src/main/resources/python/__init__model.mustache b/modules/swagger-codegen/src/main/resources/python/__init__model.mustache index 734e0692350..da086c10873 100644 --- a/modules/swagger-codegen/src/main/resources/python/__init__model.mustache +++ b/modules/swagger-codegen/src/main/resources/python/__init__model.mustache @@ -1,5 +1,5 @@ from __future__ import absolute_import # import models into model package -{{#models}}{{#model}}from .{{classVarName}} import {{classname}}{{/model}} +{{#models}}{{#model}}from .{{classFilename}} import {{classname}}{{/model}} {{/models}} diff --git a/modules/swagger-codegen/src/main/resources/python/__init__package.mustache b/modules/swagger-codegen/src/main/resources/python/__init__package.mustache index 76b4fcedd45..5265587cfd9 100644 --- a/modules/swagger-codegen/src/main/resources/python/__init__package.mustache +++ b/modules/swagger-codegen/src/main/resources/python/__init__package.mustache @@ -1,7 +1,7 @@ from __future__ import absolute_import # import models into sdk package -{{#models}}{{#model}}from .models.{{classVarName}} import {{classname}} +{{#models}}{{#model}}from .models.{{classFilename}} import {{classname}} {{/model}}{{/models}} # import apis into sdk package {{#apiInfo}}{{#apis}}from .apis.{{classVarName}} import {{classname}} diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore.json b/modules/swagger-codegen/src/test/resources/2_0/petstore.json index 3f5687ead8a..d4f14e7061a 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore.json +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore.json @@ -1251,6 +1251,28 @@ "xml": { "name": "Order" } + }, + "$special[model.name]": { + "properties": { + "$special[property.name]": { + "type": "integer", + "format": "int64" + } + }, + "xml": { + "name": "$special[model.name]" + } + }, + "Return": { + "properties": { + "return": { + "type": "integer", + "format": "int32" + } + }, + "xml": { + "name": "Return" + } } } } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/CategoryTests.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/CategoryTests.cs index 6384ee4179b..e0216f3fb0f 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/CategoryTests.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/CategoryTests.cs @@ -11,6 +11,13 @@ using System.Reflection; namespace IO.Swagger.Test { + /// + /// Class for testing Category + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// [TestFixture] public class CategoryTests { diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/OrderTests.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/OrderTests.cs index 7d0bc854cef..b9540112766 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/OrderTests.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/OrderTests.cs @@ -11,6 +11,13 @@ using System.Reflection; namespace IO.Swagger.Test { + /// + /// Class for testing Order + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// [TestFixture] public class OrderTests { diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/PetApiTests.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/PetApiTests.cs index 7e3566eb04b..77100e04b61 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/PetApiTests.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/PetApiTests.cs @@ -13,6 +13,13 @@ using IO.Swagger.Model; namespace IO.Swagger.Test { + /// + /// Class for testing PetApi + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the API endpoint. + /// [TestFixture] public class PetApiTests { @@ -155,6 +162,19 @@ namespace IO.Swagger.Test } + /// + /// Test GetPetByIdInObject + /// + [Test] + public void GetPetByIdInObjectTest() + { + // TODO: add unit test for the method 'GetPetByIdInObject' + long? petId = null; // TODO: replace null with proper value + + var response = instance.GetPetByIdInObject(petId); + Assert.IsInstanceOf (response, "response is InlineResponse200"); + } + /// /// Test PetPetIdtestingByteArraytrueGet /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/PetTests.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/PetTests.cs index 6b203dbd125..ebbf7476264 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/PetTests.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/PetTests.cs @@ -11,6 +11,13 @@ using System.Reflection; namespace IO.Swagger.Test { + /// + /// Class for testing Pet + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// [TestFixture] public class PetTests { diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/StoreApiTests.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/StoreApiTests.cs index b0eb6293380..0b9acfec5e9 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/StoreApiTests.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/StoreApiTests.cs @@ -13,6 +13,13 @@ using IO.Swagger.Model; namespace IO.Swagger.Test { + /// + /// Class for testing StoreApi + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the API endpoint. + /// [TestFixture] public class StoreApiTests { @@ -71,6 +78,18 @@ namespace IO.Swagger.Test Assert.IsInstanceOf> (response, "response is Dictionary"); } + /// + /// Test GetInventoryInObject + /// + [Test] + public void GetInventoryInObjectTest() + { + // TODO: add unit test for the method 'GetInventoryInObject' + + var response = instance.GetInventoryInObject(); + Assert.IsInstanceOf (response, "response is Object"); + } + /// /// Test PlaceOrder /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/TagTests.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/TagTests.cs index ad772584cc5..36ca5b5c0c9 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/TagTests.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/TagTests.cs @@ -11,6 +11,13 @@ using System.Reflection; namespace IO.Swagger.Test { + /// + /// Class for testing Tag + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// [TestFixture] public class TagTests { diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/UserApiTests.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/UserApiTests.cs index 0d543c384aa..8764a7773e7 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/UserApiTests.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/UserApiTests.cs @@ -13,6 +13,13 @@ using IO.Swagger.Model; namespace IO.Swagger.Test { + /// + /// Class for testing UserApi + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the API endpoint. + /// [TestFixture] public class UserApiTests { diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/UserTests.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/UserTests.cs index 4610313b734..645a4a9c69c 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/UserTests.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/UserTests.cs @@ -11,6 +11,13 @@ using System.Reflection; namespace IO.Swagger.Test { + /// + /// Class for testing User + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// [TestFixture] public class UserTests { diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs index 9ce0941740e..c1bb30d00c3 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs @@ -203,6 +203,28 @@ namespace IO.Swagger.Api /// ApiResponse of Object(void) ApiResponse UploadFileWithHttpInfo (long? petId, string additionalMetadata = null, Stream file = null); + /// + /// Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + /// + /// + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be fetched + /// InlineResponse200 + InlineResponse200 GetPetByIdInObject (long? petId); + + /// + /// Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + /// + /// + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be fetched + /// ApiResponse of InlineResponse200 + ApiResponse GetPetByIdInObjectWithHttpInfo (long? petId); + /// /// Fake endpoint to test byte array return by 'Find pet by ID' /// @@ -437,6 +459,28 @@ namespace IO.Swagger.Api /// Task of ApiResponse System.Threading.Tasks.Task> UploadFileAsyncWithHttpInfo (long? petId, string additionalMetadata = null, Stream file = null); + /// + /// Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + /// + /// + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be fetched + /// Task of InlineResponse200 + System.Threading.Tasks.Task GetPetByIdInObjectAsync (long? petId); + + /// + /// Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + /// + /// + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be fetched + /// Task of ApiResponse (InlineResponse200) + System.Threading.Tasks.Task> GetPetByIdInObjectAsyncWithHttpInfo (long? petId); + /// /// Fake endpoint to test byte array return by 'Find pet by ID' /// @@ -1978,6 +2022,192 @@ namespace IO.Swagger.Api null); } + /// + /// Fake endpoint to test inline arbitrary object return by 'Find pet by ID' Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be fetched + /// InlineResponse200 + public InlineResponse200 GetPetByIdInObject (long? petId) + { + ApiResponse localVarResponse = GetPetByIdInObjectWithHttpInfo(petId); + return localVarResponse.Data; + } + + /// + /// Fake endpoint to test inline arbitrary object return by 'Find pet by ID' Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be fetched + /// ApiResponse of InlineResponse200 + public ApiResponse< InlineResponse200 > GetPetByIdInObjectWithHttpInfo (long? petId) + { + + // verify the required parameter 'petId' is set + if (petId == null) + throw new ApiException(400, "Missing required parameter 'petId' when calling PetApi->GetPetByIdInObject"); + + + var localVarPath = "/pet/{petId}?response=inline_arbitrary_object"; + + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new Dictionary(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/json", "application/xml" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + // set "format" to json by default + // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json + localVarPathParams.Add("format", "json"); + if (petId != null) localVarPathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter + + + + + + + // authentication (api_key) required + + if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key"))) + { + localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key"); + } + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (localVarStatusCode >= 400) + throw new ApiException (localVarStatusCode, "Error calling GetPetByIdInObject: " + localVarResponse.Content, localVarResponse.Content); + else if (localVarStatusCode == 0) + throw new ApiException (localVarStatusCode, "Error calling GetPetByIdInObject: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage); + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (InlineResponse200) Configuration.ApiClient.Deserialize(localVarResponse, typeof(InlineResponse200))); + + } + + + /// + /// Fake endpoint to test inline arbitrary object return by 'Find pet by ID' Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be fetched + /// Task of InlineResponse200 + public async System.Threading.Tasks.Task GetPetByIdInObjectAsync (long? petId) + { + ApiResponse localVarResponse = await GetPetByIdInObjectAsyncWithHttpInfo(petId); + return localVarResponse.Data; + + } + + /// + /// Fake endpoint to test inline arbitrary object return by 'Find pet by ID' Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be fetched + /// Task of ApiResponse (InlineResponse200) + public async System.Threading.Tasks.Task> GetPetByIdInObjectAsyncWithHttpInfo (long? petId) + { + // verify the required parameter 'petId' is set + if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling GetPetByIdInObject"); + + + var localVarPath = "/pet/{petId}?response=inline_arbitrary_object"; + + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new Dictionary(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/json", "application/xml" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + // set "format" to json by default + // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json + localVarPathParams.Add("format", "json"); + if (petId != null) localVarPathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter + + + + + + + + // authentication (api_key) required + + if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key"))) + { + localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key"); + } + + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath, + Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (localVarStatusCode >= 400) + throw new ApiException (localVarStatusCode, "Error calling GetPetByIdInObject: " + localVarResponse.Content, localVarResponse.Content); + else if (localVarStatusCode == 0) + throw new ApiException (localVarStatusCode, "Error calling GetPetByIdInObject: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage); + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (InlineResponse200) Configuration.ApiClient.Deserialize(localVarResponse, typeof(InlineResponse200))); + + } + /// /// Fake endpoint to test byte array return by 'Find pet by ID' Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs index ca6fa9529d1..868dfdae408 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs @@ -59,6 +59,26 @@ namespace IO.Swagger.Api /// ApiResponse of Dictionary<string, int?> ApiResponse> GetInventoryWithHttpInfo (); + /// + /// Fake endpoint to test arbitrary object return by 'Get inventory' + /// + /// + /// Returns an arbitrary object which is actually a map of status codes to quantities + /// + /// Thrown when fails to make API call + /// Object + Object GetInventoryInObject (); + + /// + /// Fake endpoint to test arbitrary object return by 'Get inventory' + /// + /// + /// Returns an arbitrary object which is actually a map of status codes to quantities + /// + /// Thrown when fails to make API call + /// ApiResponse of Object + ApiResponse GetInventoryInObjectWithHttpInfo (); + /// /// Place an order for a pet /// @@ -171,6 +191,26 @@ namespace IO.Swagger.Api /// Task of ApiResponse (Dictionary<string, int?>) System.Threading.Tasks.Task>> GetInventoryAsyncWithHttpInfo (); + /// + /// Fake endpoint to test arbitrary object return by 'Get inventory' + /// + /// + /// Returns an arbitrary object which is actually a map of status codes to quantities + /// + /// Thrown when fails to make API call + /// Task of Object + System.Threading.Tasks.Task GetInventoryInObjectAsync (); + + /// + /// Fake endpoint to test arbitrary object return by 'Get inventory' + /// + /// + /// Returns an arbitrary object which is actually a map of status codes to quantities + /// + /// Thrown when fails to make API call + /// Task of ApiResponse (Object) + System.Threading.Tasks.Task> GetInventoryInObjectAsyncWithHttpInfo (); + /// /// Place an order for a pet /// @@ -654,6 +694,165 @@ namespace IO.Swagger.Api } + /// + /// Fake endpoint to test arbitrary object return by 'Get inventory' Returns an arbitrary object which is actually a map of status codes to quantities + /// + /// Thrown when fails to make API call + /// Object + public Object GetInventoryInObject () + { + ApiResponse localVarResponse = GetInventoryInObjectWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Fake endpoint to test arbitrary object return by 'Get inventory' Returns an arbitrary object which is actually a map of status codes to quantities + /// + /// Thrown when fails to make API call + /// ApiResponse of Object + public ApiResponse< Object > GetInventoryInObjectWithHttpInfo () + { + + + var localVarPath = "/store/inventory?response=arbitrary_object"; + + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new Dictionary(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/json", "application/xml" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + // set "format" to json by default + // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json + localVarPathParams.Add("format", "json"); + + + + + + + // authentication (api_key) required + + if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key"))) + { + localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key"); + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (localVarStatusCode >= 400) + throw new ApiException (localVarStatusCode, "Error calling GetInventoryInObject: " + localVarResponse.Content, localVarResponse.Content); + else if (localVarStatusCode == 0) + throw new ApiException (localVarStatusCode, "Error calling GetInventoryInObject: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage); + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (Object) Configuration.ApiClient.Deserialize(localVarResponse, typeof(Object))); + + } + + + /// + /// Fake endpoint to test arbitrary object return by 'Get inventory' Returns an arbitrary object which is actually a map of status codes to quantities + /// + /// Thrown when fails to make API call + /// Task of Object + public async System.Threading.Tasks.Task GetInventoryInObjectAsync () + { + ApiResponse localVarResponse = await GetInventoryInObjectAsyncWithHttpInfo(); + return localVarResponse.Data; + + } + + /// + /// Fake endpoint to test arbitrary object return by 'Get inventory' Returns an arbitrary object which is actually a map of status codes to quantities + /// + /// Thrown when fails to make API call + /// Task of ApiResponse (Object) + public async System.Threading.Tasks.Task> GetInventoryInObjectAsyncWithHttpInfo () + { + + + var localVarPath = "/store/inventory?response=arbitrary_object"; + + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new Dictionary(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "application/json", "application/xml" + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + // set "format" to json by default + // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json + localVarPathParams.Add("format", "json"); + + + + + + + + // authentication (api_key) required + + if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key"))) + { + localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key"); + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath, + Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (localVarStatusCode >= 400) + throw new ApiException (localVarStatusCode, "Error calling GetInventoryInObject: " + localVarResponse.Content, localVarResponse.Content); + else if (localVarStatusCode == 0) + throw new ApiException (localVarStatusCode, "Error calling GetInventoryInObject: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage); + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (Object) Configuration.ApiClient.Deserialize(localVarResponse, typeof(Object))); + + } + /// /// Place an order for a pet /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/InlineResponse200.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/InlineResponse200.cs new file mode 100644 index 00000000000..0d5c695c5a0 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/InlineResponse200.cs @@ -0,0 +1,157 @@ +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace IO.Swagger.Model +{ + + /// + /// + /// + [DataContract] + public partial class InlineResponse200 : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + /// Id (required). + /// Category. + /// Name. + + public InlineResponse200(long? Id = null, Object Category = null, string Name = null) + { + // to ensure "Id" is required (not null) + if (Id == null) + { + throw new InvalidDataException("Id is a required property for InlineResponse200 and cannot be null"); + } + else + { + this.Id = Id; + } + this.Category = Category; + this.Name = Name; + + } + + + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=false)] + public long? Id { get; set; } + + + /// + /// Gets or Sets Category + /// + [DataMember(Name="category", EmitDefaultValue=false)] + public Object Category { get; set; } + + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class InlineResponse200 {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Category: ").Append(Category).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + // credit: http://stackoverflow.com/a/10454552/677735 + return this.Equals(obj as InlineResponse200); + } + + /// + /// Returns true if InlineResponse200 instances are equal + /// + /// Instance of InlineResponse200 to be compared + /// Boolean + public bool Equals(InlineResponse200 other) + { + // credit: http://stackoverflow.com/a/10454552/677735 + if (other == null) + return false; + + return + ( + this.Id == other.Id || + this.Id != null && + this.Id.Equals(other.Id) + ) && + ( + this.Category == other.Category || + this.Category != null && + this.Category.Equals(other.Category) + ) && + ( + this.Name == other.Name || + this.Name != null && + this.Name.Equals(other.Name) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + // credit: http://stackoverflow.com/a/263416/677735 + unchecked // Overflow is fine, just wrap + { + int hash = 41; + // Suitable nullity checks etc, of course :) + + if (this.Id != null) + hash = hash * 59 + this.Id.GetHashCode(); + + if (this.Category != null) + hash = hash * 59 + this.Category.GetHashCode(); + + if (this.Name != null) + hash = hash * 59 + this.Name.GetHashCode(); + + return hash; + } + } + + } +} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj index 0b5c3d9a952..bb10c94d339 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj @@ -59,6 +59,7 @@ + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs index 27cabebb37a..fc69023c5ff 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs @@ -1,9 +1,10 @@ - + - + + diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md index 3db24ccc3d1..aec4a513ef5 100644 --- a/samples/client/petstore/perl/README.md +++ b/samples/client/petstore/perl/README.md @@ -8,7 +8,7 @@ WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore Automatically generated by the Perl Swagger Codegen project: -- Build date: 2016-02-27T21:43:00.005+08:00 +- Build date: 2016-03-03T20:09:18.907+08:00 - Build package: class io.swagger.codegen.languages.PerlClientCodegen - Codegen version: diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/PetApi.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/PetApi.pm index 1ea4bd68af8..ae57afa1ead 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/PetApi.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/PetApi.pm @@ -186,12 +186,12 @@ sub add_pet { # # Finds Pets by status # -# @param ARRAY[string] $status Status values that need to be considered for filter (optional) +# @param ARRAY[string] $status Status values that need to be considered for query (optional) { my $params = { 'status' => { data_type => 'ARRAY[string]', - description => 'Status values that need to be considered for filter', + description => 'Status values that need to be considered for query', required => '0', }, }; @@ -662,6 +662,81 @@ sub upload_file { } +# +# get_pet_by_id_in_object +# +# Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +# +# @param int $pet_id ID of pet that needs to be fetched (required) +{ + my $params = { + 'pet_id' => { + data_type => 'int', + description => 'ID of pet that needs to be fetched', + required => '1', + }, + }; + __PACKAGE__->method_documentation->{ get_pet_by_id_in_object } = { + summary => 'Fake endpoint to test inline arbitrary object return by 'Find pet by ID'', + params => $params, + returns => 'InlineResponse200', + }; +} +# @return InlineResponse200 +# +sub get_pet_by_id_in_object { + my ($self, %args) = @_; + + + # verify the required parameter 'pet_id' is set + unless (exists $args{'pet_id'}) { + croak("Missing the required parameter 'pet_id' when calling get_pet_by_id_in_object"); + } + + + # parse inputs + my $_resource_path = '/pet/{petId}?response=inline_arbitrary_object'; + $_resource_path =~ s/{format}/json/; # default format to json + + my $_method = 'GET'; + my $query_params = {}; + my $header_params = {}; + my $form_params = {}; + + # 'Accept' and 'Content-Type' header + my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); + if ($_header_accept) { + $header_params->{'Accept'} = $_header_accept; + } + $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type(); + + + + # path params + if ( exists $args{'pet_id'}) { + my $_base_variable = "{" . "petId" . "}"; + my $_base_value = $self->{api_client}->to_path_value($args{'pet_id'}); + $_resource_path =~ s/$_base_variable/$_base_value/g; + } + + my $_body_data; + + + # authentication setting, if any + my $auth_settings = [qw(api_key petstore_auth )]; + + # make the API Call + my $response = $self->{api_client}->call_api($_resource_path, $_method, + $query_params, $form_params, + $header_params, $_body_data, $auth_settings); + if (!$response) { + return; + } + my $_response_object = $self->{api_client}->deserialize('InlineResponse200', $response); + return $_response_object; + +} + # # pet_pet_idtesting_byte_arraytrue_get # diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm index 2f7f75a5389..033ba9a0dc5 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm @@ -37,7 +37,7 @@ has version_info => ( is => 'ro', default => sub { { app_name => 'Swagger Petstore', app_version => '1.0.0', - generated_date => '2016-02-27T21:43:00.005+08:00', + generated_date => '2016-03-03T20:09:18.907+08:00', generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen', } }, documentation => 'Information about the application version and the codegen codebase version' @@ -103,7 +103,7 @@ Automatically generated by the Perl Swagger Codegen project: =over 4 -=item Build date: 2016-02-27T21:43:00.005+08:00 +=item Build date: 2016-03-03T20:09:18.907+08:00 =item Build package: class io.swagger.codegen.languages.PerlClientCodegen diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/StoreApi.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/StoreApi.pm index a2c37435ee9..fe001897754 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/StoreApi.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/StoreApi.pm @@ -51,6 +51,74 @@ sub new { } +# +# find_orders_by_status +# +# Finds orders by status +# +# @param string $status Status value that needs to be considered for query (optional) +{ + my $params = { + 'status' => { + data_type => 'string', + description => 'Status value that needs to be considered for query', + required => '0', + }, + }; + __PACKAGE__->method_documentation->{ find_orders_by_status } = { + summary => 'Finds orders by status', + params => $params, + returns => 'ARRAY[Order]', + }; +} +# @return ARRAY[Order] +# +sub find_orders_by_status { + my ($self, %args) = @_; + + + + # parse inputs + my $_resource_path = '/store/findByStatus'; + $_resource_path =~ s/{format}/json/; # default format to json + + my $_method = 'GET'; + my $query_params = {}; + my $header_params = {}; + my $form_params = {}; + + # 'Accept' and 'Content-Type' header + my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); + if ($_header_accept) { + $header_params->{'Accept'} = $_header_accept; + } + $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type(); + + # query params + if ( exists $args{'status'}) { + $query_params->{'status'} = $self->{api_client}->to_query_value($args{'status'}); + } + + + + my $_body_data; + + + # authentication setting, if any + my $auth_settings = [qw(test_api_client_id test_api_client_secret )]; + + # make the API Call + my $response = $self->{api_client}->call_api($_resource_path, $_method, + $query_params, $form_params, + $header_params, $_body_data, $auth_settings); + if (!$response) { + return; + } + my $_response_object = $self->{api_client}->deserialize('ARRAY[Order]', $response); + return $_response_object; + +} + # # get_inventory # @@ -110,6 +178,65 @@ sub get_inventory { } +# +# get_inventory_in_object +# +# Fake endpoint to test arbitrary object return by 'Get inventory' +# +{ + my $params = { + }; + __PACKAGE__->method_documentation->{ get_inventory_in_object } = { + summary => 'Fake endpoint to test arbitrary object return by 'Get inventory'', + params => $params, + returns => 'object', + }; +} +# @return object +# +sub get_inventory_in_object { + my ($self, %args) = @_; + + + + # parse inputs + my $_resource_path = '/store/inventory?response=arbitrary_object'; + $_resource_path =~ s/{format}/json/; # default format to json + + my $_method = 'GET'; + my $query_params = {}; + my $header_params = {}; + my $form_params = {}; + + # 'Accept' and 'Content-Type' header + my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); + if ($_header_accept) { + $header_params->{'Accept'} = $_header_accept; + } + $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type(); + + + + + + my $_body_data; + + + # authentication setting, if any + my $auth_settings = [qw(api_key )]; + + # make the API Call + my $response = $self->{api_client}->call_api($_resource_path, $_method, + $query_params, $form_params, + $header_params, $_body_data, $auth_settings); + if (!$response) { + return; + } + my $_response_object = $self->{api_client}->deserialize('object', $response); + return $_response_object; + +} + # # place_order # diff --git a/samples/client/petstore/perl/t/PetApiTest.t b/samples/client/petstore/perl/t/PetApiTest.t index 58bf2842f24..52211d2e95f 100644 --- a/samples/client/petstore/perl/t/PetApiTest.t +++ b/samples/client/petstore/perl/t/PetApiTest.t @@ -98,6 +98,14 @@ isa_ok($api, 'WWW::SwaggerClient::PetApi'); my $result = $api->upload_file(pet_id => $pet_id, additional_metadata => $additional_metadata, file => $file); } +# +# get_pet_by_id_in_object test +# +{ + my $pet_id = undef; # replace NULL with a proper value + my $result = $api->get_pet_by_id_in_object(pet_id => $pet_id); +} + # # pet_pet_idtesting_byte_arraytrue_get test # diff --git a/samples/client/petstore/perl/t/StoreApiTest.t b/samples/client/petstore/perl/t/StoreApiTest.t index fa41c8e7a87..49257eaf3cd 100644 --- a/samples/client/petstore/perl/t/StoreApiTest.t +++ b/samples/client/petstore/perl/t/StoreApiTest.t @@ -29,6 +29,14 @@ use_ok('WWW::SwaggerClient::StoreApi'); my $api = WWW::SwaggerClient::StoreApi->new(); isa_ok($api, 'WWW::SwaggerClient::StoreApi'); +# +# find_orders_by_status test +# +{ + my $status = undef; # replace NULL with a proper value + my $result = $api->find_orders_by_status(status => $status); +} + # # get_inventory test # @@ -36,6 +44,13 @@ isa_ok($api, 'WWW::SwaggerClient::StoreApi'); my $result = $api->get_inventory(); } +# +# get_inventory_in_object test +# +{ + my $result = $api->get_inventory_in_object(); +} + # # place_order test # diff --git a/samples/client/petstore/perl/tests/04_role.t b/samples/client/petstore/perl/tests/04_role.t index 42abf5b4f41..8836c35546c 100644 --- a/samples/client/petstore/perl/tests/04_role.t +++ b/samples/client/petstore/perl/tests/04_role.t @@ -50,7 +50,7 @@ is $get_pet->tags->[0]->id, '11', 'stored and retrieved: got the proper tag id'; # API method docs is_deeply( [sort keys %{$api->pet_api->method_documentation}], - [ 'add_pet', 'add_pet_using_byte_array', 'delete_pet', 'find_pets_by_status', 'find_pets_by_tags', 'get_pet_by_id', 'pet_pet_idtesting_byte_arraytrue_get', 'update_pet', 'update_pet_with_form', 'upload_file'], + [ 'add_pet', 'add_pet_using_byte_array', 'delete_pet', 'find_pets_by_status', 'find_pets_by_tags', 'get_pet_by_id', 'get_pet_by_id_in_object', 'pet_pet_idtesting_byte_arraytrue_get', 'update_pet', 'update_pet_with_form', 'upload_file'], "Pet API method_documentation has the correct keys"); is $api->pet_api->method_documentation->{get_pet_by_id}->{params}->{pet_id}->{description}, 'ID of pet that needs to be fetched', 'get_pet_by_id parameter pet_id description is correct'; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php index c83eec73104..f17476385cb 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -878,13 +878,120 @@ class PetApi } } + /** + * getPetByIdInObject + * + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + * + * @param int $pet_id ID of pet that needs to be fetched (required) + * @return \Swagger\Client\Model\InlineResponse200 + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function getPetByIdInObject($pet_id) + { + list($response, $statusCode, $httpHeader) = $this->getPetByIdInObjectWithHttpInfo ($pet_id); + return $response; + } + + + /** + * getPetByIdInObjectWithHttpInfo + * + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + * + * @param int $pet_id ID of pet that needs to be fetched (required) + * @return Array of \Swagger\Client\Model\InlineResponse200, HTTP status code, HTTP response headers (array of strings) + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function getPetByIdInObjectWithHttpInfo($pet_id) + { + + // verify the required parameter 'pet_id' is set + if ($pet_id === null) { + throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling getPetByIdInObject'); + } + + // parse inputs + $resourcePath = "/pet/{petId}?response=inline_arbitrary_object"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + + + + // path params + + if ($pet_id !== null) { + $resourcePath = str_replace( + "{" . "petId" . "}", + $this->apiClient->getSerializer()->toPathValue($pet_id), + $resourcePath + ); + } + // default format to json + $resourcePath = str_replace("{format}", "json", $resourcePath); + + + + + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + + // this endpoint requires API key authentication + $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); + if (strlen($apiKey) !== 0) { + $headerParams['api_key'] = $apiKey; + } + + + // this endpoint requires OAuth (access token) + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } + + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, 'GET', + $queryParams, $httpBody, + $headerParams, '\Swagger\Client\Model\InlineResponse200' + ); + + if (!$response) { + return array(null, $statusCode, $httpHeader); + } + + return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\Swagger\Client\Model\InlineResponse200', $httpHeader), $statusCode, $httpHeader); + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\InlineResponse200', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } + + throw $e; + } + } + /** * petPetIdtestingByteArraytrueGet * * Fake endpoint to test byte array return by 'Find pet by ID' * * @param int $pet_id ID of pet that needs to be fetched (required) - * @return ByteArray + * @return string * @throws \Swagger\Client\ApiException on non-2xx response */ public function petPetIdtestingByteArraytrueGet($pet_id) @@ -900,7 +1007,7 @@ class PetApi * Fake endpoint to test byte array return by 'Find pet by ID' * * @param int $pet_id ID of pet that needs to be fetched (required) - * @return Array of ByteArray, HTTP status code, HTTP response headers (array of strings) + * @return Array of string, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function petPetIdtestingByteArraytrueGetWithHttpInfo($pet_id) @@ -964,19 +1071,19 @@ class PetApi list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, 'GET', $queryParams, $httpBody, - $headerParams, 'ByteArray' + $headerParams, 'string' ); if (!$response) { return array(null, $statusCode, $httpHeader); } - return array(\Swagger\Client\ObjectSerializer::deserialize($response, 'ByteArray', $httpHeader), $statusCode, $httpHeader); + return array(\Swagger\Client\ObjectSerializer::deserialize($response, 'string', $httpHeader), $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), 'ByteArray', $e->getResponseHeaders()); + $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), 'string', $e->getResponseHeaders()); $e->setResponseObject($data); break; } @@ -990,7 +1097,7 @@ class PetApi * * Fake endpoint to test byte array in body parameter for adding a new pet to the store * - * @param ByteArray $body Pet object in the form of byte array (optional) + * @param string $body Pet object in the form of byte array (optional) * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ @@ -1006,7 +1113,7 @@ class PetApi * * Fake endpoint to test byte array in body parameter for adding a new pet to the store * - * @param ByteArray $body Pet object in the form of byte array (optional) + * @param string $body Pet object in the form of byte array (optional) * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ @@ -1036,7 +1143,7 @@ class PetApi // body params $_tempBody = null; if (isset($body)) { - $_tempBody = call_user_func_array('pack', array_merge(array('C*'), $body)); + $_tempBody = $body; } // for model (json/xml) diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php index 7945d21be76..5e9705df3e3 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -280,6 +280,94 @@ class StoreApi } } + /** + * getInventoryInObject + * + * Fake endpoint to test arbitrary object return by 'Get inventory' + * + * @return object + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function getInventoryInObject() + { + list($response, $statusCode, $httpHeader) = $this->getInventoryInObjectWithHttpInfo (); + return $response; + } + + + /** + * getInventoryInObjectWithHttpInfo + * + * Fake endpoint to test arbitrary object return by 'Get inventory' + * + * @return Array of object, HTTP status code, HTTP response headers (array of strings) + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function getInventoryInObjectWithHttpInfo() + { + + + // parse inputs + $resourcePath = "/store/inventory?response=arbitrary_object"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + + + + + // default format to json + $resourcePath = str_replace("{format}", "json", $resourcePath); + + + + + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + + // this endpoint requires API key authentication + $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); + if (strlen($apiKey) !== 0) { + $headerParams['api_key'] = $apiKey; + } + + + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, 'GET', + $queryParams, $httpBody, + $headerParams, 'object' + ); + + if (!$response) { + return array(null, $statusCode, $httpHeader); + } + + return array(\Swagger\Client\ObjectSerializer::deserialize($response, 'object', $httpHeader), $statusCode, $httpHeader); + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), 'object', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } + + throw $e; + } + } + /** * placeOrder * diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php b/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php index 8313dc52004..df38b989f88 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php @@ -230,7 +230,7 @@ class ApiClient throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null); } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) { // return raw body if response is a file - if ($responseType == '\SplFileObject' || $responseType == 'ByteArray') { + if ($responseType == '\SplFileObject' || $responseType == 'string') { return array($http_body, $response_info['http_code'], $http_header); } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index 7b3509b5856..8b95811e990 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -241,8 +241,6 @@ class ObjectSerializer $values[] = self::deserialize($value, $subClass); } $deserialized = $values; - } elseif ($class === 'ByteArray') { // byte array - $deserialized = unpack('C*', (string)$data); } elseif ($class === '\DateTime') { $deserialized = new \DateTime($data); } elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) { diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/CategoryTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/CategoryTest.php index c6eaa55d0a5..26214963d3f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/CategoryTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/CategoryTest.php @@ -28,7 +28,7 @@ /** * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. + * Please update the test case below to test the model. */ namespace Swagger\Client\Model; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/OrderTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/OrderTest.php index fa036c10ef1..abfbe53d48f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/OrderTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/OrderTest.php @@ -28,7 +28,7 @@ /** * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. + * Please update the test case below to test the model. */ namespace Swagger\Client\Model; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/PetApiTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/PetApiTest.php index 0505fde1c57..75751960cb1 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/PetApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/PetApiTest.php @@ -28,7 +28,7 @@ /** * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. + * Please update the test case below to test the endpoint. */ namespace Swagger\Client\Api; @@ -145,6 +145,16 @@ class PetApiTest extends \PHPUnit_Framework_TestCase } + /** + * Test case for getPetByIdInObject + * + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + * + */ + public function test_getPetByIdInObject() { + + } + /** * Test case for petPetIdtestingByteArraytrueGet * diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/PetTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/PetTest.php index bcfc9b85ad6..571e17f56cb 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/PetTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/PetTest.php @@ -28,7 +28,7 @@ /** * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. + * Please update the test case below to test the model. */ namespace Swagger\Client\Model; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/StoreApiTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/StoreApiTest.php index 8ccedf892a0..6dd3f3ad6c2 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/StoreApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/StoreApiTest.php @@ -28,7 +28,7 @@ /** * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. + * Please update the test case below to test the endpoint. */ namespace Swagger\Client\Api; @@ -85,6 +85,16 @@ class StoreApiTest extends \PHPUnit_Framework_TestCase } + /** + * Test case for getInventoryInObject + * + * Fake endpoint to test arbitrary object return by 'Get inventory' + * + */ + public function test_getInventoryInObject() { + + } + /** * Test case for placeOrder * diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/TagTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/TagTest.php index 726dacbd126..34536dc0d4c 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/TagTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/TagTest.php @@ -28,7 +28,7 @@ /** * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. + * Please update the test case below to test the model. */ namespace Swagger\Client\Model; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/UserApiTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/UserApiTest.php index 500b99c4c4f..e991106ee84 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/UserApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/UserApiTest.php @@ -28,7 +28,7 @@ /** * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. + * Please update the test case below to test the endpoint. */ namespace Swagger\Client\Api; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/UserTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/UserTest.php index 635a91e704e..ffde69ecf2f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/UserTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/UserTest.php @@ -28,7 +28,7 @@ /** * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. + * Please update the test case below to test the model. */ namespace Swagger\Client\Model; diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php index 44d90936368..96ceaf98015 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php @@ -279,7 +279,7 @@ class PetApiTest extends \PHPUnit_Framework_TestCase // add a new pet (model) $object_serializer = new Swagger\Client\ObjectSerializer(); $pet_json_string = json_encode($object_serializer->sanitizeForSerialization($new_pet)); - $add_response = $pet_api->addPetUsingByteArray(unpack('C*', $pet_json_string)); + $add_response = $pet_api->addPetUsingByteArray($pet_json_string); // return nothing (void) $this->assertSame($add_response, NULL); // verify added Pet @@ -330,9 +330,9 @@ class PetApiTest extends \PHPUnit_Framework_TestCase // test getPetByIdWithByteArray $pet_id = 10005; $bytes = $pet_api->petPetIdtestingByteArraytrueGet($pet_id); - $json = json_decode(call_user_func_array('pack', array_merge(array('C*'), $bytes )), true); + $json = json_decode($bytes, true); - $this->assertInternalType("array", $bytes); + $this->assertInternalType("string", $bytes); $this->assertSame($json['id'], $pet_id); // not testing name as it's tested by addPetUsingByteArray diff --git a/samples/client/petstore/python/swagger_client/__init__.py b/samples/client/petstore/python/swagger_client/__init__.py index f61c5d55262..8c6fd5bc618 100644 --- a/samples/client/petstore/python/swagger_client/__init__.py +++ b/samples/client/petstore/python/swagger_client/__init__.py @@ -5,7 +5,10 @@ from .models.user import User from .models.category import Category from .models.pet import Pet from .models.tag import Tag +from .models.object_return import ObjectReturn from .models.order import Order +from .models.special_model_name import SpecialModelName +from .models.inline_response_200 import InlineResponse200 # import apis into sdk package from .apis.user_api import UserApi diff --git a/samples/client/petstore/python/swagger_client/apis/pet_api.py b/samples/client/petstore/python/swagger_client/apis/pet_api.py index 5f14852ba77..d4291093b13 100644 --- a/samples/client/petstore/python/swagger_client/apis/pet_api.py +++ b/samples/client/petstore/python/swagger_client/apis/pet_api.py @@ -664,6 +664,83 @@ class PetApi(object): callback=params.get('callback')) return response + def get_pet_by_id_in_object(self, pet_id, **kwargs): + """ + Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.get_pet_by_id_in_object(pet_id, callback=callback_function) + + :param callback function: The callback function + for asynchronous request. (optional) + :param int pet_id: ID of pet that needs to be fetched (required) + :return: InlineResponse200 + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['pet_id'] + all_params.append('callback') + + params = locals() + for key, val in iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_pet_by_id_in_object" % key + ) + params[key] = val + del params['kwargs'] + + # verify the required parameter 'pet_id' is set + if ('pet_id' not in params) or (params['pet_id'] is None): + raise ValueError("Missing the required parameter `pet_id` when calling `get_pet_by_id_in_object`") + + resource_path = '/pet/{petId}?response=inline_arbitrary_object'.replace('{format}', 'json') + path_params = {} + if 'pet_id' in params: + path_params['petId'] = params['pet_id'] + + query_params = {} + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + + # HTTP header `Accept` + header_params['Accept'] = self.api_client.\ + select_header_accept(['application/json', 'application/xml']) + if not header_params['Accept']: + del header_params['Accept'] + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.\ + select_header_content_type([]) + + # Authentication setting + auth_settings = ['api_key', 'petstore_auth'] + + response = self.api_client.call_api(resource_path, 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='InlineResponse200', + auth_settings=auth_settings, + callback=params.get('callback')) + return response + def pet_pet_idtesting_byte_arraytrue_get(self, pet_id, **kwargs): """ Fake endpoint to test byte array return by 'Find pet by ID' diff --git a/samples/client/petstore/python/swagger_client/apis/store_api.py b/samples/client/petstore/python/swagger_client/apis/store_api.py index ce524916aa4..220447d7c01 100644 --- a/samples/client/petstore/python/swagger_client/apis/store_api.py +++ b/samples/client/petstore/python/swagger_client/apis/store_api.py @@ -190,6 +190,77 @@ class StoreApi(object): callback=params.get('callback')) return response + def get_inventory_in_object(self, **kwargs): + """ + Fake endpoint to test arbitrary object return by 'Get inventory' + Returns an arbitrary object which is actually a map of status codes to quantities + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.get_inventory_in_object(callback=callback_function) + + :param callback function: The callback function + for asynchronous request. (optional) + :return: object + If the method is called asynchronously, + returns the request thread. + """ + + all_params = [] + all_params.append('callback') + + params = locals() + for key, val in iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_inventory_in_object" % key + ) + params[key] = val + del params['kwargs'] + + + resource_path = '/store/inventory?response=arbitrary_object'.replace('{format}', 'json') + path_params = {} + + query_params = {} + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + + # HTTP header `Accept` + header_params['Accept'] = self.api_client.\ + select_header_accept(['application/json', 'application/xml']) + if not header_params['Accept']: + del header_params['Accept'] + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.\ + select_header_content_type([]) + + # Authentication setting + auth_settings = ['api_key'] + + response = self.api_client.call_api(resource_path, 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='object', + auth_settings=auth_settings, + callback=params.get('callback')) + return response + def place_order(self, **kwargs): """ Place an order for a pet diff --git a/samples/client/petstore/python/swagger_client/models/__init__.py b/samples/client/petstore/python/swagger_client/models/__init__.py index 236f10e934a..399e634fe30 100644 --- a/samples/client/petstore/python/swagger_client/models/__init__.py +++ b/samples/client/petstore/python/swagger_client/models/__init__.py @@ -5,4 +5,7 @@ from .user import User from .category import Category from .pet import Pet from .tag import Tag +from .object_return import ObjectReturn from .order import Order +from .special_model_name import SpecialModelName +from .inline_response_200 import InlineResponse200