diff --git a/.gitignore b/.gitignore index 25bb6c205cb..3c008800db1 100644 --- a/.gitignore +++ b/.gitignore @@ -91,13 +91,19 @@ samples/client/petstore/swift/SwaggerClientTests/Pods/Pods.xcodeproj/xcshareddat samples/client/petstore/csharp/SwaggerClientTest/.vs samples/client/petstore/csharp/SwaggerClientTest/obj samples/client/petstore/csharp/SwaggerClientTest/bin -samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/vendor/ +samples/client/petstore/csharp/SwaggerClientTest/packages samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/ samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/ -samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/nuget.exe samples/client/petstore/csharp/SwaggerClientTest/TestResult.xml samples/client/petstore/csharp/SwaggerClientTest/nuget.exe samples/client/petstore/csharp/SwaggerClientTest/testrunner/ +samples/client/petstore/csharp/SwaggerClient/.vs +samples/client/petstore/csharp/SwaggerClient/nuget.exe +samples/client/petstore/csharp/SwaggerClient/obj +samples/client/petstore/csharp/SwaggerClient/bin +samples/client/petstore/csharp/SwaggerClient/obj/Debug/ +samples/client/petstore/csharp/SwaggerClient/bin/Debug/ +samples/client/petstore/csharp/SwaggerClient/packages # Python *.pyc diff --git a/README.md b/README.md index c1617b9b79e..8eca8ecd53e 100644 --- a/README.md +++ b/README.md @@ -763,6 +763,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you - [Acunetix](https://www.acunetix.com/) - [Atlassian](https://www.atlassian.com/) - [beemo](http://www.beemo.eu) +- [bitly](https://bitly.com) - [Cachet Financial](http://www.cachetfinancial.com/) - [CloudBoost](https://www.CloudBoost.io/) - [Cupix](http://www.cupix.com) diff --git a/bin/csharp-petstore.sh b/bin/csharp-petstore.sh index c042dd9c0cd..a82efa9af10 100755 --- a/bin/csharp-petstore.sh +++ b/bin/csharp-petstore.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l csharp -o samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l csharp -o samples/client/petstore/csharp/SwaggerClient" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/javascript-promise-petstore.sh b/bin/javascript-promise-petstore.sh index f6e7ef13913..fac0f221424 100755 --- a/bin/javascript-promise-petstore.sh +++ b/bin/javascript-promise-petstore.sh @@ -27,7 +27,7 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" ags="$@ generate -t modules/swagger-codegen/src/main/resources/Javascript \ --i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l javascript \ +-i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l javascript \ -o samples/client/petstore/javascript-promise \ --additional-properties usePromises=true" diff --git a/bin/windows/csharp-petstore.bat b/bin/windows/csharp-petstore.bat index 227ed319441..fbfc18d334d 100755 --- a/bin/windows/csharp-petstore.bat +++ b/bin/windows/csharp-petstore.bat @@ -5,6 +5,6 @@ If Not Exist %executable% ( ) set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties -set ags=generate -t modules\swagger-codegen\src\main\resources\csharp -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l csharp -o samples\client\petstore\csharp\SwaggerClientTest\Lib\SwaggerClient +set ags=generate -t modules\swagger-codegen\src\main\resources\csharp -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l csharp -o samples\client\petstore\csharp\SwaggerClient java %JAVA_OPTS% -jar %executable% %ags% diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java index e9d6457f6f0..304b23b3db5 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java @@ -12,7 +12,7 @@ import java.util.*; public abstract class AbstractCSharpCodegen extends DefaultCodegen implements CodegenConfig { protected boolean optionalAssemblyInfoFlag = true; - protected boolean optionalProjectFileFlag = false; + protected boolean optionalProjectFileFlag = true; protected boolean optionalEmitDefaultValue = false; protected boolean optionalMethodArgumentFlag = true; protected boolean useDateTimeOffsetFlag = false; @@ -21,7 +21,12 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co protected String packageVersion = "1.0.0"; protected String packageName = "IO.Swagger"; - protected String sourceFolder = "src" + File.separator + packageName; + + protected String sourceFolder = "src"; + + // TODO: Add option for test folder output location. Nice to allow e.g. ./test instead of ./src. + // This would require updating relative paths (e.g. path to main project file in test project file) + protected String testFolder = sourceFolder; protected Set collectionTypes; protected Set mapTypes; @@ -273,12 +278,12 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co @Override public String apiFileFolder() { - return outputFolder + File.separator + sourceFolder + File.separator + apiPackage().replace('.', File.separatorChar); + return outputFolder + File.separator + sourceFolder + File.separator + packageName + File.separator + apiPackage(); } @Override public String modelFileFolder() { - return outputFolder + File.separator + sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar); + return outputFolder + File.separator + sourceFolder + File.separator + packageName + File.separator + modelPackage(); } @Override @@ -528,7 +533,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co return toModelName(name) + "Tests"; } - public void setPackageName(String packageName) { this.packageName = packageName; } @@ -541,7 +545,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co this.sourceFolder = sourceFolder; } - @Override public String toEnumVarName(String name, String datatype) { String enumName = sanitizeName(name); @@ -590,4 +593,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co } } */ + + public String testPackageName() { + return this.packageName + ".Test"; + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AspNet5ServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AspNet5ServerCodegen.java index cf8915974e6..790891d38bb 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AspNet5ServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AspNet5ServerCodegen.java @@ -11,6 +11,8 @@ import java.util.*; public class AspNet5ServerCodegen extends AbstractCSharpCodegen { + protected String sourceFolder = "src" + File.separator + packageName; + @SuppressWarnings("hiding") protected Logger LOGGER = LoggerFactory.getLogger(AspNet5ServerCodegen.class); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java index 1212795e1bb..c30bae257a1 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java @@ -68,9 +68,6 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { modelDocTemplateFiles.put("model_doc.mustache", ".md"); apiDocTemplateFiles.put("api_doc.mustache", ".md"); - // C# client default - setSourceFolder("src" + File.separator + "main" + File.separator + "csharp"); - cliOptions.clear(); // CLI options @@ -141,9 +138,9 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { public void processOpts() { super.processOpts(); - apiPackage = packageName + ".Api"; - modelPackage = packageName + ".Model"; - clientPackage = packageName + ".Client"; + apiPackage = "Api"; + modelPackage = "Model"; + clientPackage = "Client"; additionalProperties.put("clientPackage", clientPackage); @@ -157,6 +154,10 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { if (additionalProperties.containsKey(CodegenConstants.DOTNET_FRAMEWORK)) { setTargetFramework((String) additionalProperties.get(CodegenConstants.DOTNET_FRAMEWORK)); + } else { + // Ensure default is set. + setTargetFramework(NET45); + additionalProperties.put("targetFramework", this.targetFramework); } if (NET35.equals(this.targetFramework)) { @@ -201,8 +202,12 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { .get(CodegenConstants.OPTIONAL_ASSEMBLY_INFO).toString())); } - String packageFolder = sourceFolder + File.separator + packageName.replace(".", java.io.File.separator); - String clientPackageDir = sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator); + final String testPackageName = testPackageName(); + String packageFolder = sourceFolder + File.separator + packageName; + String clientPackageDir = packageFolder + File.separator + clientPackage; + String testPackageFolder = testFolder + File.separator + testPackageName; + + additionalProperties.put("testPackageName", testPackageName); //Compute the relative path to the bin directory where the external assemblies live //This is necessary to properly generate the project file @@ -210,7 +215,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { String binRelativePath = "..\\"; for (int i = 0; i < packageDepth; i = i + 1) binRelativePath += "..\\"; - binRelativePath += "vendor\\"; + binRelativePath += "vendor"; additionalProperties.put("binRelativePath", binRelativePath); supportingFiles.add(new SupportingFile("Configuration.mustache", @@ -222,9 +227,13 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { supportingFiles.add(new SupportingFile("ApiResponse.mustache", clientPackageDir, "ApiResponse.cs")); - supportingFiles.add(new SupportingFile("compile.mustache", "", "compile.bat")); - supportingFiles.add(new SupportingFile("compile-mono.sh.mustache", "", "compile-mono.sh")); - supportingFiles.add(new SupportingFile("packages.config.mustache", "vendor" + java.io.File.separator, "packages.config")); + supportingFiles.add(new SupportingFile("compile.mustache", "", "build.bat")); + supportingFiles.add(new SupportingFile("compile-mono.sh.mustache", "", "build.sh")); + + // copy package.config to nuget's standard location for project-level installs + supportingFiles.add(new SupportingFile("packages.config.mustache", packageFolder + File.separator, "packages.config")); + supportingFiles.add(new SupportingFile("packages_test.config.mustache", testPackageFolder + File.separator, "packages.config")); + supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); @@ -233,7 +242,14 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { supportingFiles.add(new SupportingFile("AssemblyInfo.mustache", packageFolder + File.separator + "Properties", "AssemblyInfo.cs")); } if (optionalProjectFileFlag) { - supportingFiles.add(new SupportingFile("Project.mustache", packageFolder, clientPackage + ".csproj")); + supportingFiles.add(new SupportingFile("Solution.mustache", "", packageName + ".sln")); + supportingFiles.add(new SupportingFile("Project.mustache", packageFolder, packageName + ".csproj")); + + // TODO: Check if test project output is enabled, partially related to #2506. Should have options for: + // 1) No test project + // 2) No model tests + // 3) No api tests + supportingFiles.add(new SupportingFile("TestProject.mustache", testPackageFolder, testPackageName + ".csproj")); } additionalProperties.put("apiDocPath", apiDocPath); @@ -439,4 +455,13 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar); } + @Override + public String apiTestFileFolder() { + return outputFolder + File.separator + testFolder + File.separator + testPackageName() + File.separator + apiPackage(); + } + + @Override + public String modelTestFileFolder() { + return outputFolder + File.separator + testFolder + File.separator + testPackageName() + File.separator + modelPackage(); + } } 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 feec76d8de2..d654363727c 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 @@ -839,6 +839,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo @SuppressWarnings("unchecked") @Override public Map postProcessModels(Map objs) { + objs = super.postProcessModelsEnum(objs); List models = (List) objs.get("models"); for (Object _mo : models) { Map mo = (Map) _mo; @@ -853,8 +854,6 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo cm.vendorExtensions.put("x-all-required", allRequired); for (CodegenProperty var : cm.vars) { - Map allowableValues = var.allowableValues; - // Add JSDoc @type value for this property. String jsDocType = getJSDocTypeWithBraces(cm, var); var.vendorExtensions.put("x-jsdoc-type", jsDocType); @@ -862,40 +861,6 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo if (Boolean.TRUE.equals(var.required)) { required.add(var.name); } - - // handle ArrayProperty - if (var.items != null) { - allowableValues = var.items.allowableValues; - } - - if (allowableValues == null) { - continue; - } - List values = (List) allowableValues.get("values"); - if (values == null) { - continue; - } - - // put "enumVars" map into `allowableValues", including `name` and `value` - List> enumVars = new ArrayList>(); - String commonPrefix = findCommonPrefixOfVars(values); - int truncateIdx = commonPrefix.length(); - for (Object value : values) { - Map enumVar = new HashMap(); - String enumName; - if (truncateIdx == 0) { - enumName = value.toString(); - } else { - enumName = value.toString().substring(truncateIdx); - if ("".equals(enumName)) { - enumName = value.toString(); - } - } - enumVar.put("name", toEnumVarName(enumName, var.datatype)); - enumVar.put("value",toEnumValue(value.toString(), var.datatype)); - enumVars.add(enumVar); - } - allowableValues.put("enumVars", enumVars); } if (supportsInheritance) { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java index 21e319f6ec9..0ecdfb667c9 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java @@ -223,6 +223,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("JSONResponseSerializer-body.mustache", swaggerFolder, classPrefix + "JSONResponseSerializer.m")); supportingFiles.add(new SupportingFile("JSONRequestSerializer-body.mustache", swaggerFolder, classPrefix + "JSONRequestSerializer.m")); supportingFiles.add(new SupportingFile("JSONRequestSerializer-header.mustache", swaggerFolder, classPrefix + "JSONRequestSerializer.h")); + supportingFiles.add(new SupportingFile("ResponseDeserializer-body.mustache", swaggerFolder, classPrefix + "ResponseDeserializer.m")); + supportingFiles.add(new SupportingFile("ResponseDeserializer-header.mustache", swaggerFolder, classPrefix + "ResponseDeserializer.h")); supportingFiles.add(new SupportingFile("JSONValueTransformer+ISO8601.m", swaggerFolder, "JSONValueTransformer+ISO8601.m")); supportingFiles.add(new SupportingFile("JSONValueTransformer+ISO8601.h", swaggerFolder, "JSONValueTransformer+ISO8601.h")); supportingFiles.add(new SupportingFile("Configuration-body.mustache", swaggerFolder, classPrefix + "Configuration.m")); diff --git a/modules/swagger-codegen/src/main/resources/Java/enum_outer_doc.mustache b/modules/swagger-codegen/src/main/resources/Java/enum_outer_doc.mustache index 14b5d524c4a..20c512aaeae 100644 --- a/modules/swagger-codegen/src/main/resources/Java/enum_outer_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/enum_outer_doc.mustache @@ -2,6 +2,6 @@ ## Enum -{{#allowableValues}} -* `{{.}}` -{{/allowableValues}} +{{#allowableValues}}{{#enumVars}} +* `{{name}}` (value: `{{{value}}}`) +{{/enumVars}}{{/allowableValues}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/enum_outer_doc.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/enum_outer_doc.mustache index b5370c1360b..20c512aaeae 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/enum_outer_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/enum_outer_doc.mustache @@ -3,5 +3,5 @@ ## Enum {{#allowableValues}}{{#enumVars}} -* `{{name}}` (value: `{{value}}`) +* `{{name}}` (value: `{{{value}}}`) {{/enumVars}}{{/allowableValues}} diff --git a/modules/swagger-codegen/src/main/resources/Javascript/model_doc.mustache b/modules/swagger-codegen/src/main/resources/Javascript/model_doc.mustache index 306d8a2b3f7..4f2324fa2a7 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/model_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/model_doc.mustache @@ -1,9 +1,25 @@ -{{#models}}{{#model}}# {{moduleName}}.{{classname}} +{{#models}}{{#model}}{{#isEnum}}# {{moduleName}}.{{classname}} + +## Enum + +{{#allowableValues}}{{#enumVars}} +* `{{name}}` (value: `{{{value}}}`) +{{/enumVars}}{{/allowableValues}} +{{/isEnum}}{{^isEnum}}# {{moduleName}}.{{classname}} ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- {{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} {{/vars}} +{{#vars}}{{#isEnum}} -{{/model}}{{/models}} + +## Enum: {{datatypeWithEnum}} + +{{#allowableValues}}{{#enumVars}} +* `{{name}}` (value: `{{{value}}}`) +{{/enumVars}}{{/allowableValues}} + +{{/isEnum}}{{/vars}} +{{/isEnum}}{{/model}}{{/models}} diff --git a/modules/swagger-codegen/src/main/resources/Javascript/partial_model_enum_class.mustache b/modules/swagger-codegen/src/main/resources/Javascript/partial_model_enum_class.mustache index c7d18d35841..9ad7e3d3a90 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/partial_model_enum_class.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/partial_model_enum_class.mustache @@ -5,18 +5,18 @@ * @readonly */ {{/emitJSDoc}} - exports.{{classname}} = { + var exports = { {{#allowableValues}} - {{#values}} + {{#enumVars}} {{#emitJSDoc}} /** - * value: {{{.}}} + * value: {{{value}}} * @const */ {{/emitJSDoc}} - "{{{.}}}": "{{{.}}}"{{^-last}}, + "{{name}}": {{{value}}}{{^-last}}, {{/-last}} - {{/values}} + {{/enumVars}} {{/allowableValues}} }; diff --git a/modules/swagger-codegen/src/main/resources/csharp/Project.mustache b/modules/swagger-codegen/src/main/resources/csharp/Project.mustache index d38e5d92d1e..141d541a5b5 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/Project.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/Project.mustache @@ -39,8 +39,6 @@ - - @@ -48,18 +46,23 @@ - False - {{binRelativePath}}/Newtonsoft.Json.8.0.2/lib/{{targetFrameworkNuget}}/Newtonsoft.Json.dll + $(SolutionDir)\packages\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll + ..\..\packages\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll + {{binRelativePath}}\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll - {{binRelativePath}}/RestSharp.105.2.3/lib/{{targetFrameworkNuget}}/RestSharp.dll + $(SolutionDir)\packages\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll + ..\packages\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll + ..\..\packages\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll + {{binRelativePath}}\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll - - - - + + + + diff --git a/modules/swagger-codegen/src/main/resources/csharp/README.mustache b/modules/swagger-codegen/src/main/resources/csharp/README.mustache index c7fb29fafab..fa0d40873f1 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/README.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/README.mustache @@ -37,8 +37,8 @@ NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploa ## Installation Run the following command to generate the DLL -- [Mac/Linux] `/bin/sh compile-mono.sh` -- [Windows] `compile.bat` +- [Mac/Linux] `/bin/sh build.sh` +- [Windows] `build.bat` Then include the DLL (under the `bin` folder) in the C# project, and use the namespaces: ```csharp diff --git a/modules/swagger-codegen/src/main/resources/csharp/Solution.mustache b/modules/swagger-codegen/src/main/resources/csharp/Solution.mustache new file mode 100644 index 00000000000..57f6201600f --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/csharp/Solution.mustache @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +VisualStudioVersion = 12.0.0.0 +MinimumVisualStudioVersion = 10.0.0.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "{{packageName}}", "src\{{packageName}}\{{packageName}}.csproj", "{{packageGuid}}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "{{testPackageName}}", "src\{{testPackageName}}\{{testPackageName}}.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}" +EndProject +Global +GlobalSection(SolutionConfigurationPlatforms) = preSolution +Debug|Any CPU = Debug|Any CPU +Release|Any CPU = Release|Any CPU +EndGlobalSection +GlobalSection(ProjectConfigurationPlatforms) = postSolution +{{packageGuid}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU +{{packageGuid}}.Debug|Any CPU.Build.0 = Debug|Any CPU +{{packageGuid}}.Release|Any CPU.ActiveCfg = Release|Any CPU +{{packageGuid}}.Release|Any CPU.Build.0 = Release|Any CPU +{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU +{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU +{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU +{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU +EndGlobalSection +GlobalSection(SolutionProperties) = preSolution +HideSolutionNode = FALSE +EndGlobalSection +EndGlobal \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/csharp/TestProject.mustache b/modules/swagger-codegen/src/main/resources/csharp/TestProject.mustache new file mode 100644 index 00000000000..0e0bd6c1671 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/csharp/TestProject.mustache @@ -0,0 +1,81 @@ + + + + Debug + AnyCPU + {19F1DEBC-DE5E-4517-8062-F000CD499087} + Library + Properties + {{testPackageName}} + {{testPackageName}} + {{^supportsUWP}} + {{targetFramework}} + {{/supportsUWP}} + {{#supportsUWP}} + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + {{/supportsUWP}} + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + $(SolutionDir)\packages\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll + ..\..\packages\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll + {{binRelativePath}}\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll + + + $(SolutionDir)\packages\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll + ..\packages\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll + ..\..\packages\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll + {{binRelativePath}}\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll + + + $(SolutionDir)\packages\NUnit.2.6.3\lib\nunit.framework.dll + ..\packages\NUnit.2.6.3\lib\nunit.framework.dll + ..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll + {{binRelativePath}}\NUnit.2.6.3\lib\nunit.framework.dll + + + + + + + + + + + + {{packageGuid}} + {{packageName}} + + + + diff --git a/modules/swagger-codegen/src/main/resources/csharp/compile-mono.sh.mustache b/modules/swagger-codegen/src/main/resources/csharp/compile-mono.sh.mustache index b1b0c4f0c73..f93437eb0c8 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/compile-mono.sh.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/compile-mono.sh.mustache @@ -4,17 +4,17 @@ netfx=${frameworkVersion#net} wget -nc https://nuget.org/nuget.exe; mozroots --import --sync -mono nuget.exe install vendor/packages.config -o vendor; +mono nuget.exe install src/{{packageName}}/packages.config -o packages; mkdir -p bin; -cp vendor/Newtonsoft.Json.8.0.2/lib/{{targetFrameworkNuget}}/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll; -cp vendor/RestSharp.105.1.0/lib/{{targetFrameworkNuget}}/RestSharp.dll bin/RestSharp.dll; +cp packages/Newtonsoft.Json.8.0.2/lib/{{targetFrameworkNuget}}/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll; +cp packages/RestSharp.105.1.0/lib/{{targetFrameworkNuget}}/RestSharp.dll bin/RestSharp.dll; mcs -sdk:${netfx} -r:bin/Newtonsoft.Json.dll,\ bin/RestSharp.dll,\ System.Runtime.Serialization.dll \ -target:library \ -out:bin/{{packageName}}.dll \ --recurse:'src/*.cs' \ +-recurse:'src/{{packageName}}/*.cs' \ -doc:bin/{{packageName}}.xml \ -platform:anycpu diff --git a/modules/swagger-codegen/src/main/resources/csharp/compile.mustache b/modules/swagger-codegen/src/main/resources/csharp/compile.mustache index 76b94cad5a1..7f6dcfe0713 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/compile.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/compile.mustache @@ -4,11 +4,11 @@ {{^supportsAsync}}SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v3.5{{/supportsAsync}} if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://nuget.org/nuget.exe', '.\nuget.exe')" -.\nuget.exe install vendor/packages.config -o vendor +.\nuget.exe install src\{{packageName}}\packages.config -o packages if not exist ".\bin" mkdir bin -copy vendor\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll bin\Newtonsoft.Json.dll -copy vendor\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll bin\RestSharp.dll +copy packages\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll bin\Newtonsoft.Json.dll +copy packages\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll bin\RestSharp.dll -%CSCPATH%\csc /reference:bin\Newtonsoft.Json.dll;bin\RestSharp.dll /target:library /out:bin\{{packageName}}.dll /recurse:src\*.cs /doc:bin\{{packageName}}.xml +%CSCPATH%\csc /reference:bin\Newtonsoft.Json.dll;bin\RestSharp.dll /target:library /out:bin\{{packageName}}.dll /recurse:src\{{packageName}}\*.cs /doc:bin\{{packageName}}.xml diff --git a/modules/swagger-codegen/src/main/resources/csharp/packages_test.config.mustache b/modules/swagger-codegen/src/main/resources/csharp/packages_test.config.mustache new file mode 100644 index 00000000000..5464714bcef --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/csharp/packages_test.config.mustache @@ -0,0 +1,6 @@ + + + + + + diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index cd32f831d71..480db023f6b 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -35,9 +35,9 @@ func New{{classname}}WithBasePath(basePath string) *{{classname}} { * {{notes}}{{/notes}} * {{#allParams}} * @param {{paramName}} {{description}} -{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} +{{/allParams}} * @return {{#returnType}}{{^isListContainer}}*{{/isListContainer}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} */ -func (a {{classname}}) {{nickname}}({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}*{{{returnType}}}, {{/returnType}}*APIResponse, error) { +func (a {{classname}}) {{nickname}}({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{^isListContainer}}*{{/isListContainer}}{{{returnType}}}, {{/returnType}}*APIResponse, error) { var httpMethod = "{{httpMethod}}" // create path and map variables @@ -46,7 +46,7 @@ func (a {{classname}}) {{nickname}}({{#allParams}}{{paramName}} {{{dataType}}}{{ {{#allParams}}{{#required}} // verify the required parameter '{{paramName}}' is set if &{{paramName}} == nil { - return {{#returnType}}new({{{returnType}}}), {{/returnType}}nil, errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}") + return {{#returnType}}{{#isListContainer}}*{{/isListContainer}}new({{{returnType}}}), {{/returnType}}nil, errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}") }{{/required}}{{/allParams}} headerParams := make(map[string]string) @@ -113,10 +113,10 @@ func (a {{classname}}) {{nickname}}({{#allParams}}{{paramName}} {{{dataType}}}{{ {{#returnType}} var successPayload = new({{returnType}}){{/returnType}} httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return {{#returnType}}successPayload, {{/returnType}}NewAPIResponse(httpResponse.RawResponse), err + return {{#returnType}}{{#isListContainer}}*{{/isListContainer}}successPayload, {{/returnType}}NewAPIResponse(httpResponse.RawResponse), err } {{#returnType}} err = json.Unmarshal(httpResponse.Body(), &successPayload){{/returnType}} - return {{#returnType}}successPayload, {{/returnType}}NewAPIResponse(httpResponse.RawResponse), err + return {{#returnType}}{{#isListContainer}}*{{/isListContainer}}successPayload, {{/returnType}}NewAPIResponse(httpResponse.RawResponse), err } {{/operation}}{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache b/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache index fa0e662b67f..60da5979a89 100644 --- a/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache +++ b/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache @@ -127,6 +127,7 @@ {{#responses}}

{{code}}

{{message}} + {{#simpleType}}{{dataType}}{{/simpleType}} {{#examples}}

Example data

Content-Type: {{{contentType}}}
@@ -158,7 +159,7 @@

{{classname}} Up

- {{#vars}}
{{name}} {{^required}}(optional){{/required}}
{{datatype}} {{description}}
+ {{#vars}}
{{name}} {{^required}}(optional){{/required}}
{{^isPrimitiveType}}{{datatype}}{{/isPrimitiveType}} {{description}}
{{#isEnum}}
Enum:
{{#_enum}}
{{this}}
{{/_enum}} diff --git a/modules/swagger-codegen/src/main/resources/nodejs/package.mustache b/modules/swagger-codegen/src/main/resources/nodejs/package.mustache index 86aa21af635..2d2b917c4b2 100644 --- a/modules/swagger-codegen/src/main/resources/nodejs/package.mustache +++ b/modules/swagger-codegen/src/main/resources/nodejs/package.mustache @@ -11,6 +11,6 @@ "dependencies": { "connect": "^3.2.0", "js-yaml": "^3.3.0", - "swagger-tools": "0.9.*" + "swagger-tools": "0.10.1" } } diff --git a/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache b/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache index 18b756f78b0..a8644bab030 100644 --- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache @@ -2,10 +2,6 @@ NSString *const {{classPrefix}}ResponseObjectErrorKey = @"{{classPrefix}}ResponseObject"; -NSString *const {{classPrefix}}DeserializationErrorDomainKey = @"{{classPrefix}}DeserializationErrorDomainKey"; - -NSInteger const {{classPrefix}}TypeMismatchErrorCode = 143553; - static long requestId = 0; static bool offlineState = false; static NSMutableSet * queuedRequests = nil; @@ -33,6 +29,7 @@ static void (^reachabilityChangeBlock)(int); self.requestSerializer = [AFJSONRequestSerializer serializer]; self.responseSerializer = [AFJSONResponseSerializer serializer]; self.securityPolicy = [self customSecurityPolicy]; + self.responseDeserializer = [[{{classPrefix}}ResponseDeserializer alloc] init]; // configure reachability [self configureCacheReachibility]; } @@ -290,154 +287,6 @@ static void (^reachabilityChangeBlock)(int); [self.reachabilityManager startMonitoring]; } -#pragma mark - Deserialize methods - -- (id) deserialize:(id) data class:(NSString *) class error:(NSError **) error { - // return nil if data is nil or class is nil - if (!data || !class) { - return nil; - } - - // remove "*" from class, if ends with "*" - if ([class hasSuffix:@"*"]) { - class = [class substringToIndex:[class length] - 1]; - } - - // pure object - if ([class isEqualToString:@"NSObject"]) { - return data; - } - - NSRegularExpression *regexp = nil; - NSTextCheckingResult *match = nil; - NSMutableArray *resultArray = nil; - NSMutableDictionary *resultDict = nil; - NSString *innerType = nil; - - // list of models - NSString *arrayOfModelsPat = @"NSArray<(.+)>"; - regexp = [NSRegularExpression regularExpressionWithPattern:arrayOfModelsPat - options:NSRegularExpressionCaseInsensitive - error:nil]; - - match = [regexp firstMatchInString:class - options:0 - range:NSMakeRange(0, [class length])]; - - if (match) { - if(![data isKindOfClass: [NSArray class]]) { - if(error) { - NSDictionary * userInfo = @{NSLocalizedDescriptionKey : NSLocalizedString(@"Received response is not an array", nil)}; - *error = [NSError errorWithDomain:{{classPrefix}}DeserializationErrorDomainKey code:{{classPrefix}}TypeMismatchErrorCode userInfo:userInfo]; - } - return nil; - } - NSArray *dataArray = data; - innerType = [class substringWithRange:[match rangeAtIndex:1]]; - - resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; - [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - id arrObj = [self deserialize:obj class:innerType error:error]; - if(arrObj) { - [resultArray addObject:arrObj]; - } else { - * stop = YES; - } - }]; - - return resultArray; - } - - // list of primitives - NSString *arrayOfPrimitivesPat = @"NSArray\\* /\\* (.+) \\*/"; - regexp = [NSRegularExpression regularExpressionWithPattern:arrayOfPrimitivesPat - options:NSRegularExpressionCaseInsensitive - error:nil]; - match = [regexp firstMatchInString:class - options:0 - range:NSMakeRange(0, [class length])]; - - if (match) { - NSArray *dataArray = data; - innerType = [class substringWithRange:[match rangeAtIndex:1]]; - - resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; - [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - id arrObj = [self deserialize:obj class:innerType error:error]; - if(arrObj) { - [resultArray addObject:arrObj]; - } else { - * stop = YES; - } - }]; - - return resultArray; - } - - // map - NSString *dictPat = @"NSDictionary\\* /\\* (.+?), (.+) \\*/"; - regexp = [NSRegularExpression regularExpressionWithPattern:dictPat - options:NSRegularExpressionCaseInsensitive - error:nil]; - match = [regexp firstMatchInString:class - options:0 - range:NSMakeRange(0, [class length])]; - - if (match) { - NSDictionary *dataDict = data; - NSString *valueType = [class substringWithRange:[match rangeAtIndex:2]]; - - resultDict = [NSMutableDictionary dictionaryWithCapacity:[dataDict count]]; - [data enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { - id dicObj = [self deserialize:obj class:valueType error:error]; - if(dicObj) { - [resultDict setValue:dicObj forKey:key]; - } else { - * stop = YES; - } - }]; - - return resultDict; - } - - // primitives - NSArray *primitiveTypes = @[@"NSString", @"NSDate", @"NSNumber"]; - - if ([primitiveTypes containsObject:class]) { - if ([class isEqualToString:@"NSString"]) { - return [NSString stringWithString:data]; - } - else if ([class isEqualToString:@"NSDate"]) { - return [NSDate dateWithISO8601String:data]; - } - else if ([class isEqualToString:@"NSNumber"]) { - // NSNumber from NSNumber - if ([data isKindOfClass:[NSNumber class]]) { - return data; - } - else if ([data isKindOfClass:[NSString class]]) { - // NSNumber (NSCFBoolean) from NSString - if ([[data lowercaseString] isEqualToString:@"true"] || [[data lowercaseString] isEqualToString:@"false"]) { - return [NSNumber numberWithBool:[data boolValue]]; - // NSNumber from NSString - } else { - NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; - formatter.numberStyle = NSNumberFormatterDecimalStyle; - return [formatter numberFromString:data]; - } - } - } - } - - // model - Class ModelClass = NSClassFromString(class); - if ([ModelClass instancesRespondToSelector:@selector(initWithDictionary:error:)]) { - return [(JSONModel *) [ModelClass alloc] initWithDictionary:data error:error]; - } - - return nil; -} - #pragma mark - Operation Methods - (void) operationWithCompletionBlock: (NSURLRequest *)request @@ -661,7 +510,7 @@ static void (^reachabilityChangeBlock)(int); else { [self operationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) { NSError * serializationError; - id response = [self deserialize:data class:responseType error:&serializationError]; + id response = [self.responseDeserializer deserialize:data class:responseType error:&serializationError]; if(!response && !error){ error = serializationError; } diff --git a/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache b/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache index 1cf3db5e523..c7caa7ab11e 100644 --- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache @@ -5,7 +5,7 @@ #import "{{classPrefix}}JSONRequestSerializer.h" #import "{{classPrefix}}QueryParamCollection.h" #import "{{classPrefix}}Configuration.h" - +#import "{{classPrefix}}ResponseDeserializer.h" /** * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen @@ -25,16 +25,6 @@ */ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; -/** - * A key for deserialization ErrorDomain - */ -extern NSString *const {{classPrefix}}DeserializationErrorDomainKey; - -/** - * Code for deserialization type mismatch error - */ -extern NSInteger const {{classPrefix}}TypeMismatchErrorCode; - /** * Log debug message macro */ @@ -49,6 +39,7 @@ extern NSInteger const {{classPrefix}}TypeMismatchErrorCode; /// In order to ensure the HTTPResponseHeaders are correct, it is recommended to initialize one {{classPrefix}}ApiClient instance per thread. @property(nonatomic, readonly) NSDictionary* HTTPResponseHeaders; +@property(nonatomic, strong) id<{{classPrefix}}ResponseDeserializer> responseDeserializer; /** * Clears Cache */ @@ -176,15 +167,6 @@ extern NSInteger const {{classPrefix}}TypeMismatchErrorCode; queryParams:(NSDictionary **)querys WithAuthSettings:(NSArray *)authSettings; -/** - * Deserializes the given data to Objective-C object. - * - * @param data The data will be deserialized. - * @param class The type of objective-c object. - * @param error The error - */ -- (id) deserialize:(id) data class:(NSString *) class error:(NSError**)error; - /** * Logs request and response * diff --git a/modules/swagger-codegen/src/main/resources/objc/Object-body.mustache b/modules/swagger-codegen/src/main/resources/objc/Object-body.mustache index 122484f1ad4..b4599c34f3f 100644 --- a/modules/swagger-codegen/src/main/resources/objc/Object-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/Object-body.mustache @@ -1,4 +1,13 @@ #import "{{classPrefix}}Object.h" @implementation {{classPrefix}}Object + +/** + * Gets the string presentation of the object. + * This method will be called when logging model object using `NSLog`. + */ +- (NSString *)description { + return [[self toDictionary] description]; +} + @end diff --git a/modules/swagger-codegen/src/main/resources/objc/ResponseDeserializer-body.mustache b/modules/swagger-codegen/src/main/resources/objc/ResponseDeserializer-body.mustache new file mode 100644 index 00000000000..27a59e39cdc --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/objc/ResponseDeserializer-body.mustache @@ -0,0 +1,231 @@ +#import "{{classPrefix}}ResponseDeserializer.h" +#import +#import + +NSString *const {{classPrefix}}DeserializationErrorDomainKey = @"{{classPrefix}}DeserializationErrorDomainKey"; + +NSInteger const {{classPrefix}}TypeMismatchErrorCode = 143553; + +NSInteger const {{classPrefix}}EmptyValueOccurredErrorCode = 143509; + +NSInteger const {{classPrefix}}UnknownResponseObjectErrorCode = 143528; + + +@interface {{classPrefix}}ResponseDeserializer () + +@property (nonatomic, strong) NSNumberFormatter* numberFormatter; +@property (nonatomic, strong) NSArray *primitiveTypes; +@property (nonatomic, strong) NSArray *basicReturnTypes; + +@property (nonatomic, strong) NSRegularExpression* arrayOfModelsPatExpression; +@property (nonatomic, strong) NSRegularExpression* arrayOfPrimitivesPatExpression; +@property (nonatomic, strong) NSRegularExpression* dictPatExpression; +@property (nonatomic, strong) NSRegularExpression* dictModelsPatExpression; + +@end + +@implementation {{classPrefix}}ResponseDeserializer + +- (instancetype)init { + self = [super init]; + if (self) { + NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; + formatter.numberStyle = NSNumberFormatterDecimalStyle; + _numberFormatter = formatter; + _primitiveTypes = @[@"NSString", @"NSDate", @"NSNumber"]; + _basicReturnTypes = @[@"NSObject", @"id"]; + _arrayOfModelsPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSArray<(.+)>" + options:NSRegularExpressionCaseInsensitive + error:nil]; + _arrayOfPrimitivesPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSArray\\* /\\* (.+) \\*/" + options:NSRegularExpressionCaseInsensitive + error:nil]; + _dictPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSDictionary\\* /\\* (.+?), (.+) \\*/" + options:NSRegularExpressionCaseInsensitive + error:nil]; + _dictModelsPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSDictionary\\<(.+?), (.+)*\\>" + options:NSRegularExpressionCaseInsensitive + error:nil]; + } + return self; +} + +#pragma mark - Deserialize methods + +- (id) deserialize:(id) data class:(NSString *) className error:(NSError **) error { + // return nil if data is nil or className is nil + if (!data || !className || [data isKindOfClass:[NSNull class]]) { + return nil; + } + + // remove "*" from className, if ends with "*" + if ([className hasSuffix:@"*"]) { + className = [className substringToIndex:[className length] - 1]; + } + // pure object + if ([self.basicReturnTypes containsObject:className]) { + return data; + } + + // primitives + if ([self.primitiveTypes containsObject:className]) { + return [self deserializePrimitiveValue:data class:className error:error]; + } + + NSTextCheckingResult *match = nil; + NSRange range = NSMakeRange(0, [className length]); + // list of models + match = [self.arrayOfModelsPatExpression firstMatchInString:className options:0 range:range]; + if (match) { + NSString *innerType = [className substringWithRange:[match rangeAtIndex:1]]; + return [self deserializeArrayValue:data innerType:innerType error:error]; + } + + // list of primitives + match = [self.arrayOfPrimitivesPatExpression firstMatchInString:className options:0 range:range]; + if (match) { + NSString *innerType = [className substringWithRange:[match rangeAtIndex:1]]; + return [self deserializeArrayValue:data innerType:innerType error:error]; + } + + // map + match = [self.dictPatExpression firstMatchInString:className options:0 range:range]; + if (match) { + NSString *valueType = [className substringWithRange:[match rangeAtIndex:2]]; + return [self deserializeDictionaryValue:data valueType:valueType error:error]; + } + + match = [self.dictModelsPatExpression firstMatchInString:className options:0 range:range]; + if (match) { + NSString *valueType = [className substringWithRange:[match rangeAtIndex:2]]; + return [self deserializeDictionaryValue:data valueType:valueType error:error]; + } + + // model + Class ModelClass = NSClassFromString(className); + if ([ModelClass instancesRespondToSelector:@selector(initWithDictionary:error:)]) { + return [(JSONModel *) [ModelClass alloc] initWithDictionary:data error:error]; + } + + if(error) { + *error = [self unknownResponseErrorWithExpectedType:className data:data]; + } + return nil; +} + +- (id) deserializeDictionaryValue:(id) data valueType:(NSString *) valueType error:(NSError**)error { + if(![data isKindOfClass: [NSDictionary class]]) { + if(error) { + *error = [self typeMismatchErrorWithExpectedType:NSStringFromClass([NSDictionary class]) data:data]; + } + return nil; + } + __block NSMutableDictionary *resultDict = [NSMutableDictionary dictionaryWithCapacity:[data count]]; + for (id key in [data allKeys]) { + id obj = [data valueForKey:key]; + id dicObj = [self deserialize:obj class:valueType error:error]; + if(dicObj) { + [resultDict setValue:dicObj forKey:key]; + } else if([obj isKindOfClass:[NSNull class]]) { + if(self.treatNullAsError) { + if (error) { + *error = [self emptyValueOccurredError]; + } + resultDict = nil; + break; + } + } else { + resultDict = nil; + break; + } + } + return resultDict; +} + +- (id) deserializeArrayValue:(id) data innerType:(NSString *) innerType error:(NSError**)error { + if(![data isKindOfClass: [NSArray class]]) { + if(error) { + *error = [self typeMismatchErrorWithExpectedType:NSStringFromClass([NSArray class]) data:data]; + } + return nil; + } + NSMutableArray* resultArray = [NSMutableArray arrayWithCapacity:[data count]]; + for (id obj in data) { + id arrObj = [self deserialize:obj class:innerType error:error]; + if(arrObj) { + [resultArray addObject:arrObj]; + } else if([obj isKindOfClass:[NSNull class]]) { + if(self.treatNullAsError) { + if (error) { + *error = [self emptyValueOccurredError]; + } + resultArray = nil; + break; + } + } else { + resultArray = nil; + break; + } + } + return resultArray; +}; + +- (id) deserializePrimitiveValue:(id) data class:(NSString *) className error:(NSError**)error { + if ([className isEqualToString:@"NSString"]) { + return [NSString stringWithString:data]; + } + else if ([className isEqualToString:@"NSDate"]) { + return [self deserializeDateValue:data error:error]; + } + else if ([className isEqualToString:@"NSNumber"]) { + // NSNumber from NSNumber + if ([data isKindOfClass:[NSNumber class]]) { + return data; + } + else if ([data isKindOfClass:[NSString class]]) { + // NSNumber (NSCFBoolean) from NSString + if ([[data lowercaseString] isEqualToString:@"true"] || [[data lowercaseString] isEqualToString:@"false"]) { + return @([data boolValue]); + // NSNumber from NSString + } else { + NSNumber* formattedValue = [self.numberFormatter numberFromString:data]; + if(!formattedValue && [data length] > 0 && error) { + *error = [self typeMismatchErrorWithExpectedType:className data:data]; + } + return formattedValue; + } + } + } + if(error) { + *error = [self typeMismatchErrorWithExpectedType:className data:data]; + } + return nil; +} + +- (id) deserializeDateValue:(id) data error:(NSError**)error { + NSDate *date =[NSDate dateWithISO8601String:data]; + if(!date && [data length] > 0 && error) { + *error = [self typeMismatchErrorWithExpectedType:NSStringFromClass([NSDate class]) data:data]; + } + return date; +}; + +-(NSError *)typeMismatchErrorWithExpectedType:(NSString *)expected data:(id)data { + NSString * message = [NSString stringWithFormat:NSLocalizedString(@"Received response [%@] is not an object of type %@",nil),data, expected]; + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : message}; + return [NSError errorWithDomain:{{classPrefix}}DeserializationErrorDomainKey code:{{classPrefix}}TypeMismatchErrorCode userInfo:userInfo]; +} + +-(NSError *)emptyValueOccurredError { + NSString * message = NSLocalizedString(@"Received response contains null value in dictionary or array response",nil); + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : message}; + return [NSError errorWithDomain:{{classPrefix}}DeserializationErrorDomainKey code:{{classPrefix}}EmptyValueOccurredErrorCode userInfo:userInfo]; +} + +-(NSError *)unknownResponseErrorWithExpectedType:(NSString *)expected data:(id)data { + NSString * message = [NSString stringWithFormat:NSLocalizedString(@"Unknown response expected type %@ [reponse: %@]",nil),expected,data]; + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : message}; + return [NSError errorWithDomain:{{classPrefix}}DeserializationErrorDomainKey code:{{classPrefix}}UnknownResponseObjectErrorCode userInfo:userInfo]; +} + +@end diff --git a/modules/swagger-codegen/src/main/resources/objc/ResponseDeserializer-header.mustache b/modules/swagger-codegen/src/main/resources/objc/ResponseDeserializer-header.mustache new file mode 100644 index 00000000000..2dd038c13f0 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/objc/ResponseDeserializer-header.mustache @@ -0,0 +1,50 @@ +#import + +/** + * 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. + */ + +/** + * A key for deserialization ErrorDomain + */ +extern NSString *const {{classPrefix}}DeserializationErrorDomainKey; + +/** + * Code for deserialization type mismatch error + */ +extern NSInteger const {{classPrefix}}TypeMismatchErrorCode; + +/** + * Code for deserialization empty value error + */ +extern NSInteger const {{classPrefix}}EmptyValueOccurredErrorCode; + +/** + * Error code for unknown response + */ +extern NSInteger const {{classPrefix}}UnknownResponseObjectErrorCode; + +@protocol {{classPrefix}}ResponseDeserializer + +/** + * Deserializes the given data to Objective-C object. + * + * @param data The data will be deserialized. + * @param class The type of objective-c object. + * @param error The error + */ +- (id) deserialize:(id) data class:(NSString *) className error:(NSError**)error; + +@end + +@interface {{classPrefix}}ResponseDeserializer : NSObject <{{classPrefix}}ResponseDeserializer> + +/** + * If an null value occurs in dictionary or array if set to YES whole response will be invalid else will be ignored + * @default NO + */ +@property (nonatomic, assign) BOOL treatNullAsError; + +@end diff --git a/modules/swagger-codegen/src/main/resources/objc/model-body.mustache b/modules/swagger-codegen/src/main/resources/objc/model-body.mustache index ec5ab3b9f80..776cd55ccef 100644 --- a/modules/swagger-codegen/src/main/resources/objc/model-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/model-body.mustache @@ -6,13 +6,11 @@ - (instancetype)init { self = [super init]; - if (self) { // initalise property's default value, if any {{#vars}}{{#defaultValue}}self.{{name}} = {{{defaultValue}}}; {{/defaultValue}}{{/vars}} } - return self; } @@ -22,7 +20,6 @@ */ - (id)initWithDictionary:(NSDictionary *)dict error:(NSError *__autoreleasing *)err { - NSString * discriminatedClassName = [dict valueForKey:@"{{discriminator}}"]; if(discriminatedClassName == nil ){ @@ -45,8 +42,7 @@ * Maps json key to property name. * This method is used by `JSONModel`. */ -+ (JSONKeyMapper *)keyMapper -{ ++ (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ {{#vars}}@"{{baseName}}": @"{{name}}"{{#hasMore}}, {{/hasMore}}{{/vars}} }]; } @@ -55,24 +51,11 @@ * If `propertyName` is optional, then return `YES`, otherwise return `NO`. * This method is used by `JSONModel`. */ -+ (BOOL)propertyIsOptional:(NSString *)propertyName -{ ++ (BOOL)propertyIsOptional:(NSString *)propertyName { + NSArray *optionalProperties = @[{{#vars}}{{^required}}@"{{name}}"{{#hasMore}}, {{/hasMore}}{{/required}}{{/vars}}]; + return [optionalProperties containsObject:propertyName]; - if ([optionalProperties containsObject:propertyName]) { - return YES; - } - else { - return NO; - } -} - -/** - * Gets the string presentation of the object. - * This method will be called when logging model object using `NSLog`. - */ -- (NSString *)description { - return [[self toDictionary] description]; } {{/model}} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/.gitignore b/samples/client/petstore/csharp/SwaggerClient/.gitignore similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/.gitignore rename to samples/client/petstore/csharp/SwaggerClient/.gitignore diff --git a/samples/client/petstore/csharp/SwaggerClient/IO.Swagger.sln b/samples/client/petstore/csharp/SwaggerClient/IO.Swagger.sln new file mode 100644 index 00000000000..72e6e04d121 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClient/IO.Swagger.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +VisualStudioVersion = 12.0.0.0 +MinimumVisualStudioVersion = 10.0.0.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{AC0D0300-7030-473F-B672-17C40187815A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger.Test", "src\IO.Swagger.Test\IO.Swagger.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}" +EndProject +Global +GlobalSection(SolutionConfigurationPlatforms) = preSolution +Debug|Any CPU = Debug|Any CPU +Release|Any CPU = Release|Any CPU +EndGlobalSection +GlobalSection(ProjectConfigurationPlatforms) = postSolution +{AC0D0300-7030-473F-B672-17C40187815A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU +{AC0D0300-7030-473F-B672-17C40187815A}.Debug|Any CPU.Build.0 = Debug|Any CPU +{AC0D0300-7030-473F-B672-17C40187815A}.Release|Any CPU.ActiveCfg = Release|Any CPU +{AC0D0300-7030-473F-B672-17C40187815A}.Release|Any CPU.Build.0 = Release|Any CPU +{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU +{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU +{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU +{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU +EndGlobalSection +GlobalSection(SolutionProperties) = preSolution +HideSolutionNode = FALSE +EndGlobalSection +EndGlobal \ No newline at end of file diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/README.md b/samples/client/petstore/csharp/SwaggerClient/README.md similarity index 85% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/README.md rename to samples/client/petstore/csharp/SwaggerClient/README.md index aceb18e3396..1f7e9f634e0 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/README.md +++ b/samples/client/petstore/csharp/SwaggerClient/README.md @@ -6,7 +6,7 @@ This C# SDK is automatically generated by the [Swagger Codegen](https://github.c - API version: 1.0.0 - SDK version: 1.0.0 -- Build date: 2016-04-27T22:04:12.906+08:00 +- Build date: 2016-05-07T17:39:09.181+08:00 - Build package: class io.swagger.codegen.languages.CSharpClientCodegen ## Frameworks supported @@ -27,14 +27,14 @@ NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploa ## Installation Run the following command to generate the DLL -- [Mac/Linux] `/bin/sh compile-mono.sh` -- [Windows] `compile.bat` +- [Mac/Linux] `/bin/sh build.sh` +- [Windows] `build.bat` Then include the DLL (under the `bin` folder) in the C# project, and use the namespaces: ```csharp using IO.Swagger.Api; using IO.Swagger.Client; -using IO.Swagger.Model; +using Model; ``` ## Getting Started @@ -44,7 +44,7 @@ using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; -using IO.Swagger.Model; +using Model; namespace Example { @@ -54,7 +54,7 @@ namespace Example { var apiInstance = new FakeApi(); - var number = number_example; // string | None + var number = 3.4; // double? | None var _double = 1.2; // double? | None var _string = _string_example; // string | None var _byte = B; // byte[] | None @@ -112,22 +112,23 @@ Class | Method | HTTP request | Description ## Documentation for Models - - [IO.Swagger.Model.Animal](docs/Animal.md) - - [IO.Swagger.Model.ApiResponse](docs/ApiResponse.md) - - [IO.Swagger.Model.Cat](docs/Cat.md) - - [IO.Swagger.Model.Category](docs/Category.md) - - [IO.Swagger.Model.Dog](docs/Dog.md) - - [IO.Swagger.Model.EnumClass](docs/EnumClass.md) - - [IO.Swagger.Model.EnumTest](docs/EnumTest.md) - - [IO.Swagger.Model.FormatTest](docs/FormatTest.md) - - [IO.Swagger.Model.Model200Response](docs/Model200Response.md) - - [IO.Swagger.Model.ModelReturn](docs/ModelReturn.md) - - [IO.Swagger.Model.Name](docs/Name.md) - - [IO.Swagger.Model.Order](docs/Order.md) - - [IO.Swagger.Model.Pet](docs/Pet.md) - - [IO.Swagger.Model.SpecialModelName](docs/SpecialModelName.md) - - [IO.Swagger.Model.Tag](docs/Tag.md) - - [IO.Swagger.Model.User](docs/User.md) + - [Model.Animal](docs/Animal.md) + - [Model.AnimalFarm](docs/AnimalFarm.md) + - [Model.ApiResponse](docs/ApiResponse.md) + - [Model.Cat](docs/Cat.md) + - [Model.Category](docs/Category.md) + - [Model.Dog](docs/Dog.md) + - [Model.EnumClass](docs/EnumClass.md) + - [Model.EnumTest](docs/EnumTest.md) + - [Model.FormatTest](docs/FormatTest.md) + - [Model.Model200Response](docs/Model200Response.md) + - [Model.ModelReturn](docs/ModelReturn.md) + - [Model.Name](docs/Name.md) + - [Model.Order](docs/Order.md) + - [Model.Pet](docs/Pet.md) + - [Model.SpecialModelName](docs/SpecialModelName.md) + - [Model.Tag](docs/Tag.md) + - [Model.User](docs/User.md) ## Documentation for Authorization diff --git a/samples/client/petstore/csharp/SwaggerClient/build.bat b/samples/client/petstore/csharp/SwaggerClient/build.bat new file mode 100644 index 00000000000..80a13e48231 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClient/build.bat @@ -0,0 +1,14 @@ +@echo off + +SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319 + + +if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://nuget.org/nuget.exe', '.\nuget.exe')" +.\nuget.exe install src\IO.Swagger\packages.config -o packages + +if not exist ".\bin" mkdir bin + +copy packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll bin\Newtonsoft.Json.dll +copy packages\RestSharp.105.1.0\lib\net45\RestSharp.dll bin\RestSharp.dll + +%CSCPATH%\csc /reference:bin\Newtonsoft.Json.dll;bin\RestSharp.dll /target:library /out:bin\IO.Swagger.dll /recurse:src\IO.Swagger\*.cs /doc:bin\IO.Swagger.xml diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile-mono.sh b/samples/client/petstore/csharp/SwaggerClient/build.sh old mode 100755 new mode 100644 similarity index 56% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile-mono.sh rename to samples/client/petstore/csharp/SwaggerClient/build.sh index d768c892f31..159673fd60c --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile-mono.sh +++ b/samples/client/petstore/csharp/SwaggerClient/build.sh @@ -4,17 +4,17 @@ netfx=${frameworkVersion#net} wget -nc https://nuget.org/nuget.exe; mozroots --import --sync -mono nuget.exe install vendor/packages.config -o vendor; +mono nuget.exe install src/IO.Swagger/packages.config -o packages; mkdir -p bin; -cp vendor/Newtonsoft.Json.8.0.2/lib/net45/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll; -cp vendor/RestSharp.105.1.0/lib/net45/RestSharp.dll bin/RestSharp.dll; +cp packages/Newtonsoft.Json.8.0.2/lib/net45/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll; +cp packages/RestSharp.105.1.0/lib/net45/RestSharp.dll bin/RestSharp.dll; mcs -sdk:${netfx} -r:bin/Newtonsoft.Json.dll,\ bin/RestSharp.dll,\ System.Runtime.Serialization.dll \ -target:library \ -out:bin/IO.Swagger.dll \ --recurse:'src/*.cs' \ +-recurse:'src/IO.Swagger/*.cs' \ -doc:bin/IO.Swagger.xml \ -platform:anycpu diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Animal.md b/samples/client/petstore/csharp/SwaggerClient/docs/Animal.md similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Animal.md rename to samples/client/petstore/csharp/SwaggerClient/docs/Animal.md diff --git a/samples/client/petstore/csharp/SwaggerClient/docs/AnimalFarm.md b/samples/client/petstore/csharp/SwaggerClient/docs/AnimalFarm.md new file mode 100644 index 00000000000..4d1cccb0cef --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClient/docs/AnimalFarm.md @@ -0,0 +1,8 @@ +# IO.Swagger.Model.AnimalFarm +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/ApiResponse.md b/samples/client/petstore/csharp/SwaggerClient/docs/ApiResponse.md similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/ApiResponse.md rename to samples/client/petstore/csharp/SwaggerClient/docs/ApiResponse.md diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Cat.md b/samples/client/petstore/csharp/SwaggerClient/docs/Cat.md similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Cat.md rename to samples/client/petstore/csharp/SwaggerClient/docs/Cat.md diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Category.md b/samples/client/petstore/csharp/SwaggerClient/docs/Category.md similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Category.md rename to samples/client/petstore/csharp/SwaggerClient/docs/Category.md diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Dog.md b/samples/client/petstore/csharp/SwaggerClient/docs/Dog.md similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Dog.md rename to samples/client/petstore/csharp/SwaggerClient/docs/Dog.md diff --git a/samples/client/petstore/csharp/SwaggerClient/docs/EnumClass.md b/samples/client/petstore/csharp/SwaggerClient/docs/EnumClass.md new file mode 100644 index 00000000000..d936aad6f0b --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClient/docs/EnumClass.md @@ -0,0 +1,8 @@ +# IO.Swagger.Model.EnumClass +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClient/docs/EnumTest.md b/samples/client/petstore/csharp/SwaggerClient/docs/EnumTest.md new file mode 100644 index 00000000000..f0f300021b5 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClient/docs/EnumTest.md @@ -0,0 +1,11 @@ +# IO.Swagger.Model.EnumTest +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**EnumString** | **string** | | [optional] +**EnumInteger** | **int?** | | [optional] +**EnumNumber** | **double?** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md b/samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md new file mode 100644 index 00000000000..ae9fd8c3d36 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md @@ -0,0 +1,91 @@ +# IO.Swagger.Api.FakeApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**TestEndpointParameters**](FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters + + +# **TestEndpointParameters** +> void TestEndpointParameters (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null) + +Fake endpoint for testing various parameters + +Fake endpoint for testing various parameters + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class TestEndpointParametersExample + { + public void main() + { + + var apiInstance = new FakeApi(); + var number = 3.4; // double? | None + var _double = 1.2; // double? | None + var _string = _string_example; // string | None + var _byte = B; // byte[] | None + var integer = 56; // int? | None (optional) + var int32 = 56; // int? | None (optional) + var int64 = 789; // long? | None (optional) + var _float = 3.4; // float? | None (optional) + var binary = B; // byte[] | None (optional) + var date = 2013-10-20; // DateTime? | None (optional) + var dateTime = 2013-10-20T19:20:30+01:00; // DateTime? | None (optional) + var password = password_example; // string | None (optional) + + try + { + // Fake endpoint for testing various parameters + apiInstance.TestEndpointParameters(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password); + } + catch (Exception e) + { + Debug.Print("Exception when calling FakeApi.TestEndpointParameters: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **number** | **double?**| None | + **_double** | **double?**| None | + **_string** | **string**| None | + **_byte** | **byte[]**| None | + **integer** | **int?**| None | [optional] + **int32** | **int?**| None | [optional] + **int64** | **long?**| None | [optional] + **_float** | **float?**| None | [optional] + **binary** | **byte[]**| None | [optional] + **date** | **DateTime?**| None | [optional] + **dateTime** | **DateTime?**| None | [optional] + **password** | **string**| None | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/FormatTest.md b/samples/client/petstore/csharp/SwaggerClient/docs/FormatTest.md similarity index 95% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/FormatTest.md rename to samples/client/petstore/csharp/SwaggerClient/docs/FormatTest.md index c5dc3cf53f3..7ddfad04d05 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/FormatTest.md +++ b/samples/client/petstore/csharp/SwaggerClient/docs/FormatTest.md @@ -14,6 +14,7 @@ Name | Type | Description | Notes **Binary** | **byte[]** | | [optional] **Date** | **DateTime?** | | **DateTime** | **DateTime?** | | [optional] +**Uuid** | **Guid?** | | [optional] **Password** | **string** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Model200Response.md b/samples/client/petstore/csharp/SwaggerClient/docs/Model200Response.md similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Model200Response.md rename to samples/client/petstore/csharp/SwaggerClient/docs/Model200Response.md diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/ModelReturn.md b/samples/client/petstore/csharp/SwaggerClient/docs/ModelReturn.md similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/ModelReturn.md rename to samples/client/petstore/csharp/SwaggerClient/docs/ModelReturn.md diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Name.md b/samples/client/petstore/csharp/SwaggerClient/docs/Name.md similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Name.md rename to samples/client/petstore/csharp/SwaggerClient/docs/Name.md diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Order.md b/samples/client/petstore/csharp/SwaggerClient/docs/Order.md similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Order.md rename to samples/client/petstore/csharp/SwaggerClient/docs/Order.md diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Pet.md b/samples/client/petstore/csharp/SwaggerClient/docs/Pet.md similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Pet.md rename to samples/client/petstore/csharp/SwaggerClient/docs/Pet.md diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/PetApi.md b/samples/client/petstore/csharp/SwaggerClient/docs/PetApi.md similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/PetApi.md rename to samples/client/petstore/csharp/SwaggerClient/docs/PetApi.md diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/SpecialModelName.md b/samples/client/petstore/csharp/SwaggerClient/docs/SpecialModelName.md similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/SpecialModelName.md rename to samples/client/petstore/csharp/SwaggerClient/docs/SpecialModelName.md diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/StoreApi.md b/samples/client/petstore/csharp/SwaggerClient/docs/StoreApi.md similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/StoreApi.md rename to samples/client/petstore/csharp/SwaggerClient/docs/StoreApi.md diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Tag.md b/samples/client/petstore/csharp/SwaggerClient/docs/Tag.md similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Tag.md rename to samples/client/petstore/csharp/SwaggerClient/docs/Tag.md diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/User.md b/samples/client/petstore/csharp/SwaggerClient/docs/User.md similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/User.md rename to samples/client/petstore/csharp/SwaggerClient/docs/User.md diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/UserApi.md b/samples/client/petstore/csharp/SwaggerClient/docs/UserApi.md similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/UserApi.md rename to samples/client/petstore/csharp/SwaggerClient/docs/UserApi.md diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/git_push.sh b/samples/client/petstore/csharp/SwaggerClient/git_push.sh similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/git_push.sh rename to samples/client/petstore/csharp/SwaggerClient/git_push.sh diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/FakeApiTests.cs new file mode 100644 index 00000000000..478311b649e --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/FakeApiTests.cs @@ -0,0 +1,80 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reflection; +using RestSharp; +using NUnit.Framework; + +using IO.Swagger.Client; +using IO.Swagger.Api; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing FakeApi + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the API endpoint. + /// + [TestFixture] + public class FakeApiTests + { + private FakeApi instance; + + /// + /// Setup before each unit test + /// + [SetUp] + public void Init() + { + instance = new FakeApi(); + } + + /// + /// Clean up after each unit test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of FakeApi + /// + [Test] + public void InstanceTest() + { + Assert.IsInstanceOf (instance, "instance is a FakeApi"); + } + + + /// + /// Test TestEndpointParameters + /// + [Test] + public void TestEndpointParametersTest() + { + // TODO: add unit test for the method 'TestEndpointParameters' + double? number = null; // TODO: replace null with proper value + double? _double = null; // TODO: replace null with proper value + string _string = null; // TODO: replace null with proper value + byte[] _byte = null; // TODO: replace null with proper value + int? integer = null; // TODO: replace null with proper value + int? int32 = null; // TODO: replace null with proper value + long? int64 = null; // TODO: replace null with proper value + float? _float = null; // TODO: replace null with proper value + byte[] binary = null; // TODO: replace null with proper value + DateTime? date = null; // TODO: replace null with proper value + DateTime? dateTime = null; // TODO: replace null with proper value + string password = null; // TODO: replace null with proper value + instance.TestEndpointParameters(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password); + + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/PetApiTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/PetApiTests.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/PetApiTests.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/PetApiTests.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/StoreApiTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/StoreApiTests.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/StoreApiTests.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/StoreApiTests.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/UserApiTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/UserApiTests.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/UserApiTests.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Api/UserApiTests.cs diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/IO.Swagger.Test.csproj b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/IO.Swagger.Test.csproj new file mode 100644 index 00000000000..de3b57cfe78 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/IO.Swagger.Test.csproj @@ -0,0 +1,73 @@ + + + + Debug + AnyCPU + {19F1DEBC-DE5E-4517-8062-F000CD499087} + Library + Properties + IO.Swagger.Test + IO.Swagger.Test + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + $(SolutionDir)\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll + ..\..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll + ..\..\vendor\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll + + + $(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll + ..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll + ..\..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll + ..\..\vendor\RestSharp.105.1.0\lib\net45\RestSharp.dll + + + $(SolutionDir)\packages\NUnit.2.6.3\lib\nunit.framework.dll + ..\packages\NUnit.2.6.3\lib\nunit.framework.dll + ..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll + ..\..\vendor\NUnit.2.6.3\lib\nunit.framework.dll + + + + + + + + + + + + {AC0D0300-7030-473F-B672-17C40187815A} + IO.Swagger + + + + diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/AnimalFarmTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/AnimalFarmTests.cs new file mode 100644 index 00000000000..5baa4d93485 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/AnimalFarmTests.cs @@ -0,0 +1,56 @@ +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing AnimalFarm + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class AnimalFarmTests + { + private AnimalFarm instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + instance = new AnimalFarm(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of AnimalFarm + /// + [Test] + public void AnimalFarmInstanceTest() + { + Assert.IsInstanceOf (instance, "instance is a AnimalFarm"); + } + + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/AnimalTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/AnimalTests.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/AnimalTests.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/AnimalTests.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/ApiResponseTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/ApiResponseTests.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/ApiResponseTests.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/ApiResponseTests.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/CatTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/CatTests.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/CatTests.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/CatTests.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/CategoryTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/CategoryTests.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/CategoryTests.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/CategoryTests.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/DogTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/DogTests.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/DogTests.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/DogTests.cs diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/EnumClassTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/EnumClassTests.cs new file mode 100644 index 00000000000..8c81c81fbb1 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/EnumClassTests.cs @@ -0,0 +1,56 @@ +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing EnumClass + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class EnumClassTests + { + private EnumClass instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + instance = new EnumClass(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of EnumClass + /// + [Test] + public void EnumClassInstanceTest() + { + Assert.IsInstanceOf (instance, "instance is a EnumClass"); + } + + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/EnumTestTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/EnumTestTests.cs new file mode 100644 index 00000000000..2679b085233 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/EnumTestTests.cs @@ -0,0 +1,80 @@ +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing EnumTest + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class EnumTestTests + { + private EnumTest instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + instance = new EnumTest(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of EnumTest + /// + [Test] + public void EnumTestInstanceTest() + { + Assert.IsInstanceOf (instance, "instance is a EnumTest"); + } + + /// + /// Test the property 'EnumString' + /// + [Test] + public void EnumStringTest() + { + // TODO: unit test for the property 'EnumString' + } + /// + /// Test the property 'EnumInteger' + /// + [Test] + public void EnumIntegerTest() + { + // TODO: unit test for the property 'EnumInteger' + } + /// + /// Test the property 'EnumNumber' + /// + [Test] + public void EnumNumberTest() + { + // TODO: unit test for the property 'EnumNumber' + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/FormatTestTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/FormatTestTests.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/FormatTestTests.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/FormatTestTests.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/Model200ResponseTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/Model200ResponseTests.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/Model200ResponseTests.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/Model200ResponseTests.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/ModelReturnTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/ModelReturnTests.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/ModelReturnTests.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/ModelReturnTests.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/NameTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/NameTests.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/NameTests.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/NameTests.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/OrderTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/OrderTests.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/OrderTests.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/OrderTests.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/PetTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/PetTests.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/PetTests.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/PetTests.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/SpecialModelNameTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/SpecialModelNameTests.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/SpecialModelNameTests.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/SpecialModelNameTests.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/TagTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/TagTests.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/TagTests.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/TagTests.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/UserTests.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/UserTests.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/UserTests.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/Model/UserTests.cs diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/packages.config b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/packages.config new file mode 100644 index 00000000000..a8a3491f63d --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger.Test/packages.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/FakeApi.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/FakeApi.cs new file mode 100644 index 00000000000..1c92dc3bbda --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/FakeApi.cs @@ -0,0 +1,418 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using RestSharp; +using IO.Swagger.Client; + +namespace IO.Swagger.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public interface IFakeApi + { + #region Synchronous Operations + /// + /// Fake endpoint for testing various parameters + /// + /// + /// Fake endpoint for testing various parameters + /// + /// Thrown when fails to make API call + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// + void TestEndpointParameters (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null); + + /// + /// Fake endpoint for testing various parameters + /// + /// + /// Fake endpoint for testing various parameters + /// + /// Thrown when fails to make API call + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// ApiResponse of Object(void) + ApiResponse TestEndpointParametersWithHttpInfo (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null); + #endregion Synchronous Operations + #region Asynchronous Operations + /// + /// Fake endpoint for testing various parameters + /// + /// + /// Fake endpoint for testing various parameters + /// + /// Thrown when fails to make API call + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// Task of void + System.Threading.Tasks.Task TestEndpointParametersAsync (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null); + + /// + /// Fake endpoint for testing various parameters + /// + /// + /// Fake endpoint for testing various parameters + /// + /// Thrown when fails to make API call + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// Task of ApiResponse + System.Threading.Tasks.Task> TestEndpointParametersAsyncWithHttpInfo (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null); + #endregion Asynchronous Operations + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class FakeApi : IFakeApi + { + /// + /// Initializes a new instance of the class. + /// + /// + public FakeApi(String basePath) + { + this.Configuration = new Configuration(new ApiClient(basePath)); + + // ensure API client has configuration ready + if (Configuration.ApiClient.Configuration == null) + { + this.Configuration.ApiClient.Configuration = this.Configuration; + } + } + + /// + /// Initializes a new instance of the class + /// using Configuration object + /// + /// An instance of Configuration + /// + public FakeApi(Configuration configuration = null) + { + if (configuration == null) // use the default one in Configuration + this.Configuration = Configuration.Default; + else + this.Configuration = configuration; + + // ensure API client has configuration ready + if (Configuration.ApiClient.Configuration == null) + { + this.Configuration.ApiClient.Configuration = this.Configuration; + } + } + + /// + /// Gets the base path of the API client. + /// + /// The base path + public String GetBasePath() + { + return this.Configuration.ApiClient.RestClient.BaseUrl.ToString(); + } + + /// + /// Sets the base path of the API client. + /// + /// The base path + [Obsolete("SetBasePath is deprecated, please do 'Configuraiton.ApiClient = new ApiClient(\"http://new-path\")' instead.")] + public void SetBasePath(String basePath) + { + // do nothing + } + + /// + /// Gets or sets the configuration object + /// + /// An instance of the Configuration + public Configuration Configuration {get; set;} + + /// + /// Gets the default header. + /// + /// Dictionary of HTTP header + [Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")] + public Dictionary DefaultHeader() + { + return this.Configuration.DefaultHeader; + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + [Obsolete("AddDefaultHeader is deprecated, please use Configuration.AddDefaultHeader instead.")] + public void AddDefaultHeader(string key, string value) + { + this.Configuration.AddDefaultHeader(key, value); + } + + /// + /// Fake endpoint for testing various parameters Fake endpoint for testing various parameters + /// + /// Thrown when fails to make API call + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// + public void TestEndpointParameters (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null) + { + TestEndpointParametersWithHttpInfo(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password); + } + + /// + /// Fake endpoint for testing various parameters Fake endpoint for testing various parameters + /// + /// Thrown when fails to make API call + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// ApiResponse of Object(void) + public ApiResponse TestEndpointParametersWithHttpInfo (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null) + { + // verify the required parameter 'number' is set + if (number == null) + throw new ApiException(400, "Missing required parameter 'number' when calling FakeApi->TestEndpointParameters"); + // verify the required parameter '_double' is set + if (_double == null) + throw new ApiException(400, "Missing required parameter '_double' when calling FakeApi->TestEndpointParameters"); + // verify the required parameter '_string' is set + if (_string == null) + throw new ApiException(400, "Missing required parameter '_string' when calling FakeApi->TestEndpointParameters"); + // verify the required parameter '_byte' is set + if (_byte == null) + throw new ApiException(400, "Missing required parameter '_byte' when calling FakeApi->TestEndpointParameters"); + + var localVarPath = "/fake"; + 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/xml", + "application/json" + }; + 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 (integer != null) localVarFormParams.Add("integer", Configuration.ApiClient.ParameterToString(integer)); // form parameter + if (int32 != null) localVarFormParams.Add("int32", Configuration.ApiClient.ParameterToString(int32)); // form parameter + if (int64 != null) localVarFormParams.Add("int64", Configuration.ApiClient.ParameterToString(int64)); // form parameter + if (number != null) localVarFormParams.Add("number", Configuration.ApiClient.ParameterToString(number)); // form parameter + if (_float != null) localVarFormParams.Add("float", Configuration.ApiClient.ParameterToString(_float)); // form parameter + if (_double != null) localVarFormParams.Add("double", Configuration.ApiClient.ParameterToString(_double)); // form parameter + if (_string != null) localVarFormParams.Add("string", Configuration.ApiClient.ParameterToString(_string)); // form parameter + if (_byte != null) localVarFormParams.Add("byte", Configuration.ApiClient.ParameterToString(_byte)); // form parameter + if (binary != null) localVarFormParams.Add("binary", Configuration.ApiClient.ParameterToString(binary)); // form parameter + if (date != null) localVarFormParams.Add("date", Configuration.ApiClient.ParameterToString(date)); // form parameter + if (dateTime != null) localVarFormParams.Add("dateTime", Configuration.ApiClient.ParameterToString(dateTime)); // form parameter + if (password != null) localVarFormParams.Add("password", Configuration.ApiClient.ParameterToString(password)); // form parameter + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (localVarStatusCode >= 400) + throw new ApiException (localVarStatusCode, "Error calling TestEndpointParameters: " + localVarResponse.Content, localVarResponse.Content); + else if (localVarStatusCode == 0) + throw new ApiException (localVarStatusCode, "Error calling TestEndpointParameters: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage); + + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + /// + /// Fake endpoint for testing various parameters Fake endpoint for testing various parameters + /// + /// Thrown when fails to make API call + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// Task of void + public async System.Threading.Tasks.Task TestEndpointParametersAsync (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null) + { + await TestEndpointParametersAsyncWithHttpInfo(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password); + + } + + /// + /// Fake endpoint for testing various parameters Fake endpoint for testing various parameters + /// + /// Thrown when fails to make API call + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// Task of ApiResponse + public async System.Threading.Tasks.Task> TestEndpointParametersAsyncWithHttpInfo (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null) + { + // verify the required parameter 'number' is set + if (number == null) + throw new ApiException(400, "Missing required parameter 'number' when calling FakeApi->TestEndpointParameters"); + // verify the required parameter '_double' is set + if (_double == null) + throw new ApiException(400, "Missing required parameter '_double' when calling FakeApi->TestEndpointParameters"); + // verify the required parameter '_string' is set + if (_string == null) + throw new ApiException(400, "Missing required parameter '_string' when calling FakeApi->TestEndpointParameters"); + // verify the required parameter '_byte' is set + if (_byte == null) + throw new ApiException(400, "Missing required parameter '_byte' when calling FakeApi->TestEndpointParameters"); + + var localVarPath = "/fake"; + 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/xml", + "application/json" + }; + 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 (integer != null) localVarFormParams.Add("integer", Configuration.ApiClient.ParameterToString(integer)); // form parameter + if (int32 != null) localVarFormParams.Add("int32", Configuration.ApiClient.ParameterToString(int32)); // form parameter + if (int64 != null) localVarFormParams.Add("int64", Configuration.ApiClient.ParameterToString(int64)); // form parameter + if (number != null) localVarFormParams.Add("number", Configuration.ApiClient.ParameterToString(number)); // form parameter + if (_float != null) localVarFormParams.Add("float", Configuration.ApiClient.ParameterToString(_float)); // form parameter + if (_double != null) localVarFormParams.Add("double", Configuration.ApiClient.ParameterToString(_double)); // form parameter + if (_string != null) localVarFormParams.Add("string", Configuration.ApiClient.ParameterToString(_string)); // form parameter + if (_byte != null) localVarFormParams.Add("byte", Configuration.ApiClient.ParameterToString(_byte)); // form parameter + if (binary != null) localVarFormParams.Add("binary", Configuration.ApiClient.ParameterToString(binary)); // form parameter + if (date != null) localVarFormParams.Add("date", Configuration.ApiClient.ParameterToString(date)); // form parameter + if (dateTime != null) localVarFormParams.Add("dateTime", Configuration.ApiClient.ParameterToString(dateTime)); // form parameter + if (password != null) localVarFormParams.Add("password", Configuration.ApiClient.ParameterToString(password)); // form parameter + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (localVarStatusCode >= 400) + throw new ApiException (localVarStatusCode, "Error calling TestEndpointParameters: " + localVarResponse.Content, localVarResponse.Content); + else if (localVarStatusCode == 0) + throw new ApiException (localVarStatusCode, "Error calling TestEndpointParameters: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage); + + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + } +} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/PetApi.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/PetApi.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/StoreApi.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/StoreApi.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/UserApi.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/UserApi.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Client/ApiClient.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Client/ApiClient.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiException.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Client/ApiException.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiException.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Client/ApiException.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiResponse.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Client/ApiResponse.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiResponse.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Client/ApiResponse.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Client/Configuration.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Client/Configuration.cs diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/IO.Swagger.csproj b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/IO.Swagger.csproj new file mode 100644 index 00000000000..5d9a64329c1 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/IO.Swagger.csproj @@ -0,0 +1,61 @@ + + + + Debug + AnyCPU + {AC0D0300-7030-473F-B672-17C40187815A} + Library + Properties + Swagger Library + Swagger Library + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + $(SolutionDir)\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll + ..\..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll + ..\..\vendor\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll + + + $(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll + ..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll + ..\..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll + ..\..\vendor\RestSharp.105.1.0\lib\net45\RestSharp.dll + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Animal.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Animal.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Animal.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Animal.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Task.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/AnimalFarm.cs similarity index 61% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Task.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/AnimalFarm.cs index b2182f2f712..76685fe8495 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Task.cs +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/AnimalFarm.cs @@ -12,31 +12,20 @@ using Newtonsoft.Json.Converters; namespace IO.Swagger.Model { /// - /// + /// AnimalFarm /// [DataContract] - public partial class Task : IEquatable - { - + public partial class AnimalFarm : List, IEquatable + { /// - /// Initializes a new instance of the class. - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// _Return. - - public Task(int? _Return = null) + public AnimalFarm() { - this._Return = _Return; + } - - /// - /// Gets or Sets _Return - /// - [DataMember(Name="return", EmitDefaultValue=false)] - public int? _Return { get; set; } - /// /// Returns the string presentation of the object /// @@ -44,10 +33,8 @@ namespace IO.Swagger.Model public override string ToString() { var sb = new StringBuilder(); - sb.Append("class Task {\n"); - sb.Append(" _Return: ").Append(_Return).Append("\n"); - - sb.Append("}\n"); + sb.Append("class AnimalFarm {\n"); + sb.Append("}\n"); return sb.ToString(); } @@ -55,7 +42,7 @@ namespace IO.Swagger.Model /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public string ToJson() + public new string ToJson() { return JsonConvert.SerializeObject(this, Formatting.Indented); } @@ -68,26 +55,21 @@ namespace IO.Swagger.Model public override bool Equals(object obj) { // credit: http://stackoverflow.com/a/10454552/677735 - return this.Equals(obj as Task); + return this.Equals(obj as AnimalFarm); } /// - /// Returns true if Task instances are equal + /// Returns true if AnimalFarm instances are equal /// - /// Instance of Task to be compared + /// Instance of AnimalFarm to be compared /// Boolean - public bool Equals(Task other) + public bool Equals(AnimalFarm other) { // credit: http://stackoverflow.com/a/10454552/677735 if (other == null) return false; - return - ( - this._Return == other._Return || - this._Return != null && - this._Return.Equals(other._Return) - ); + return false; } /// @@ -101,13 +83,9 @@ namespace IO.Swagger.Model { int hash = 41; // Suitable nullity checks etc, of course :) - - if (this._Return != null) - hash = hash * 59 + this._Return.GetHashCode(); - return hash; } } - } + } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/ApiResponse.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/ApiResponse.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/ApiResponse.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/ApiResponse.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Cat.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Cat.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Cat.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Cat.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Category.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Category.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Dog.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Dog.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Dog.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Dog.cs diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/EnumClass.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/EnumClass.cs new file mode 100644 index 00000000000..1fb5f0b6626 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/EnumClass.cs @@ -0,0 +1,40 @@ +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; +using Newtonsoft.Json.Converters; + +namespace IO.Swagger.Model +{ + /// + /// Gets or Sets EnumClass + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum EnumClass + { + + /// + /// Enum Abc for "_abc" + /// + [EnumMember(Value = "_abc")] + Abc, + + /// + /// Enum efg for "-efg" + /// + [EnumMember(Value = "-efg")] + efg, + + /// + /// Enum xyz for "(xyz)" + /// + [EnumMember(Value = "(xyz)")] + xyz + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/EnumTest.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/EnumTest.cs new file mode 100644 index 00000000000..f8bebd6b2d7 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/EnumTest.cs @@ -0,0 +1,199 @@ +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; +using Newtonsoft.Json.Converters; + +namespace IO.Swagger.Model +{ + /// + /// EnumTest + /// + [DataContract] + public partial class EnumTest : IEquatable + { + /// + /// Gets or Sets EnumString + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum EnumStringEnum + { + + /// + /// Enum Upper for "UPPER" + /// + [EnumMember(Value = "UPPER")] + Upper, + + /// + /// Enum Lower for "lower" + /// + [EnumMember(Value = "lower")] + Lower + } + + /// + /// Gets or Sets EnumInteger + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum EnumIntegerEnum + { + + /// + /// Enum NUMBER_1 for 1 + /// + [EnumMember(Value = "1")] + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for -1 + /// + [EnumMember(Value = "-1")] + NUMBER_MINUS_1 = -1 + } + + /// + /// Gets or Sets EnumNumber + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum EnumNumberEnum + { + + /// + /// Enum NUMBER_1_DOT_1 for 1.1 + /// + [EnumMember(Value = "1.1")] + NUMBER_1_DOT_1, + + /// + /// Enum NUMBER_MINUS_1_DOT_2 for -1.2 + /// + [EnumMember(Value = "-1.2")] + NUMBER_MINUS_1_DOT_2 + } + + /// + /// Gets or Sets EnumString + /// + [DataMember(Name="enum_string", EmitDefaultValue=false)] + public EnumStringEnum? EnumString { get; set; } + /// + /// Gets or Sets EnumInteger + /// + [DataMember(Name="enum_integer", EmitDefaultValue=false)] + public EnumIntegerEnum? EnumInteger { get; set; } + /// + /// Gets or Sets EnumNumber + /// + [DataMember(Name="enum_number", EmitDefaultValue=false)] + public EnumNumberEnum? EnumNumber { get; set; } + /// + /// Initializes a new instance of the class. + /// + /// EnumString. + /// EnumInteger. + /// EnumNumber. + public EnumTest(EnumStringEnum? EnumString = null, EnumIntegerEnum? EnumInteger = null, EnumNumberEnum? EnumNumber = null) + { + + + this.EnumString = EnumString; + + this.EnumInteger = EnumInteger; + + this.EnumNumber = EnumNumber; + + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class EnumTest {\n"); + sb.Append(" EnumString: ").Append(EnumString).Append("\n"); +sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n"); +sb.Append(" EnumNumber: ").Append(EnumNumber).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 EnumTest); + } + + /// + /// Returns true if EnumTest instances are equal + /// + /// Instance of EnumTest to be compared + /// Boolean + public bool Equals(EnumTest other) + { + // credit: http://stackoverflow.com/a/10454552/677735 + if (other == null) + return false; + + return + ( + this.EnumString == other.EnumString || + this.EnumString != null && + this.EnumString.Equals(other.EnumString) + ) && + ( + this.EnumInteger == other.EnumInteger || + this.EnumInteger != null && + this.EnumInteger.Equals(other.EnumInteger) + ) && + ( + this.EnumNumber == other.EnumNumber || + this.EnumNumber != null && + this.EnumNumber.Equals(other.EnumNumber) + ); + } + + /// + /// 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.EnumString != null) + hash = hash * 59 + this.EnumString.GetHashCode(); + if (this.EnumInteger != null) + hash = hash * 59 + this.EnumInteger.GetHashCode(); + if (this.EnumNumber != null) + hash = hash * 59 + this.EnumNumber.GetHashCode(); + return hash; + } + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/FormatTest.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/FormatTest.cs similarity index 94% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/FormatTest.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/FormatTest.cs index c5a99d45af0..33301f02a95 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/FormatTest.cs +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/FormatTest.cs @@ -31,8 +31,9 @@ namespace IO.Swagger.Model /// Binary. /// Date (required). /// DateTime. + /// Uuid. /// Password (required). - public FormatTest(int? Integer = null, int? Int32 = null, long? Int64 = null, double? Number = null, float? _Float = null, double? _Double = null, string _String = null, byte[] _Byte = null, byte[] Binary = null, DateTime? Date = null, DateTime? DateTime = null, string Password = null) + public FormatTest(int? Integer = null, int? Int32 = null, long? Int64 = null, double? Number = null, float? _Float = null, double? _Double = null, string _String = null, byte[] _Byte = null, byte[] Binary = null, DateTime? Date = null, DateTime? DateTime = null, Guid? Uuid = null, string Password = null) { // to ensure "Number" is required (not null) if (Number == null) @@ -88,6 +89,8 @@ namespace IO.Swagger.Model this.DateTime = DateTime; + this.Uuid = Uuid; + } /// @@ -146,6 +149,11 @@ namespace IO.Swagger.Model [DataMember(Name="dateTime", EmitDefaultValue=false)] public DateTime? DateTime { get; set; } /// + /// Gets or Sets Uuid + /// + [DataMember(Name="uuid", EmitDefaultValue=false)] + public Guid? Uuid { get; set; } + /// /// Gets or Sets Password /// [DataMember(Name="password", EmitDefaultValue=false)] @@ -169,6 +177,7 @@ sb.Append(" _Byte: ").Append(_Byte).Append("\n"); sb.Append(" Binary: ").Append(Binary).Append("\n"); sb.Append(" Date: ").Append(Date).Append("\n"); sb.Append(" DateTime: ").Append(DateTime).Append("\n"); +sb.Append(" Uuid: ").Append(Uuid).Append("\n"); sb.Append(" Password: ").Append(Password).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -261,6 +270,11 @@ sb.Append(" Password: ").Append(Password).Append("\n"); this.DateTime != null && this.DateTime.Equals(other.DateTime) ) && + ( + this.Uuid == other.Uuid || + this.Uuid != null && + this.Uuid.Equals(other.Uuid) + ) && ( this.Password == other.Password || this.Password != null && @@ -301,6 +315,8 @@ sb.Append(" Password: ").Append(Password).Append("\n"); hash = hash * 59 + this.Date.GetHashCode(); if (this.DateTime != null) hash = hash * 59 + this.DateTime.GetHashCode(); + if (this.Uuid != null) + hash = hash * 59 + this.Uuid.GetHashCode(); if (this.Password != null) hash = hash * 59 + this.Password.GetHashCode(); return hash; diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Model200Response.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Model200Response.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Model200Response.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Model200Response.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/ModelReturn.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/ModelReturn.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/ModelReturn.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/ModelReturn.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Name.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Name.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Name.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Name.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Order.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Order.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Pet.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Pet.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/SpecialModelName.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/SpecialModelName.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/SpecialModelName.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/SpecialModelName.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Tag.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Tag.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/User.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/User.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Properties/AssemblyInfo.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Properties/AssemblyInfo.cs similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Properties/AssemblyInfo.cs rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Properties/AssemblyInfo.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/vendor/packages.config b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/packages.config similarity index 100% rename from samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/vendor/packages.config rename to samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/packages.config diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/InlineResponse200Tests.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/InlineResponse200Tests.cs deleted file mode 100644 index a4930b02df3..00000000000 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/InlineResponse200Tests.cs +++ /dev/null @@ -1,104 +0,0 @@ -using NUnit.Framework; - -using System; -using System.Linq; -using System.IO; -using System.Collections.Generic; -using IO.Swagger.Api; -using IO.Swagger.Model; -using IO.Swagger.Client; -using System.Reflection; - -namespace IO.Swagger.Test -{ - /// - /// Class for testing InlineResponse200 - /// - /// - /// This file is automatically generated by Swagger Codegen. - /// Please update the test case below to test the model. - /// - [TestFixture] - public class InlineResponse200Tests - { - private InlineResponse200 instance; - - /// - /// Setup before each test - /// - [SetUp] - public void Init() - { - instance = new InlineResponse200(); - } - - /// - /// Clean up after each test - /// - [TearDown] - public void Cleanup() - { - - } - - /// - /// Test an instance of InlineResponse200 - /// - [Test] - public void InlineResponse200InstanceTest() - { - Assert.IsInstanceOf (instance, "instance is a InlineResponse200"); - } - - /// - /// Test the property 'PhotoUrls' - /// - [Test] - public void PhotoUrlsTest() - { - // TODO: unit test for the property 'PhotoUrls' - } - /// - /// Test the property 'Name' - /// - [Test] - public void NameTest() - { - // TODO: unit test for the property 'Name' - } - /// - /// Test the property 'Id' - /// - [Test] - public void IdTest() - { - // TODO: unit test for the property 'Id' - } - /// - /// Test the property 'Category' - /// - [Test] - public void CategoryTest() - { - // TODO: unit test for the property 'Category' - } - /// - /// Test the property 'Tags' - /// - [Test] - public void TagsTest() - { - // TODO: unit test for the property 'Tags' - } - /// - /// Test the property 'Status' - /// - [Test] - public void StatusTest() - { - // TODO: unit test for the property 'Status' - } - - } - -} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/README.mustache b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/README.mustache deleted file mode 100644 index 6a7b6cd5e3c..00000000000 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/README.mustache +++ /dev/null @@ -1,184 +0,0 @@ - - the C# library for the Swagger Petstore - - This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters - -This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: - -- API version: 1.0.0 -- Package version: -- Build date: 2016-04-14T06:55:47.468-04:00 -- Build package: class io.swagger.codegen.languages.CSharpClientCodegen - -## Frameworks supported -- .NET 4.0 or later -- Windows Phone 7.1 (Mango) - -## Dependencies -- [RestSharp] (https://www.nuget.org/packages/RestSharp) - 105.1.0 or later -- [Json.NET] (https://www.nuget.org/packages/Newtonsoft.Json/) - 7.0.0 or later - -The DLLs included in the package may not be the latest version. We recommned using [NuGet] (https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages: -``` -Install-Package RestSharp -Install-Package Newtonsoft.Json -``` - -NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742) - -## Installation -Run the following command to generate the DLL -- [Mac/Linux] compile-mono.sh -- [Windows] compile.bat - -Then include the DLL (under the `bin` folder) in the C# project - - -```csharp -using System; -using System.Diagnostics; -using IO.Swagger.Api; -using IO.Swagger.Client; -using IO.Swagger.Module; - -namespace Example -{ -public class Example -{ -public void main(){ - - // Configure OAuth2 access token for authorization: petstore_auth - Configuration.Default.AccessToken = 'YOUR_ACCESS_TOKEN'; - // Configure API key authorization: test_api_client_id - Configuration.Default.ApiKey.Add('x-test_api_client_id', 'YOUR_API_KEY'); - // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed - // Configuration.Default.ApiKeyPrefix.Add('x-test_api_client_id', 'Bearer'); - // Configure API key authorization: test_api_client_secret - Configuration.Default.ApiKey.Add('x-test_api_client_secret', 'YOUR_API_KEY'); - // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed - // Configuration.Default.ApiKeyPrefix.Add('x-test_api_client_secret', 'Bearer'); - // Configure API key authorization: api_key - Configuration.Default.ApiKey.Add('api_key', 'YOUR_API_KEY'); - // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed - // Configuration.Default.ApiKeyPrefix.Add('api_key', 'Bearer'); - // Configure HTTP basic authorization: test_http_basic - Configuration.Default.Username = 'YOUR_USERNAME'; - Configuration.Default.Password = 'YOUR_PASSWORD'; - // Configure API key authorization: test_api_key_query - Configuration.Default.ApiKey.Add('test_api_key_query', 'YOUR_API_KEY'); - // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed - // Configuration.Default.ApiKeyPrefix.Add('test_api_key_query', 'Bearer'); - // Configure API key authorization: test_api_key_header - Configuration.Default.ApiKey.Add('test_api_key_header', 'YOUR_API_KEY'); - // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed - // Configuration.Default.ApiKeyPrefix.Add('test_api_key_header', 'Bearer'); - -var apiInstance = new (); - -try { -apiInstance.(); -} catch (Exception e) { -Debug.Print("Exception when calling .: " + e.Message ); -} -} -} -} -``` - -## Documentation for API Endpoints - -All URIs are relative to *http://petstore.swagger.io/v2* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -*::PetApi* | [**AddPet**](docs/PetApi.md#AddPet) | **POST** /pet | Add a new pet to the store -*::PetApi* | [**AddPetUsingByteArray**](docs/PetApi.md#AddPetUsingByteArray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store -*::PetApi* | [**DeletePet**](docs/PetApi.md#DeletePet) | **DELETE** /pet/{petId} | Deletes a pet -*::PetApi* | [**FindPetsByStatus**](docs/PetApi.md#FindPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status -*::PetApi* | [**FindPetsByTags**](docs/PetApi.md#FindPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags -*::PetApi* | [**GetPetById**](docs/PetApi.md#GetPetById) | **GET** /pet/{petId} | Find pet by ID -*::PetApi* | [**GetPetByIdInObject**](docs/PetApi.md#GetPetByIdInObject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -*::PetApi* | [**PetPetIdtestingByteArraytrueGet**](docs/PetApi.md#PetPetIdtestingByteArraytrueGet) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' -*::PetApi* | [**UpdatePet**](docs/PetApi.md#UpdatePet) | **PUT** /pet | Update an existing pet -*::PetApi* | [**UpdatePetWithForm**](docs/PetApi.md#UpdatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data -*::PetApi* | [**UploadFile**](docs/PetApi.md#UploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image -*::StoreApi* | [**DeleteOrder**](docs/StoreApi.md#DeleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -*::StoreApi* | [**FindOrdersByStatus**](docs/StoreApi.md#FindOrdersByStatus) | **GET** /store/findByStatus | Finds orders by status -*::StoreApi* | [**GetInventory**](docs/StoreApi.md#GetInventory) | **GET** /store/inventory | Returns pet inventories by status -*::StoreApi* | [**GetInventoryInObject**](docs/StoreApi.md#GetInventoryInObject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' -*::StoreApi* | [**GetOrderById**](docs/StoreApi.md#GetOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID -*::StoreApi* | [**PlaceOrder**](docs/StoreApi.md#PlaceOrder) | **POST** /store/order | Place an order for a pet -*::UserApi* | [**CreateUser**](docs/UserApi.md#CreateUser) | **POST** /user | Create user -*::UserApi* | [**CreateUsersWithArrayInput**](docs/UserApi.md#CreateUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array -*::UserApi* | [**CreateUsersWithListInput**](docs/UserApi.md#CreateUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array -*::UserApi* | [**DeleteUser**](docs/UserApi.md#DeleteUser) | **DELETE** /user/{username} | Delete user -*::UserApi* | [**GetUserByName**](docs/UserApi.md#GetUserByName) | **GET** /user/{username} | Get user by user name -*::UserApi* | [**LoginUser**](docs/UserApi.md#LoginUser) | **GET** /user/login | Logs user into the system -*::UserApi* | [**LogoutUser**](docs/UserApi.md#LogoutUser) | **GET** /user/logout | Logs out current logged in user session -*::UserApi* | [**UpdateUser**](docs/UserApi.md#UpdateUser) | **PUT** /user/{username} | Updated user - - -## Documentation for Models - - - [::Animal](docs/Animal.md) - - [::Cat](docs/Cat.md) - - [::Category](docs/Category.md) - - [::Dog](docs/Dog.md) - - [::FormatTest](docs/FormatTest.md) - - [::InlineResponse200](docs/InlineResponse200.md) - - [::Model200Response](docs/Model200Response.md) - - [::ModelReturn](docs/ModelReturn.md) - - [::Name](docs/Name.md) - - [::Order](docs/Order.md) - - [::Pet](docs/Pet.md) - - [::SpecialModelName](docs/SpecialModelName.md) - - [::Tag](docs/Tag.md) - - [::User](docs/User.md) - - -## Documentation for Authorization - - -### petstore_auth - -- **Type**: OAuth -- **Flow**: implicit -- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog -- **Scopes**: - - write:pets: modify pets in your account - - read:pets: read your pets - -### test_api_client_id - -- **Type**: API key -- **API key parameter name**: x-test_api_client_id -- **Location**: HTTP header - -### test_api_client_secret - -- **Type**: API key -- **API key parameter name**: x-test_api_client_secret -- **Location**: HTTP header - -### api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - -### test_http_basic - -- **Type**: HTTP basic authentication - -### test_api_key_query - -- **Type**: API key -- **API key parameter name**: test_api_key_query -- **Location**: URL query string - -### test_api_key_header - -- **Type**: API key -- **API key parameter name**: test_api_key_header -- **Location**: HTTP header - - diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/bin/Newtonsoft.Json.dll b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/bin/Newtonsoft.Json.dll deleted file mode 100644 index 4d42dd9c5fe..00000000000 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/bin/Newtonsoft.Json.dll and /dev/null differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/bin/RestSharp.dll b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/bin/RestSharp.dll deleted file mode 100644 index 59d82f94198..00000000000 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/bin/RestSharp.dll and /dev/null differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile.bat b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile.bat deleted file mode 100644 index 8d07d021131..00000000000 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile.bat +++ /dev/null @@ -1,14 +0,0 @@ -@echo off - -SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319 - - -if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://nuget.org/nuget.exe', '.\nuget.exe')" -.\nuget.exe install vendor/packages.config -o vendor - -if not exist ".\bin" mkdir bin - -copy vendor\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll bin\Newtonsoft.Json.dll -copy vendor\RestSharp.105.1.0\lib\net45\RestSharp.dll bin\RestSharp.dll - -%CSCPATH%\csc /reference:bin\Newtonsoft.Json.dll;bin\RestSharp.dll /target:library /out:bin\IO.Swagger.dll /recurse:src\*.cs /doc:bin\IO.Swagger.xml diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/InlineResponse200.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/InlineResponse200.md deleted file mode 100644 index 6380096b06b..00000000000 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/InlineResponse200.md +++ /dev/null @@ -1,14 +0,0 @@ -# InlineResponse200 - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**PhotoUrls** | **List<string>** | | [optional] -**Name** | **string** | | [optional] -**Id** | **long?** | | -**Category** | **Object** | | [optional] -**Tags** | [**List<Tag>**](Tag.md) | | [optional] -**Status** | **string** | pet status in the store | [optional] - - diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/petstore b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/petstore deleted file mode 100644 index e69de29bb2d..00000000000 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 deleted file mode 100644 index 32d3db25e58..00000000000 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/InlineResponse200.cs +++ /dev/null @@ -1,235 +0,0 @@ -using System; -using System.Linq; -using System.IO; -using System.Text; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.ComponentModel; -using System.Runtime.Serialization; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; - -namespace IO.Swagger.Model -{ - /// - /// InlineResponse200 - /// - [DataContract] - public partial class InlineResponse200 : IEquatable - { - /// - /// pet status in the store - /// - /// pet status in the store - [JsonConverter(typeof(StringEnumConverter))] - public enum StatusEnum - { - - /// - /// Enum Available for "available" - /// - [EnumMember(Value = "available")] - Available, - - /// - /// Enum Pending for "pending" - /// - [EnumMember(Value = "pending")] - Pending, - - /// - /// Enum Sold for "sold" - /// - [EnumMember(Value = "sold")] - Sold - } - - - /// - /// pet status in the store - /// - /// pet status in the store - [DataMember(Name="status", EmitDefaultValue=false)] - public StatusEnum? Status { get; set; } - - /// - /// Initializes a new instance of the class. - /// Initializes a new instance of the class. - /// - /// Tags. - /// Id (required). - /// Category. - /// pet status in the store. - /// Name. - /// PhotoUrls. - - public InlineResponse200(List Tags = null, long? Id = null, Object Category = null, StatusEnum? Status = null, string Name = null, List PhotoUrls = 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.Tags = Tags; - this.Category = Category; - this.Status = Status; - this.Name = Name; - this.PhotoUrls = PhotoUrls; - - } - - - /// - /// Gets or Sets Tags - /// - [DataMember(Name="tags", EmitDefaultValue=false)] - public List Tags { get; set; } - - /// - /// 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; } - - /// - /// Gets or Sets PhotoUrls - /// - [DataMember(Name="photoUrls", EmitDefaultValue=false)] - public List PhotoUrls { 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(" Tags: ").Append(Tags).Append("\n"); - sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" Category: ").Append(Category).Append("\n"); - sb.Append(" Status: ").Append(Status).Append("\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" PhotoUrls: ").Append(PhotoUrls).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.Tags == other.Tags || - this.Tags != null && - this.Tags.SequenceEqual(other.Tags) - ) && - ( - 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.Status == other.Status || - this.Status != null && - this.Status.Equals(other.Status) - ) && - ( - this.Name == other.Name || - this.Name != null && - this.Name.Equals(other.Name) - ) && - ( - this.PhotoUrls == other.PhotoUrls || - this.PhotoUrls != null && - this.PhotoUrls.SequenceEqual(other.PhotoUrls) - ); - } - - /// - /// 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.Tags != null) - hash = hash * 59 + this.Tags.GetHashCode(); - - if (this.Id != null) - hash = hash * 59 + this.Id.GetHashCode(); - - if (this.Category != null) - hash = hash * 59 + this.Category.GetHashCode(); - - if (this.Status != null) - hash = hash * 59 + this.Status.GetHashCode(); - - if (this.Name != null) - hash = hash * 59 + this.Name.GetHashCode(); - - if (this.PhotoUrls != null) - hash = hash * 59 + this.PhotoUrls.GetHashCode(); - - return hash; - } - } - } - -} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/ObjectReturn.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/ObjectReturn.cs deleted file mode 100644 index 1ea3dea45c5..00000000000 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/ObjectReturn.cs +++ /dev/null @@ -1,113 +0,0 @@ -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; -using Newtonsoft.Json.Converters; - -namespace IO.Swagger.Model -{ - /// - /// - /// - [DataContract] - public partial class ObjectReturn : IEquatable - { - - /// - /// Initializes a new instance of the class. - /// Initializes a new instance of the class. - /// - /// _Return. - - public ObjectReturn(int? _Return = null) - { - this._Return = _Return; - - } - - - /// - /// Gets or Sets _Return - /// - [DataMember(Name="return", EmitDefaultValue=false)] - public int? _Return { 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 ObjectReturn {\n"); - sb.Append(" _Return: ").Append(_Return).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 ObjectReturn); - } - - /// - /// Returns true if ObjectReturn instances are equal - /// - /// Instance of ObjectReturn to be compared - /// Boolean - public bool Equals(ObjectReturn other) - { - // credit: http://stackoverflow.com/a/10454552/677735 - if (other == null) - return false; - - return - ( - this._Return == other._Return || - this._Return != null && - this._Return.Equals(other._Return) - ); - } - - /// - /// 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._Return != null) - hash = hash * 59 + this._Return.GetHashCode(); - - return hash; - } - } - - } -} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj index 389c142e1bd..c7be212db66 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj @@ -30,7 +30,10 @@ - Lib\SwaggerClient\bin\Newtonsoft.Json.dll + packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll + + + packages\RestSharp.105.1.0\lib\net45\RestSharp.dll @@ -38,56 +41,31 @@ packages\NUnit.2.6.4\lib\nunit.framework.dll - - Lib\SwaggerClient\bin\RestSharp.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + - \ No newline at end of file + + + {0862164F-97E9-4226-B458-E09905B21F2F} + IO.Swagger + + + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.sln b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.sln index dfb6e762ce2..5274859c30a 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.sln +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.sln @@ -3,12 +3,18 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SwaggerClientTest", "SwaggerClientTest.csproj", "{1011E844-3414-4D65-BF1F-7C8CE0167174}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "..\SwaggerClient\src\IO.Swagger\IO.Swagger.csproj", "{0862164F-97E9-4226-B458-E09905B21F2F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0862164F-97E9-4226-B458-E09905B21F2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0862164F-97E9-4226-B458-E09905B21F2F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0862164F-97E9-4226-B458-E09905B21F2F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0862164F-97E9-4226-B458-E09905B21F2F}.Release|Any CPU.Build.0 = Release|Any CPU {1011E844-3414-4D65-BF1F-7C8CE0167174}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1011E844-3414-4D65-BF1F-7C8CE0167174}.Debug|Any CPU.Build.0 = Debug|Any CPU {1011E844-3414-4D65-BF1F-7C8CE0167174}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs index eb976117be8..b87503528b6 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs @@ -1,11 +1,11 @@  - + - - - - + + + + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt new file mode 100644 index 00000000000..fe5b5e6a930 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt @@ -0,0 +1,11 @@ +/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs +/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.swagger-logo.png +/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb +/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll +/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll +/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb +/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll +/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll +/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll +/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Swagger Library.dll +/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Swagger Library.dll.mdb diff --git a/samples/client/petstore/csharp/SwaggerClientTest/packages.config b/samples/client/petstore/csharp/SwaggerClientTest/packages.config index 09300da2fcd..0a536655794 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/packages.config +++ b/samples/client/petstore/csharp/SwaggerClientTest/packages.config @@ -1,4 +1,6 @@  + + \ No newline at end of file diff --git a/samples/client/petstore/csharp/SwaggerClientTest/packages/repositories.config b/samples/client/petstore/csharp/SwaggerClientTest/packages/repositories.config index ba8d0d576a8..c109c8ad2e5 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/packages/repositories.config +++ b/samples/client/petstore/csharp/SwaggerClientTest/packages/repositories.config @@ -1,4 +1,5 @@ - - - + + + + \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index c5eb1f7ef3e..f70ceaa65f0 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -171,7 +171,7 @@ func (a PetApi) DeletePet(petId int64, apiKey string) (*APIResponse, error) { * @param status Status values that need to be considered for filter * @return []Pet */ -func (a PetApi) FindPetsByStatus(status []string) (*[]Pet, *APIResponse, error) { +func (a PetApi) FindPetsByStatus(status []string) ([]Pet, *APIResponse, error) { var httpMethod = "Get" // create path and map variables @@ -179,7 +179,7 @@ func (a PetApi) FindPetsByStatus(status []string) (*[]Pet, *APIResponse, error) // verify the required parameter 'status' is set if &status == nil { - return new([]Pet), nil, errors.New("Missing required parameter 'status' when calling PetApi->FindPetsByStatus") + return *new([]Pet), nil, errors.New("Missing required parameter 'status' when calling PetApi->FindPetsByStatus") } headerParams := make(map[string]string) @@ -224,10 +224,10 @@ func (a PetApi) FindPetsByStatus(status []string) (*[]Pet, *APIResponse, error) var successPayload = new([]Pet) httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return successPayload, NewAPIResponse(httpResponse.RawResponse), err + return *successPayload, NewAPIResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return successPayload, NewAPIResponse(httpResponse.RawResponse), err + return *successPayload, NewAPIResponse(httpResponse.RawResponse), err } /** @@ -237,7 +237,7 @@ func (a PetApi) FindPetsByStatus(status []string) (*[]Pet, *APIResponse, error) * @param tags Tags to filter by * @return []Pet */ -func (a PetApi) FindPetsByTags(tags []string) (*[]Pet, *APIResponse, error) { +func (a PetApi) FindPetsByTags(tags []string) ([]Pet, *APIResponse, error) { var httpMethod = "Get" // create path and map variables @@ -245,7 +245,7 @@ func (a PetApi) FindPetsByTags(tags []string) (*[]Pet, *APIResponse, error) { // verify the required parameter 'tags' is set if &tags == nil { - return new([]Pet), nil, errors.New("Missing required parameter 'tags' when calling PetApi->FindPetsByTags") + return *new([]Pet), nil, errors.New("Missing required parameter 'tags' when calling PetApi->FindPetsByTags") } headerParams := make(map[string]string) @@ -290,10 +290,10 @@ func (a PetApi) FindPetsByTags(tags []string) (*[]Pet, *APIResponse, error) { var successPayload = new([]Pet) httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return successPayload, NewAPIResponse(httpResponse.RawResponse), err + return *successPayload, NewAPIResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return successPayload, NewAPIResponse(httpResponse.RawResponse), err + return *successPayload, NewAPIResponse(httpResponse.RawResponse), err } /** @@ -301,7 +301,7 @@ func (a PetApi) FindPetsByTags(tags []string) (*[]Pet, *APIResponse, error) { * Returns a single pet * * @param petId ID of pet to return - * @return Pet + * @return *Pet */ func (a PetApi) GetPetById(petId int64) (*Pet, *APIResponse, error) { @@ -501,7 +501,7 @@ func (a PetApi) UpdatePetWithForm(petId int64, name string, status string) (*API * @param petId ID of pet to update * @param additionalMetadata Additional data to pass to server * @param file file to upload - * @return ModelApiResponse + * @return *ModelApiResponse */ func (a PetApi) UploadFile(petId int64, additionalMetadata string, file *os.File) (*ModelApiResponse, *APIResponse, error) { diff --git a/samples/client/petstore/go/go-petstore/store_api.go b/samples/client/petstore/go/go-petstore/store_api.go index 53aafd569aa..56af7223639 100644 --- a/samples/client/petstore/go/go-petstore/store_api.go +++ b/samples/client/petstore/go/go-petstore/store_api.go @@ -90,7 +90,7 @@ func (a StoreApi) DeleteOrder(orderId string) (*APIResponse, error) { * Returns pet inventories by status * Returns a map of status codes to quantities * - * @return map[string]int32 + * @return *map[string]int32 */ func (a StoreApi) GetInventory() (*map[string]int32, *APIResponse, error) { @@ -147,7 +147,7 @@ func (a StoreApi) GetInventory() (*map[string]int32, *APIResponse, error) { * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * * @param orderId ID of pet that needs to be fetched - * @return Order + * @return *Order */ func (a StoreApi) GetOrderById(orderId int64) (*Order, *APIResponse, error) { @@ -206,7 +206,7 @@ func (a StoreApi) GetOrderById(orderId int64) (*Order, *APIResponse, error) { * * * @param body order placed for purchasing the pet - * @return Order + * @return *Order */ func (a StoreApi) PlaceOrder(body Order) (*Order, *APIResponse, error) { diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go index e096fd506ec..1ed8b9a599a 100644 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ b/samples/client/petstore/go/go-petstore/user_api.go @@ -274,7 +274,7 @@ func (a UserApi) DeleteUser(username string) (*APIResponse, error) { * * * @param username The name that needs to be fetched. Use user1 for testing. - * @return User + * @return *User */ func (a UserApi) GetUserByName(username string) (*User, *APIResponse, error) { @@ -334,7 +334,7 @@ func (a UserApi) GetUserByName(username string) (*User, *APIResponse, error) { * * @param username The user name for login * @param password The password for login in clear text - * @return string + * @return *string */ func (a UserApi) LoginUser(username string, password string) (*string, *APIResponse, error) { diff --git a/samples/client/petstore/go/pet_api_test.go b/samples/client/petstore/go/pet_api_test.go index 2f3b2742804..fdda15acbe5 100644 --- a/samples/client/petstore/go/pet_api_test.go +++ b/samples/client/petstore/go/pet_api_test.go @@ -18,8 +18,8 @@ func TestAddPet(t *testing.T) { t.Errorf("Error while adding pet") t.Log(err) } - if *apiResponse.Response.StatusCode != 200 { - t.Log(*apiResponse.Response) + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) } } @@ -32,8 +32,8 @@ func TestFindPetsByStatusWithMissingParam(t *testing.T) { t.Errorf("Error while testing TestFindPetsByStatusWithMissingParam") t.Log(err) } - if *apiResponse.Response.StatusCode != 200 { - t.Log(*apiResponse) + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse) } } @@ -52,8 +52,8 @@ func TestGetPetById(t *testing.T) { //t.Log(resp) } - if *apiResponse.Response.StatusCode != 200 { - t.Log(*apiResponse.Response) + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) } } @@ -67,8 +67,8 @@ func TestGetPetByIdWithInvalidID(t *testing.T) { } else { t.Log(resp) } - if *apiResponse.Response.StatusCode != 200 { - t.Log(*apiResponse.Response) + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) } } @@ -79,10 +79,10 @@ func TestUpdatePetWithForm(t *testing.T) { if err != nil { t.Errorf("Error while updating pet by id") t.Log(err) - t.Log(*apiResponse) + t.Log(apiResponse) } - if *apiResponse.Response.StatusCode != 200 { - t.Log(*apiResponse.Response) + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) } } @@ -92,10 +92,9 @@ func TestFindPetsByStatus(t *testing.T) { if err != nil { t.Errorf("Error while getting pet by id") t.Log(err) - t.Log(*apiResponse) + t.Log(apiResponse) } else { - t.Log(*apiResponse) - if len(*resp) == 0 { + if len(resp) == 0 { t.Errorf("Error no pets returned") } else { assert := assert.New(t) @@ -104,8 +103,8 @@ func TestFindPetsByStatus(t *testing.T) { } } - if *apiResponse.Response.StatusCode != 200 { - t.Log(*apiResponse.Response) + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) } } } @@ -121,7 +120,7 @@ func TestUploadFile(t *testing.T) { t.Log(err) } - if *apiResponse.Response.StatusCode != 200 { + if apiResponse.Response.StatusCode != 200 { t.Log(apiResponse.Response) } } @@ -134,7 +133,7 @@ func TestDeletePet(t *testing.T) { t.Errorf("Error while deleting pet by id") t.Log(err) } - if *apiResponse.Response.StatusCode != 200 { + if apiResponse.Response.StatusCode != 200 { t.Log(apiResponse.Response) } } diff --git a/samples/client/petstore/java/default/docs/AnimalFarm.md b/samples/client/petstore/java/default/docs/AnimalFarm.md new file mode 100644 index 00000000000..c7c7f1ddcce --- /dev/null +++ b/samples/client/petstore/java/default/docs/AnimalFarm.md @@ -0,0 +1,9 @@ + +# AnimalFarm + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + + + diff --git a/samples/client/petstore/java/default/docs/EnumClass.md b/samples/client/petstore/java/default/docs/EnumClass.md index de0bc8a95ac..c746edc3cb1 100644 --- a/samples/client/petstore/java/default/docs/EnumClass.md +++ b/samples/client/petstore/java/default/docs/EnumClass.md @@ -3,6 +3,12 @@ ## Enum -* `{values=[_abc, -efg, (xyz)], enumVars=[{name=_ABC, value="_abc"}, {name=_EFG, value="-efg"}, {name=_XYZ_, value="(xyz)"}]}` + +* `_ABC` (value: `"_abc"`) + +* `_EFG` (value: `"-efg"`) + +* `_XYZ_` (value: `"(xyz)"`) + diff --git a/samples/client/petstore/java/default/docs/FakeApi.md b/samples/client/petstore/java/default/docs/FakeApi.md index f642566c8e7..c1fdd310321 100644 --- a/samples/client/petstore/java/default/docs/FakeApi.md +++ b/samples/client/petstore/java/default/docs/FakeApi.md @@ -23,7 +23,7 @@ Fake endpoint for testing various parameters FakeApi apiInstance = new FakeApi(); -String number = "number_example"; // String | None +BigDecimal number = new BigDecimal(); // BigDecimal | None Double _double = 3.4D; // Double | None String string = "string_example"; // String | None byte[] _byte = B; // byte[] | None @@ -47,7 +47,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **number** | **String**| None | + **number** | **BigDecimal**| None | **_double** | **Double**| None | **string** | **String**| None | **_byte** | **byte[]**| None | diff --git a/samples/client/petstore/java/default/docs/FormatTest.md b/samples/client/petstore/java/default/docs/FormatTest.md index 5e54362e535..dc2b559dad2 100644 --- a/samples/client/petstore/java/default/docs/FormatTest.md +++ b/samples/client/petstore/java/default/docs/FormatTest.md @@ -15,6 +15,7 @@ Name | Type | Description | Notes **binary** | **byte[]** | | [optional] **date** | [**Date**](Date.md) | | **dateTime** | [**Date**](Date.md) | | [optional] +**uuid** | **String** | | [optional] **password** | **String** | | diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/FakeApi.java index ddfaff67d0f..efa202418d6 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/FakeApi.java @@ -7,6 +7,7 @@ import io.swagger.client.ApiClient; import io.swagger.client.Configuration; import io.swagger.client.Pair; +import java.math.BigDecimal; import java.util.Date; import java.util.ArrayList; @@ -51,7 +52,7 @@ public class FakeApi { * @param password None (optional) * @throws ApiException if fails to make API call */ - public void testEndpointParameters(String number, Double _double, String string, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, byte[] binary, Date date, Date dateTime, String password) throws ApiException { + public void testEndpointParameters(BigDecimal number, Double _double, String string, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, byte[] binary, Date date, Date dateTime, String password) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'number' is set diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java index c4ff05ec24f..584c85aaae4 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java @@ -8,8 +8,8 @@ import io.swagger.client.Configuration; import io.swagger.client.Pair; import io.swagger.client.model.Pet; -import java.io.File; import io.swagger.client.model.ModelApiResponse; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/AnimalFarm.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/AnimalFarm.java new file mode 100644 index 00000000000..9dbd29436ad --- /dev/null +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/AnimalFarm.java @@ -0,0 +1,53 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.client.model.Animal; +import java.util.ArrayList; +import java.util.List; + + +/** + * AnimalFarm + */ + +public class AnimalFarm extends ArrayList { + + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnimalFarm {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java/feign/git_push.sh b/samples/client/petstore/java/feign/git_push.sh index 1a36388db02..ed374619b13 100644 --- a/samples/client/petstore/java/feign/git_push.sh +++ b/samples/client/petstore/java/feign/git_push.sh @@ -8,12 +8,12 @@ git_repo_id=$2 release_note=$3 if [ "$git_user_id" = "" ]; then - git_user_id="YOUR_GIT_USR_ID" + git_user_id="GIT_USER_ID" echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" fi if [ "$git_repo_id" = "" ]; then - git_repo_id="YOUR_GIT_REPO_ID" + git_repo_id="GIT_REPO_ID" echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" fi diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java index b92a064d3e5..b1dc92805ab 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java @@ -2,6 +2,7 @@ package io.swagger.client.api; import io.swagger.client.ApiClient; +import java.math.BigDecimal; import java.util.Date; import java.util.ArrayList; @@ -10,7 +11,7 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-27T23:17:22.230+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:05.435+08:00") public interface FakeApi extends ApiClient.Api { @@ -36,5 +37,5 @@ public interface FakeApi extends ApiClient.Api { "Content-type: application/x-www-form-urlencoded", "Accepts: application/json", }) - void testEndpointParameters(@Param("number") String number, @Param("_double") Double _double, @Param("string") String string, @Param("_byte") byte[] _byte, @Param("integer") Integer integer, @Param("int32") Integer int32, @Param("int64") Long int64, @Param("_float") Float _float, @Param("binary") byte[] binary, @Param("date") Date date, @Param("dateTime") Date dateTime, @Param("password") String password); + void testEndpointParameters(@Param("number") BigDecimal number, @Param("_double") Double _double, @Param("string") String string, @Param("_byte") byte[] _byte, @Param("integer") Integer integer, @Param("int32") Integer int32, @Param("int64") Long int64, @Param("_float") Float _float, @Param("binary") byte[] binary, @Param("date") Date date, @Param("dateTime") Date dateTime, @Param("password") String password); } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/AnimalFarm.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/AnimalFarm.java new file mode 100644 index 00000000000..f38bf504d50 --- /dev/null +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/AnimalFarm.java @@ -0,0 +1,53 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.client.model.Animal; +import java.util.ArrayList; +import java.util.List; + + +/** + * AnimalFarm + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:05.435+08:00") +public class AnimalFarm extends ArrayList { + + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnimalFarm {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java index 53aa13638a7..072decf8079 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java @@ -11,7 +11,7 @@ import java.util.Date; /** * FormatTest */ -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-27T23:17:22.230+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:05.435+08:00") public class FormatTest { private Integer integer = null; @@ -25,6 +25,7 @@ public class FormatTest { private byte[] binary = null; private Date date = null; private Date dateTime = null; + private String uuid = null; private String password = null; @@ -225,6 +226,23 @@ public class FormatTest { } + /** + **/ + public FormatTest uuid(String uuid) { + this.uuid = uuid; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("uuid") + public String getUuid() { + return uuid; + } + public void setUuid(String uuid) { + this.uuid = uuid; + } + + /** **/ public FormatTest password(String password) { @@ -262,12 +280,13 @@ public class FormatTest { Objects.equals(this.binary, formatTest.binary) && Objects.equals(this.date, formatTest.date) && Objects.equals(this.dateTime, formatTest.dateTime) && + Objects.equals(this.uuid, formatTest.uuid) && Objects.equals(this.password, formatTest.password); } @Override public int hashCode() { - return Objects.hash(integer, int32, int64, number, _float, _double, string, _byte, binary, date, dateTime, password); + return Objects.hash(integer, int32, int64, number, _float, _double, string, _byte, binary, date, dateTime, uuid, password); } @Override @@ -286,6 +305,7 @@ public class FormatTest { sb.append(" binary: ").append(toIndentedString(binary)).append("\n"); sb.append(" date: ").append(toIndentedString(date)).append("\n"); sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); sb.append(" password: ").append(toIndentedString(password)).append("\n"); sb.append("}"); return sb.toString(); diff --git a/samples/client/petstore/java/jersey2/docs/AnimalFarm.md b/samples/client/petstore/java/jersey2/docs/AnimalFarm.md new file mode 100644 index 00000000000..c7c7f1ddcce --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/AnimalFarm.md @@ -0,0 +1,9 @@ + +# AnimalFarm + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + + + diff --git a/samples/client/petstore/java/jersey2/docs/EnumClass.md b/samples/client/petstore/java/jersey2/docs/EnumClass.md new file mode 100644 index 00000000000..c746edc3cb1 --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/EnumClass.md @@ -0,0 +1,14 @@ + +# EnumClass + +## Enum + + +* `_ABC` (value: `"_abc"`) + +* `_EFG` (value: `"-efg"`) + +* `_XYZ_` (value: `"(xyz)"`) + + + diff --git a/samples/client/petstore/java/jersey2/docs/EnumTest.md b/samples/client/petstore/java/jersey2/docs/EnumTest.md new file mode 100644 index 00000000000..deb1951c552 --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/EnumTest.md @@ -0,0 +1,36 @@ + +# EnumTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**enumString** | [**EnumStringEnum**](#EnumStringEnum) | | [optional] +**enumInteger** | [**EnumIntegerEnum**](#EnumIntegerEnum) | | [optional] +**enumNumber** | [**EnumNumberEnum**](#EnumNumberEnum) | | [optional] + + + +## Enum: EnumStringEnum +Name | Value +---- | ----- +UPPER | "UPPER" +LOWER | "lower" + + + +## Enum: EnumIntegerEnum +Name | Value +---- | ----- +NUMBER_1 | 1 +NUMBER_MINUS_1 | -1 + + + +## Enum: EnumNumberEnum +Name | Value +---- | ----- +NUMBER_1_DOT_1 | 1.1 +NUMBER_MINUS_1_DOT_2 | -1.2 + + + diff --git a/samples/client/petstore/java/jersey2/docs/FakeApi.md b/samples/client/petstore/java/jersey2/docs/FakeApi.md new file mode 100644 index 00000000000..c1fdd310321 --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/FakeApi.md @@ -0,0 +1,75 @@ +# FakeApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters + + + +# **testEndpointParameters** +> testEndpointParameters(number, _double, string, _byte, integer, int32, int64, _float, binary, date, dateTime, password) + +Fake endpoint for testing various parameters + +Fake endpoint for testing various parameters + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +BigDecimal number = new BigDecimal(); // BigDecimal | None +Double _double = 3.4D; // Double | None +String string = "string_example"; // String | None +byte[] _byte = B; // byte[] | None +Integer integer = 56; // Integer | None +Integer int32 = 56; // Integer | None +Long int64 = 789L; // Long | None +Float _float = 3.4F; // Float | None +byte[] binary = B; // byte[] | None +Date date = new Date(); // Date | None +Date dateTime = new Date(); // Date | None +String password = "password_example"; // String | None +try { + apiInstance.testEndpointParameters(number, _double, string, _byte, integer, int32, int64, _float, binary, date, dateTime, password); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testEndpointParameters"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **number** | **BigDecimal**| None | + **_double** | **Double**| None | + **string** | **String**| None | + **_byte** | **byte[]**| None | + **integer** | **Integer**| None | [optional] + **int32** | **Integer**| None | [optional] + **int64** | **Long**| None | [optional] + **_float** | **Float**| None | [optional] + **binary** | **byte[]**| None | [optional] + **date** | **Date**| None | [optional] + **dateTime** | **Date**| None | [optional] + **password** | **String**| None | [optional] + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + diff --git a/samples/client/petstore/java/jersey2/docs/FormatTest.md b/samples/client/petstore/java/jersey2/docs/FormatTest.md index 8e400e7bcd7..dc2b559dad2 100644 --- a/samples/client/petstore/java/jersey2/docs/FormatTest.md +++ b/samples/client/petstore/java/jersey2/docs/FormatTest.md @@ -11,11 +11,12 @@ Name | Type | Description | Notes **_float** | **Float** | | [optional] **_double** | **Double** | | [optional] **string** | **String** | | [optional] -**_byte** | **byte[]** | | [optional] +**_byte** | **byte[]** | | **binary** | **byte[]** | | [optional] -**date** | [**Date**](Date.md) | | [optional] +**date** | [**Date**](Date.md) | | **dateTime** | [**Date**](Date.md) | | [optional] -**password** | **String** | | [optional] +**uuid** | **String** | | [optional] +**password** | **String** | | diff --git a/samples/client/petstore/java/jersey2/docs/Order.md b/samples/client/petstore/java/jersey2/docs/Order.md index b1709c14eee..29ca3ddbc6b 100644 --- a/samples/client/petstore/java/jersey2/docs/Order.md +++ b/samples/client/petstore/java/jersey2/docs/Order.md @@ -16,9 +16,9 @@ Name | Type | Description | Notes ## Enum: StatusEnum Name | Value ---- | ----- -PLACED | placed -APPROVED | approved -DELIVERED | delivered +PLACED | "placed" +APPROVED | "approved" +DELIVERED | "delivered" diff --git a/samples/client/petstore/java/jersey2/docs/Pet.md b/samples/client/petstore/java/jersey2/docs/Pet.md index 20a1c298dd6..5b63109ef92 100644 --- a/samples/client/petstore/java/jersey2/docs/Pet.md +++ b/samples/client/petstore/java/jersey2/docs/Pet.md @@ -16,9 +16,9 @@ Name | Type | Description | Notes ## Enum: StatusEnum Name | Value ---- | ----- -AVAILABLE | available -PENDING | pending -SOLD | sold +AVAILABLE | "available" +PENDING | "pending" +SOLD | "sold" diff --git a/samples/client/petstore/java/jersey2/git_push.sh b/samples/client/petstore/java/jersey2/git_push.sh index 1a36388db02..ed374619b13 100644 --- a/samples/client/petstore/java/jersey2/git_push.sh +++ b/samples/client/petstore/java/jersey2/git_push.sh @@ -8,12 +8,12 @@ git_repo_id=$2 release_note=$3 if [ "$git_user_id" = "" ]; then - git_user_id="YOUR_GIT_USR_ID" + git_user_id="GIT_USER_ID" echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" fi if [ "$git_repo_id" = "" ]; then - git_repo_id="YOUR_GIT_REPO_ID" + git_repo_id="GIT_REPO_ID" echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" fi diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeApi.java new file mode 100644 index 00000000000..33c74e7a51c --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeApi.java @@ -0,0 +1,128 @@ +package io.swagger.client.api; + +import io.swagger.client.ApiException; +import io.swagger.client.ApiClient; +import io.swagger.client.Configuration; +import io.swagger.client.Pair; + +import javax.ws.rs.core.GenericType; + +import java.math.BigDecimal; +import java.util.Date; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:03.551+08:00") +public class FakeApi { + private ApiClient apiClient; + + public FakeApi() { + this(Configuration.getDefaultApiClient()); + } + + public FakeApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + public ApiClient getApiClient() { + return apiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + /** + * Fake endpoint for testing various parameters + * Fake endpoint for testing various parameters + * @param number None (required) + * @param _double None (required) + * @param string None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @throws ApiException if fails to make API call + */ + public void testEndpointParameters(BigDecimal number, Double _double, String string, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, byte[] binary, Date date, Date dateTime, String password) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'number' is set + if (number == null) { + throw new ApiException(400, "Missing the required parameter 'number' when calling testEndpointParameters"); + } + + // verify the required parameter '_double' is set + if (_double == null) { + throw new ApiException(400, "Missing the required parameter '_double' when calling testEndpointParameters"); + } + + // verify the required parameter 'string' is set + if (string == null) { + throw new ApiException(400, "Missing the required parameter 'string' when calling testEndpointParameters"); + } + + // verify the required parameter '_byte' is set + if (_byte == null) { + throw new ApiException(400, "Missing the required parameter '_byte' when calling testEndpointParameters"); + } + + // create path and map variables + String localVarPath = "/fake".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + if (integer != null) + localVarFormParams.put("integer", integer); +if (int32 != null) + localVarFormParams.put("int32", int32); +if (int64 != null) + localVarFormParams.put("int64", int64); +if (number != null) + localVarFormParams.put("number", number); +if (_float != null) + localVarFormParams.put("float", _float); +if (_double != null) + localVarFormParams.put("double", _double); +if (string != null) + localVarFormParams.put("string", string); +if (_byte != null) + localVarFormParams.put("byte", _byte); +if (binary != null) + localVarFormParams.put("binary", binary); +if (date != null) + localVarFormParams.put("date", date); +if (dateTime != null) + localVarFormParams.put("dateTime", dateTime); +if (password != null) + localVarFormParams.put("password", password); + + final String[] localVarAccepts = { + "application/xml", "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + + apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + } +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java index 1a3029ec922..0781e60a4d4 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; /** * Animal */ -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-12T23:06:12.393+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:03.551+08:00") public class Animal { private String className = null; @@ -31,7 +31,6 @@ public class Animal { this.className = className; } - @Override public boolean equals(java.lang.Object o) { diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/AnimalFarm.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/AnimalFarm.java new file mode 100644 index 00000000000..04767c63252 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/AnimalFarm.java @@ -0,0 +1,53 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.client.model.Animal; +import java.util.ArrayList; +import java.util.List; + + +/** + * AnimalFarm + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:03.551+08:00") +public class AnimalFarm extends ArrayList { + + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnimalFarm {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java index c877047cd45..8acadb9a2f6 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; /** * Cat */ -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-12T23:06:12.393+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:03.551+08:00") public class Cat extends Animal { private String className = null; @@ -33,7 +33,7 @@ public class Cat extends Animal { this.className = className; } - + /** **/ public Cat declawed(Boolean declawed) { @@ -50,7 +50,6 @@ public class Cat extends Animal { this.declawed = declawed; } - @Override public boolean equals(java.lang.Object o) { diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java index b9cb4951346..763fcccf2a7 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; /** * Category */ -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-12T23:06:12.393+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:03.551+08:00") public class Category { private Long id = null; @@ -32,7 +32,7 @@ public class Category { this.id = id; } - + /** **/ public Category name(String name) { @@ -49,7 +49,6 @@ public class Category { this.name = name; } - @Override public boolean equals(java.lang.Object o) { diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java index 15d3ce320b2..a9e7e2acce0 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; /** * Dog */ -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-12T23:06:12.393+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:03.551+08:00") public class Dog extends Animal { private String className = null; @@ -33,7 +33,7 @@ public class Dog extends Animal { this.className = className; } - + /** **/ public Dog breed(String breed) { @@ -50,7 +50,6 @@ public class Dog extends Animal { this.breed = breed; } - @Override public boolean equals(java.lang.Object o) { diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/EnumTest.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/EnumTest.java index 6b8ee8102be..8152b440599 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/EnumTest.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/EnumTest.java @@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty; /** * EnumTest */ -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-12T23:06:12.393+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:03.551+08:00") public class EnumTest { @@ -97,7 +97,7 @@ public class EnumTest { this.enumString = enumString; } - + /** **/ public EnumTest enumInteger(EnumIntegerEnum enumInteger) { @@ -114,7 +114,7 @@ public class EnumTest { this.enumInteger = enumInteger; } - + /** **/ public EnumTest enumNumber(EnumNumberEnum enumNumber) { @@ -131,7 +131,6 @@ public class EnumTest { this.enumNumber = enumNumber; } - @Override public boolean equals(java.lang.Object o) { diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java index 774ce0ebcfe..4098e37a8a9 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java @@ -8,10 +8,10 @@ import java.math.BigDecimal; import java.util.Date; - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") +/** + * FormatTest + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:03.551+08:00") public class FormatTest { private Integer integer = null; @@ -25,10 +25,13 @@ public class FormatTest { private byte[] binary = null; private Date date = null; private Date dateTime = null; + private String uuid = null; private String password = null; /** + * minimum: 10.0 + * maximum: 100.0 **/ public FormatTest integer(Integer integer) { this.integer = integer; @@ -46,6 +49,8 @@ public class FormatTest { /** + * minimum: 20.0 + * maximum: 200.0 **/ public FormatTest int32(Integer int32) { this.int32 = int32; @@ -80,6 +85,8 @@ public class FormatTest { /** + * minimum: 32.1 + * maximum: 543.2 **/ public FormatTest number(BigDecimal number) { this.number = number; @@ -97,6 +104,8 @@ public class FormatTest { /** + * minimum: 54.3 + * maximum: 987.6 **/ public FormatTest _float(Float _float) { this._float = _float; @@ -114,6 +123,8 @@ public class FormatTest { /** + * minimum: 67.8 + * maximum: 123.4 **/ public FormatTest _double(Double _double) { this._double = _double; @@ -154,7 +165,7 @@ public class FormatTest { return this; } - @ApiModelProperty(example = "null", value = "") + @ApiModelProperty(example = "null", required = true, value = "") @JsonProperty("byte") public byte[] getByte() { return _byte; @@ -188,7 +199,7 @@ public class FormatTest { return this; } - @ApiModelProperty(example = "null", value = "") + @ApiModelProperty(example = "null", required = true, value = "") @JsonProperty("date") public Date getDate() { return date; @@ -215,6 +226,23 @@ public class FormatTest { } + /** + **/ + public FormatTest uuid(String uuid) { + this.uuid = uuid; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("uuid") + public String getUuid() { + return uuid; + } + public void setUuid(String uuid) { + this.uuid = uuid; + } + + /** **/ public FormatTest password(String password) { @@ -222,7 +250,7 @@ public class FormatTest { return this; } - @ApiModelProperty(example = "null", value = "") + @ApiModelProperty(example = "null", required = true, value = "") @JsonProperty("password") public String getPassword() { return password; @@ -252,12 +280,13 @@ public class FormatTest { Objects.equals(this.binary, formatTest.binary) && Objects.equals(this.date, formatTest.date) && Objects.equals(this.dateTime, formatTest.dateTime) && + Objects.equals(this.uuid, formatTest.uuid) && Objects.equals(this.password, formatTest.password); } @Override public int hashCode() { - return Objects.hash(integer, int32, int64, number, _float, _double, string, _byte, binary, date, dateTime, password); + return Objects.hash(integer, int32, int64, number, _float, _double, string, _byte, binary, date, dateTime, uuid, password); } @Override @@ -276,6 +305,7 @@ public class FormatTest { sb.append(" binary: ").append(toIndentedString(binary)).append("\n"); sb.append(" date: ").append(toIndentedString(date)).append("\n"); sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); sb.append(" password: ").append(toIndentedString(password)).append("\n"); sb.append("}"); return sb.toString(); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java index 36f04c225f6..0101cd5e8e3 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java @@ -7,9 +7,10 @@ import io.swagger.annotations.ApiModelProperty; /** - * Model200Response + * Model for testing model name starting with number */ -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-12T23:06:12.393+08:00") +@ApiModel(description = "Model for testing model name starting with number") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:03.551+08:00") public class Model200Response { private Integer name = null; @@ -31,7 +32,6 @@ public class Model200Response { this.name = name; } - @Override public boolean equals(java.lang.Object o) { diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java index 5a3f9254bae..af6f23fd782 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java @@ -6,10 +6,10 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") +/** + * ModelApiResponse + */ +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:03.551+08:00") public class ModelApiResponse { private Integer code = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java index 62224f3b2c3..827c22bef67 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java @@ -7,9 +7,10 @@ import io.swagger.annotations.ApiModelProperty; /** - * ModelReturn + * Model for testing reserved words */ -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-12T23:06:12.393+08:00") +@ApiModel(description = "Model for testing reserved words") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:03.551+08:00") public class ModelReturn { private Integer _return = null; @@ -31,7 +32,6 @@ public class ModelReturn { this._return = _return; } - @Override public boolean equals(java.lang.Object o) { diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java index 92bf36a7952..b7209d46b19 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java @@ -7,13 +7,15 @@ import io.swagger.annotations.ApiModelProperty; /** - * Name + * Model for testing model name same as property name */ -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-12T23:06:12.393+08:00") +@ApiModel(description = "Model for testing model name same as property name") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:03.551+08:00") public class Name { private Integer name = null; private Integer snakeCase = null; + private String property = null; /** @@ -23,7 +25,7 @@ public class Name { return this; } - @ApiModelProperty(example = "null", value = "") + @ApiModelProperty(example = "null", required = true, value = "") @JsonProperty("name") public Integer getName() { return name; @@ -32,24 +34,30 @@ public class Name { this.name = name; } - - /** - **/ - public Name snakeCase(Integer snakeCase) { - this.snakeCase = snakeCase; - return this; - } - + @ApiModelProperty(example = "null", value = "") @JsonProperty("snake_case") public Integer getSnakeCase() { return snakeCase; } - public void setSnakeCase(Integer snakeCase) { - this.snakeCase = snakeCase; + + + /** + **/ + public Name property(String property) { + this.property = property; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("property") + public String getProperty() { + return property; + } + public void setProperty(String property) { + this.property = property; } - @Override public boolean equals(java.lang.Object o) { @@ -61,12 +69,13 @@ public class Name { } Name name = (Name) o; return Objects.equals(this.name, name.name) && - Objects.equals(this.snakeCase, name.snakeCase); + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property); } @Override public int hashCode() { - return Objects.hash(name, snakeCase); + return Objects.hash(name, snakeCase, property); } @Override @@ -76,6 +85,7 @@ public class Name { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java index 116f07dc14d..322b2b832cb 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; /** * Order */ -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-12T23:06:12.393+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:03.551+08:00") public class Order { private Long id = null; @@ -40,17 +40,27 @@ public class Order { } } - private StatusEnum status = StatusEnum.PLACED; - private Boolean complete = null; + private StatusEnum status = null; + private Boolean complete = false; + /** + **/ + public Order id(Long id) { + this.id = id; + return this; + } + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; } + public void setId(Long id) { + this.id = id; + } + - /** **/ public Order petId(Long petId) { @@ -67,7 +77,7 @@ public class Order { this.petId = petId; } - + /** **/ public Order quantity(Integer quantity) { @@ -84,7 +94,7 @@ public class Order { this.quantity = quantity; } - + /** **/ public Order shipDate(Date shipDate) { @@ -101,7 +111,7 @@ public class Order { this.shipDate = shipDate; } - + /** * Order Status **/ @@ -119,7 +129,7 @@ public class Order { this.status = status; } - + /** **/ public Order complete(Boolean complete) { @@ -136,7 +146,6 @@ public class Order { this.complete = complete; } - @Override public boolean equals(java.lang.Object o) { diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java index 82dc1e9a1a4..07becbd4107 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java @@ -14,7 +14,7 @@ import java.util.List; /** * Pet */ -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-12T23:06:12.393+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:03.551+08:00") public class Pet { private Long id = null; @@ -63,7 +63,7 @@ public class Pet { this.id = id; } - + /** **/ public Pet category(Category category) { @@ -80,7 +80,7 @@ public class Pet { this.category = category; } - + /** **/ public Pet name(String name) { @@ -97,7 +97,7 @@ public class Pet { this.name = name; } - + /** **/ public Pet photoUrls(List photoUrls) { @@ -114,7 +114,7 @@ public class Pet { this.photoUrls = photoUrls; } - + /** **/ public Pet tags(List tags) { @@ -131,7 +131,7 @@ public class Pet { this.tags = tags; } - + /** * pet status in the store **/ @@ -149,7 +149,6 @@ public class Pet { this.status = status; } - @Override public boolean equals(java.lang.Object o) { diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java index 12e360e83a4..fccd55df94d 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; /** * SpecialModelName */ -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-12T23:06:12.393+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:03.551+08:00") public class SpecialModelName { private Long specialPropertyName = null; @@ -31,7 +31,6 @@ public class SpecialModelName { this.specialPropertyName = specialPropertyName; } - @Override public boolean equals(java.lang.Object o) { diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java index 0c579b9ed7e..417f95d4a2f 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; /** * Tag */ -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-12T23:06:12.393+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:03.551+08:00") public class Tag { private Long id = null; @@ -32,7 +32,7 @@ public class Tag { this.id = id; } - + /** **/ public Tag name(String name) { @@ -49,7 +49,6 @@ public class Tag { this.name = name; } - @Override public boolean equals(java.lang.Object o) { diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java index 48933177c5f..bf361b5a765 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; /** * User */ -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-12T23:06:12.393+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-06T18:35:03.551+08:00") public class User { private Long id = null; @@ -38,7 +38,7 @@ public class User { this.id = id; } - + /** **/ public User username(String username) { @@ -55,7 +55,7 @@ public class User { this.username = username; } - + /** **/ public User firstName(String firstName) { @@ -72,7 +72,7 @@ public class User { this.firstName = firstName; } - + /** **/ public User lastName(String lastName) { @@ -89,7 +89,7 @@ public class User { this.lastName = lastName; } - + /** **/ public User email(String email) { @@ -106,7 +106,7 @@ public class User { this.email = email; } - + /** **/ public User password(String password) { @@ -123,7 +123,7 @@ public class User { this.password = password; } - + /** **/ public User phone(String phone) { @@ -140,7 +140,7 @@ public class User { this.phone = phone; } - + /** * User Status **/ @@ -158,7 +158,6 @@ public class User { this.userStatus = userStatus; } - @Override public boolean equals(java.lang.Object o) { diff --git a/samples/client/petstore/java/okhttp-gson/docs/AnimalFarm.md b/samples/client/petstore/java/okhttp-gson/docs/AnimalFarm.md new file mode 100644 index 00000000000..c7c7f1ddcce --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/AnimalFarm.md @@ -0,0 +1,9 @@ + +# AnimalFarm + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/EnumClass.md b/samples/client/petstore/java/okhttp-gson/docs/EnumClass.md index d03195a19a4..c746edc3cb1 100644 --- a/samples/client/petstore/java/okhttp-gson/docs/EnumClass.md +++ b/samples/client/petstore/java/okhttp-gson/docs/EnumClass.md @@ -4,11 +4,11 @@ ## Enum -* `_ABC` (value: `"_abc"`) +* `_ABC` (value: `"_abc"`) -* `_EFG` (value: `"-efg"`) +* `_EFG` (value: `"-efg"`) -* `_XYZ_` (value: `"(xyz)"`) +* `_XYZ_` (value: `"(xyz)"`) diff --git a/samples/client/petstore/java/okhttp-gson/docs/FakeApi.md b/samples/client/petstore/java/okhttp-gson/docs/FakeApi.md index f642566c8e7..c1fdd310321 100644 --- a/samples/client/petstore/java/okhttp-gson/docs/FakeApi.md +++ b/samples/client/petstore/java/okhttp-gson/docs/FakeApi.md @@ -23,7 +23,7 @@ Fake endpoint for testing various parameters FakeApi apiInstance = new FakeApi(); -String number = "number_example"; // String | None +BigDecimal number = new BigDecimal(); // BigDecimal | None Double _double = 3.4D; // Double | None String string = "string_example"; // String | None byte[] _byte = B; // byte[] | None @@ -47,7 +47,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **number** | **String**| None | + **number** | **BigDecimal**| None | **_double** | **Double**| None | **string** | **String**| None | **_byte** | **byte[]**| None | diff --git a/samples/client/petstore/java/okhttp-gson/docs/FormatTest.md b/samples/client/petstore/java/okhttp-gson/docs/FormatTest.md index 5e54362e535..dc2b559dad2 100644 --- a/samples/client/petstore/java/okhttp-gson/docs/FormatTest.md +++ b/samples/client/petstore/java/okhttp-gson/docs/FormatTest.md @@ -15,6 +15,7 @@ Name | Type | Description | Notes **binary** | **byte[]** | | [optional] **date** | [**Date**](Date.md) | | **dateTime** | [**Date**](Date.md) | | [optional] +**uuid** | **String** | | [optional] **password** | **String** | | diff --git a/samples/client/petstore/java/okhttp-gson/git_push.sh b/samples/client/petstore/java/okhttp-gson/git_push.sh index 1a36388db02..ed374619b13 100644 --- a/samples/client/petstore/java/okhttp-gson/git_push.sh +++ b/samples/client/petstore/java/okhttp-gson/git_push.sh @@ -8,12 +8,12 @@ git_repo_id=$2 release_note=$3 if [ "$git_user_id" = "" ]; then - git_user_id="YOUR_GIT_USR_ID" + git_user_id="GIT_USER_ID" echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" fi if [ "$git_repo_id" = "" ]; then - git_repo_id="YOUR_GIT_REPO_ID" + git_repo_id="GIT_REPO_ID" echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" fi diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeApi.java index dd6d8236607..e021970cdb7 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeApi.java @@ -17,6 +17,7 @@ import com.squareup.okhttp.Response; import java.io.IOException; +import java.math.BigDecimal; import java.util.Date; import java.lang.reflect.Type; @@ -45,7 +46,7 @@ public class FakeApi { } /* Build call for testEndpointParameters */ - private Call testEndpointParametersCall(String number, Double _double, String string, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, byte[] binary, Date date, Date dateTime, String password, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private Call testEndpointParametersCall(BigDecimal number, Double _double, String string, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, byte[] binary, Date date, Date dateTime, String password, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'number' is set @@ -147,7 +148,7 @@ public class FakeApi { * @param password None (optional) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public void testEndpointParameters(String number, Double _double, String string, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, byte[] binary, Date date, Date dateTime, String password) throws ApiException { + public void testEndpointParameters(BigDecimal number, Double _double, String string, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, byte[] binary, Date date, Date dateTime, String password) throws ApiException { testEndpointParametersWithHttpInfo(number, _double, string, _byte, integer, int32, int64, _float, binary, date, dateTime, password); } @@ -169,7 +170,7 @@ public class FakeApi { * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public ApiResponse testEndpointParametersWithHttpInfo(String number, Double _double, String string, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, byte[] binary, Date date, Date dateTime, String password) throws ApiException { + public ApiResponse testEndpointParametersWithHttpInfo(BigDecimal number, Double _double, String string, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, byte[] binary, Date date, Date dateTime, String password) throws ApiException { Call call = testEndpointParametersCall(number, _double, string, _byte, integer, int32, int64, _float, binary, date, dateTime, password, null, null); return apiClient.execute(call); } @@ -193,7 +194,7 @@ public class FakeApi { * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ - public Call testEndpointParametersAsync(String number, Double _double, String string, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, byte[] binary, Date date, Date dateTime, String password, final ApiCallback callback) throws ApiException { + public Call testEndpointParametersAsync(BigDecimal number, Double _double, String string, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, byte[] binary, Date date, Date dateTime, String password, final ApiCallback callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/AnimalFarm.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/AnimalFarm.java new file mode 100644 index 00000000000..8be2f1ecd0d --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/AnimalFarm.java @@ -0,0 +1,53 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.client.model.Animal; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + + +/** + * AnimalFarm + */ +public class AnimalFarm extends ArrayList { + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnimalFarm {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/FormatTest.java index 0fc4082d119..af3fec2a2ea 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/FormatTest.java @@ -47,6 +47,9 @@ public class FormatTest { @SerializedName("dateTime") private Date dateTime = null; + @SerializedName("uuid") + private String uuid = null; + @SerializedName("password") private String password = null; @@ -170,6 +173,16 @@ public class FormatTest { this.dateTime = dateTime; } + /** + **/ + @ApiModelProperty(value = "") + public String getUuid() { + return uuid; + } + public void setUuid(String uuid) { + this.uuid = uuid; + } + /** **/ @ApiModelProperty(required = true, value = "") @@ -201,12 +214,13 @@ public class FormatTest { Objects.equals(this.binary, formatTest.binary) && Objects.equals(this.date, formatTest.date) && Objects.equals(this.dateTime, formatTest.dateTime) && + Objects.equals(this.uuid, formatTest.uuid) && Objects.equals(this.password, formatTest.password); } @Override public int hashCode() { - return Objects.hash(integer, int32, int64, number, _float, _double, string, _byte, binary, date, dateTime, password); + return Objects.hash(integer, int32, int64, number, _float, _double, string, _byte, binary, date, dateTime, uuid, password); } @Override @@ -225,6 +239,7 @@ public class FormatTest { sb.append(" binary: ").append(toIndentedString(binary)).append("\n"); sb.append(" date: ").append(toIndentedString(date)).append("\n"); sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); sb.append(" password: ").append(toIndentedString(password)).append("\n"); sb.append("}"); return sb.toString(); diff --git a/samples/client/petstore/java/retrofit/git_push.sh b/samples/client/petstore/java/retrofit/git_push.sh index 1a36388db02..ed374619b13 100644 --- a/samples/client/petstore/java/retrofit/git_push.sh +++ b/samples/client/petstore/java/retrofit/git_push.sh @@ -8,12 +8,12 @@ git_repo_id=$2 release_note=$3 if [ "$git_user_id" = "" ]; then - git_user_id="YOUR_GIT_USR_ID" + git_user_id="GIT_USER_ID" echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" fi if [ "$git_repo_id" = "" ]; then - git_repo_id="YOUR_GIT_REPO_ID" + git_repo_id="GIT_REPO_ID" echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" fi diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/FakeApi.java index 03f5b9aff1b..89fb9ddba73 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/FakeApi.java @@ -6,6 +6,7 @@ import retrofit.Callback; import retrofit.http.*; import retrofit.mime.*; +import java.math.BigDecimal; import java.util.Date; import java.util.ArrayList; @@ -36,7 +37,7 @@ public interface FakeApi { @FormUrlEncoded @POST("/fake") Void testEndpointParameters( - @Field("number") String number, @Field("double") Double _double, @Field("string") String string, @Field("byte") byte[] _byte, @Field("integer") Integer integer, @Field("int32") Integer int32, @Field("int64") Long int64, @Field("float") Float _float, @Field("binary") byte[] binary, @Field("date") Date date, @Field("dateTime") Date dateTime, @Field("password") String password + @Field("number") BigDecimal number, @Field("double") Double _double, @Field("string") String string, @Field("byte") byte[] _byte, @Field("integer") Integer integer, @Field("int32") Integer int32, @Field("int64") Long int64, @Field("float") Float _float, @Field("binary") byte[] binary, @Field("date") Date date, @Field("dateTime") Date dateTime, @Field("password") String password ); /** @@ -61,6 +62,6 @@ public interface FakeApi { @FormUrlEncoded @POST("/fake") void testEndpointParameters( - @Field("number") String number, @Field("double") Double _double, @Field("string") String string, @Field("byte") byte[] _byte, @Field("integer") Integer integer, @Field("int32") Integer int32, @Field("int64") Long int64, @Field("float") Float _float, @Field("binary") byte[] binary, @Field("date") Date date, @Field("dateTime") Date dateTime, @Field("password") String password, Callback cb + @Field("number") BigDecimal number, @Field("double") Double _double, @Field("string") String string, @Field("byte") byte[] _byte, @Field("integer") Integer integer, @Field("int32") Integer int32, @Field("int64") Long int64, @Field("float") Float _float, @Field("binary") byte[] binary, @Field("date") Date date, @Field("dateTime") Date dateTime, @Field("password") String password, Callback cb ); } diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/AnimalFarm.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/AnimalFarm.java new file mode 100644 index 00000000000..c7d37b1512c --- /dev/null +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/AnimalFarm.java @@ -0,0 +1,53 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.client.model.Animal; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + + + + + +public class AnimalFarm extends ArrayList { + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AnimalFarm animalFarm = (AnimalFarm) o; + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnimalFarm {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/FormatTest.java index 40d1ca0ecea..694335531fd 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/FormatTest.java @@ -47,6 +47,9 @@ public class FormatTest { @SerializedName("dateTime") private Date dateTime = null; + @SerializedName("uuid") + private String uuid = null; + @SerializedName("password") private String password = null; @@ -170,6 +173,16 @@ public class FormatTest { this.dateTime = dateTime; } + /** + **/ + @ApiModelProperty(value = "") + public String getUuid() { + return uuid; + } + public void setUuid(String uuid) { + this.uuid = uuid; + } + /** **/ @ApiModelProperty(required = true, value = "") @@ -201,12 +214,13 @@ public class FormatTest { Objects.equals(binary, formatTest.binary) && Objects.equals(date, formatTest.date) && Objects.equals(dateTime, formatTest.dateTime) && + Objects.equals(uuid, formatTest.uuid) && Objects.equals(password, formatTest.password); } @Override public int hashCode() { - return Objects.hash(integer, int32, int64, number, _float, _double, string, _byte, binary, date, dateTime, password); + return Objects.hash(integer, int32, int64, number, _float, _double, string, _byte, binary, date, dateTime, uuid, password); } @Override @@ -225,6 +239,7 @@ public class FormatTest { sb.append(" binary: ").append(toIndentedString(binary)).append("\n"); sb.append(" date: ").append(toIndentedString(date)).append("\n"); sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); sb.append(" password: ").append(toIndentedString(password)).append("\n"); sb.append("}"); return sb.toString(); diff --git a/samples/client/petstore/java/retrofit2/git_push.sh b/samples/client/petstore/java/retrofit2/git_push.sh index 1a36388db02..ed374619b13 100644 --- a/samples/client/petstore/java/retrofit2/git_push.sh +++ b/samples/client/petstore/java/retrofit2/git_push.sh @@ -8,12 +8,12 @@ git_repo_id=$2 release_note=$3 if [ "$git_user_id" = "" ]; then - git_user_id="YOUR_GIT_USR_ID" + git_user_id="GIT_USER_ID" echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" fi if [ "$git_repo_id" = "" ]; then - git_repo_id="YOUR_GIT_REPO_ID" + git_repo_id="GIT_REPO_ID" echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" fi diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java index dc732e67ae7..28db89beefd 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java @@ -8,6 +8,7 @@ import retrofit2.http.*; import okhttp3.RequestBody; +import java.math.BigDecimal; import java.util.Date; import java.util.ArrayList; @@ -37,7 +38,7 @@ public interface FakeApi { @FormUrlEncoded @POST("fake") Call testEndpointParameters( - @Field("number") String number, @Field("double") Double _double, @Field("string") String string, @Field("byte") byte[] _byte, @Field("integer") Integer integer, @Field("int32") Integer int32, @Field("int64") Long int64, @Field("float") Float _float, @Field("binary") byte[] binary, @Field("date") Date date, @Field("dateTime") Date dateTime, @Field("password") String password + @Field("number") BigDecimal number, @Field("double") Double _double, @Field("string") String string, @Field("byte") byte[] _byte, @Field("integer") Integer integer, @Field("int32") Integer int32, @Field("int64") Long int64, @Field("float") Float _float, @Field("binary") byte[] binary, @Field("date") Date date, @Field("dateTime") Date dateTime, @Field("password") String password ); } diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/AnimalFarm.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/AnimalFarm.java new file mode 100644 index 00000000000..c7d37b1512c --- /dev/null +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/AnimalFarm.java @@ -0,0 +1,53 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.client.model.Animal; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + + + + + +public class AnimalFarm extends ArrayList { + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AnimalFarm animalFarm = (AnimalFarm) o; + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnimalFarm {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/FormatTest.java index 40d1ca0ecea..694335531fd 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/FormatTest.java @@ -47,6 +47,9 @@ public class FormatTest { @SerializedName("dateTime") private Date dateTime = null; + @SerializedName("uuid") + private String uuid = null; + @SerializedName("password") private String password = null; @@ -170,6 +173,16 @@ public class FormatTest { this.dateTime = dateTime; } + /** + **/ + @ApiModelProperty(value = "") + public String getUuid() { + return uuid; + } + public void setUuid(String uuid) { + this.uuid = uuid; + } + /** **/ @ApiModelProperty(required = true, value = "") @@ -201,12 +214,13 @@ public class FormatTest { Objects.equals(binary, formatTest.binary) && Objects.equals(date, formatTest.date) && Objects.equals(dateTime, formatTest.dateTime) && + Objects.equals(uuid, formatTest.uuid) && Objects.equals(password, formatTest.password); } @Override public int hashCode() { - return Objects.hash(integer, int32, int64, number, _float, _double, string, _byte, binary, date, dateTime, password); + return Objects.hash(integer, int32, int64, number, _float, _double, string, _byte, binary, date, dateTime, uuid, password); } @Override @@ -225,6 +239,7 @@ public class FormatTest { sb.append(" binary: ").append(toIndentedString(binary)).append("\n"); sb.append(" date: ").append(toIndentedString(date)).append("\n"); sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); sb.append(" password: ").append(toIndentedString(password)).append("\n"); sb.append("}"); return sb.toString(); diff --git a/samples/client/petstore/java/retrofit2rx/git_push.sh b/samples/client/petstore/java/retrofit2rx/git_push.sh index 1a36388db02..ed374619b13 100644 --- a/samples/client/petstore/java/retrofit2rx/git_push.sh +++ b/samples/client/petstore/java/retrofit2rx/git_push.sh @@ -8,12 +8,12 @@ git_repo_id=$2 release_note=$3 if [ "$git_user_id" = "" ]; then - git_user_id="YOUR_GIT_USR_ID" + git_user_id="GIT_USER_ID" echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" fi if [ "$git_repo_id" = "" ]; then - git_repo_id="YOUR_GIT_REPO_ID" + git_repo_id="GIT_REPO_ID" echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" fi diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/AnimalFarm.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/AnimalFarm.java new file mode 100644 index 00000000000..c7d37b1512c --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/AnimalFarm.java @@ -0,0 +1,53 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.client.model.Animal; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + + + + + +public class AnimalFarm extends ArrayList { + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AnimalFarm animalFarm = (AnimalFarm) o; + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnimalFarm {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/FormatTest.java index 4106b15caaf..694335531fd 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/FormatTest.java @@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; import java.util.Date; -import java.util.UUID; import com.google.gson.annotations.SerializedName; @@ -49,7 +48,7 @@ public class FormatTest { private Date dateTime = null; @SerializedName("uuid") - private UUID uuid = null; + private String uuid = null; @SerializedName("password") private String password = null; @@ -177,10 +176,10 @@ public class FormatTest { /** **/ @ApiModelProperty(value = "") - public UUID getUuid() { + public String getUuid() { return uuid; } - public void setUuid(UUID uuid) { + public void setUuid(String uuid) { this.uuid = uuid; } diff --git a/samples/client/petstore/javascript-promise/README.md b/samples/client/petstore/javascript-promise/README.md index f1d10a435b6..ba181cae089 100644 --- a/samples/client/petstore/javascript-promise/README.md +++ b/samples/client/petstore/javascript-promise/README.md @@ -1,12 +1,12 @@ # swagger-petstore SwaggerPetstore - JavaScript client for swagger-petstore -This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-05-01T12:08:53.092+08:00 +- Build date: 2016-05-06T17:51:36.114+08:00 - Build package: class io.swagger.codegen.languages.JavascriptClientCodegen ## Installation @@ -53,18 +53,27 @@ Please follow the [installation](#installation) instruction and execute the foll ```javascript var SwaggerPetstore = require('swagger-petstore'); -var defaultClient = SwaggerPetstore.ApiClient.default; +var api = new SwaggerPetstore.FakeApi() -// Configure OAuth2 access token for authorization: petstore_auth -var petstore_auth = defaultClient.authentications['petstore_auth']; -petstore_auth.accessToken = "YOUR ACCESS TOKEN" +var _number = 3.4; // {Number} None -var api = new SwaggerPetstore.PetApi() +var _double = 1.2; // {Number} None + +var _string = "_string_example"; // {String} None + +var _byte = "B"; // {String} None var opts = { - 'body': new SwaggerPetstore.Pet() // {Pet} Pet object that needs to be added to the store + 'integer': 56, // {Integer} None + 'int32': 56, // {Integer} None + 'int64': 789, // {Integer} None + '_float': 3.4, // {Number} None + 'binary': "B", // {String} None + '_date': new Date("2013-10-20"), // {Date} None + 'dateTime': new Date("2013-10-20T19:20:30+01:00"), // {Date} None + 'password': "password_example" // {String} None }; -api.addPet(opts).then(function() { +api.testEndpointParameters(_number, _double, _string, _byte, opts).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -79,6 +88,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*SwaggerPetstore.FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters *SwaggerPetstore.PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store *SwaggerPetstore.PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet *SwaggerPetstore.PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status @@ -103,9 +113,21 @@ Class | Method | HTTP request | Description ## Documentation for Models + - [SwaggerPetstore.Animal](docs/Animal.md) + - [SwaggerPetstore.AnimalFarm](docs/AnimalFarm.md) + - [SwaggerPetstore.ApiResponse](docs/ApiResponse.md) + - [SwaggerPetstore.Cat](docs/Cat.md) - [SwaggerPetstore.Category](docs/Category.md) + - [SwaggerPetstore.Dog](docs/Dog.md) + - [SwaggerPetstore.EnumClass](docs/EnumClass.md) + - [SwaggerPetstore.EnumTest](docs/EnumTest.md) + - [SwaggerPetstore.FormatTest](docs/FormatTest.md) + - [SwaggerPetstore.Model200Response](docs/Model200Response.md) + - [SwaggerPetstore.ModelReturn](docs/ModelReturn.md) + - [SwaggerPetstore.Name](docs/Name.md) - [SwaggerPetstore.Order](docs/Order.md) - [SwaggerPetstore.Pet](docs/Pet.md) + - [SwaggerPetstore.SpecialModelName](docs/SpecialModelName.md) - [SwaggerPetstore.Tag](docs/Tag.md) - [SwaggerPetstore.User](docs/User.md) @@ -113,12 +135,6 @@ 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 @@ -128,3 +144,9 @@ 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/AnimalFarm.md b/samples/client/petstore/javascript-promise/docs/AnimalFarm.md new file mode 100644 index 00000000000..b72739a44c4 --- /dev/null +++ b/samples/client/petstore/javascript-promise/docs/AnimalFarm.md @@ -0,0 +1,7 @@ +# SwaggerPetstore.AnimalFarm + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + + diff --git a/samples/client/petstore/javascript-promise/docs/ApiResponse.md b/samples/client/petstore/javascript-promise/docs/ApiResponse.md new file mode 100644 index 00000000000..0ee678b84af --- /dev/null +++ b/samples/client/petstore/javascript-promise/docs/ApiResponse.md @@ -0,0 +1,10 @@ +# SwaggerPetstore.ApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **Integer** | | [optional] +**type** | **String** | | [optional] +**message** | **String** | | [optional] + + diff --git a/samples/client/petstore/javascript-promise/docs/EnumClass.md b/samples/client/petstore/javascript-promise/docs/EnumClass.md new file mode 100644 index 00000000000..04b89362941 --- /dev/null +++ b/samples/client/petstore/javascript-promise/docs/EnumClass.md @@ -0,0 +1,12 @@ +# SwaggerPetstore.EnumClass + +## Enum + + +* `_abc` (value: `"_abc"`) + +* `-efg` (value: `"-efg"`) + +* `(xyz)` (value: `"(xyz)"`) + + diff --git a/samples/client/petstore/javascript-promise/docs/EnumTest.md b/samples/client/petstore/javascript-promise/docs/EnumTest.md new file mode 100644 index 00000000000..22c4da11b9d --- /dev/null +++ b/samples/client/petstore/javascript-promise/docs/EnumTest.md @@ -0,0 +1,43 @@ +# SwaggerPetstore.EnumTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**enumString** | **String** | | [optional] +**enumInteger** | **Integer** | | [optional] +**enumNumber** | **Number** | | [optional] + + + +## Enum: EnumStringEnum + + +* `UPPER` (value: `"UPPER"`) + +* `lower` (value: `"lower"`) + + + + + +## Enum: EnumIntegerEnum + + +* `1` (value: `1`) + +* `-1` (value: `-1`) + + + + + +## Enum: EnumNumberEnum + + +* `1.1` (value: `1.1`) + +* `-1.2` (value: `-1.2`) + + + + diff --git a/samples/client/petstore/javascript-promise/docs/FakeApi.md b/samples/client/petstore/javascript-promise/docs/FakeApi.md new file mode 100644 index 00000000000..83925c1266d --- /dev/null +++ b/samples/client/petstore/javascript-promise/docs/FakeApi.md @@ -0,0 +1,79 @@ +# SwaggerPetstore.FakeApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters + + + +# **testEndpointParameters** +> testEndpointParameters(_number, _double, _string, _byte, opts) + +Fake endpoint for testing various parameters + +Fake endpoint for testing various parameters + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); + +var apiInstance = new SwaggerPetstore.FakeApi(); + +var _number = 3.4; // Number | None + +var _double = 1.2; // Number | None + +var _string = "_string_example"; // String | None + +var _byte = "B"; // String | None + +var opts = { + 'integer': 56, // Integer | None + 'int32': 56, // Integer | None + 'int64': 789, // Integer | None + '_float': 3.4, // Number | None + 'binary': "B", // String | None + '_date': new Date("2013-10-20"), // Date | None + 'dateTime': new Date("2013-10-20T19:20:30+01:00"), // Date | None + 'password': "password_example" // String | None +}; +apiInstance.testEndpointParameters(_number, _double, _string, _byte, opts).then(function() { + console.log('API called successfully.'); +}, function(error) { + console.error(error); +}); + +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **_number** | **Number**| None | + **_double** | **Number**| None | + **_string** | **String**| None | + **_byte** | **String**| None | + **integer** | **Integer**| None | [optional] + **int32** | **Integer**| None | [optional] + **int64** | **Integer**| None | [optional] + **_float** | **Number**| None | [optional] + **binary** | **String**| None | [optional] + **_date** | **Date**| None | [optional] + **dateTime** | **Date**| None | [optional] + **password** | **String**| None | [optional] + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + diff --git a/samples/client/petstore/javascript-promise/docs/FormatTest.md b/samples/client/petstore/javascript-promise/docs/FormatTest.md index 57a4fb132d5..9600904ee6d 100644 --- a/samples/client/petstore/javascript-promise/docs/FormatTest.md +++ b/samples/client/petstore/javascript-promise/docs/FormatTest.md @@ -10,9 +10,11 @@ Name | Type | Description | Notes **_float** | **Number** | | [optional] **_double** | **Number** | | [optional] **_string** | **String** | | [optional] -**_byte** | **String** | | [optional] +**_byte** | **String** | | **binary** | **String** | | [optional] -**_date** | **Date** | | [optional] -**dateTime** | **String** | | [optional] +**_date** | **Date** | | +**dateTime** | **Date** | | [optional] +**uuid** | **String** | | [optional] +**password** | **String** | | diff --git a/samples/client/petstore/javascript-promise/docs/InlineResponse200.md b/samples/client/petstore/javascript-promise/docs/InlineResponse200.md deleted file mode 100644 index bbb11067e9a..00000000000 --- a/samples/client/petstore/javascript-promise/docs/InlineResponse200.md +++ /dev/null @@ -1,13 +0,0 @@ -# SwaggerPetstore.InlineResponse200 - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**tags** | [**[Tag]**](Tag.md) | | [optional] -**id** | **Integer** | | -**category** | **Object** | | [optional] -**status** | **String** | pet status in the store | [optional] -**name** | **String** | | [optional] -**photoUrls** | **[String]** | | [optional] - - diff --git a/samples/client/petstore/javascript-promise/docs/Name.md b/samples/client/petstore/javascript-promise/docs/Name.md index f0e693f2f56..3bdb76be085 100644 --- a/samples/client/petstore/javascript-promise/docs/Name.md +++ b/samples/client/petstore/javascript-promise/docs/Name.md @@ -5,5 +5,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **Integer** | | **snakeCase** | **Integer** | | [optional] +**property** | **String** | | [optional] diff --git a/samples/client/petstore/javascript-promise/docs/Order.md b/samples/client/petstore/javascript-promise/docs/Order.md index b34b67d3a56..95ee5946ed2 100644 --- a/samples/client/petstore/javascript-promise/docs/Order.md +++ b/samples/client/petstore/javascript-promise/docs/Order.md @@ -8,6 +8,19 @@ Name | Type | Description | Notes **quantity** | **Integer** | | [optional] **shipDate** | **Date** | | [optional] **status** | **String** | Order Status | [optional] -**complete** | **Boolean** | | [optional] +**complete** | **Boolean** | | [optional] [default to false] + + + +## Enum: StatusEnum + + +* `placed` (value: `"placed"`) + +* `approved` (value: `"approved"`) + +* `delivered` (value: `"delivered"`) + + diff --git a/samples/client/petstore/javascript-promise/docs/Pet.md b/samples/client/petstore/javascript-promise/docs/Pet.md index f1b049dcadd..a08333731c0 100644 --- a/samples/client/petstore/javascript-promise/docs/Pet.md +++ b/samples/client/petstore/javascript-promise/docs/Pet.md @@ -11,3 +11,16 @@ Name | Type | Description | Notes **status** | **String** | pet status in the store | [optional] + +## Enum: StatusEnum + + +* `available` (value: `"available"`) + +* `pending` (value: `"pending"`) + +* `sold` (value: `"sold"`) + + + + diff --git a/samples/client/petstore/javascript-promise/docs/PetApi.md b/samples/client/petstore/javascript-promise/docs/PetApi.md index 0a0513875eb..af66741523b 100644 --- a/samples/client/petstore/javascript-promise/docs/PetApi.md +++ b/samples/client/petstore/javascript-promise/docs/PetApi.md @@ -16,7 +16,7 @@ Method | HTTP request | Description # **addPet** -> addPet(opts) +> addPet(body) Add a new pet to the store @@ -33,10 +33,9 @@ petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; var apiInstance = new SwaggerPetstore.PetApi(); -var opts = { - 'body': new SwaggerPetstore.Pet() // Pet | Pet object that needs to be added to the store -}; -apiInstance.addPet(opts).then(function() { +var body = new SwaggerPetstore.Pet(); // Pet | Pet object that needs to be added to the store + +apiInstance.addPet(body).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -48,7 +47,7 @@ apiInstance.addPet(opts).then(function() { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -61,7 +60,7 @@ null (empty response body) ### HTTP request headers - **Content-Type**: application/json, application/xml - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **deletePet** @@ -113,15 +112,15 @@ null (empty response body) ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **findPetsByStatus** -> [Pet] findPetsByStatus(opts) +> [Pet] findPetsByStatus(status) Finds Pets by status -Multiple status values can be provided with comma seperated strings +Multiple status values can be provided with comma separated strings ### Example ```javascript @@ -134,10 +133,9 @@ petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; var apiInstance = new SwaggerPetstore.PetApi(); -var opts = { - 'status': ["available"] // [String] | Status values that need to be considered for filter -}; -apiInstance.findPetsByStatus(opts).then(function(data) { +var status = ["status_example"]; // [String] | Status values that need to be considered for filter + +apiInstance.findPetsByStatus(status).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); @@ -149,7 +147,7 @@ apiInstance.findPetsByStatus(opts).then(function(data) { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **status** | [**[String]**](String.md)| Status values that need to be considered for filter | [optional] [default to available] + **status** | [**[String]**](String.md)| Status values that need to be considered for filter | ### Return type @@ -162,15 +160,15 @@ Name | Type | Description | Notes ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **findPetsByTags** -> [Pet] findPetsByTags(opts) +> [Pet] findPetsByTags(tags) Finds Pets by tags -Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. ### Example ```javascript @@ -183,10 +181,9 @@ petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; var apiInstance = new SwaggerPetstore.PetApi(); -var opts = { - 'tags': ["tags_example"] // [String] | Tags to filter by -}; -apiInstance.findPetsByTags(opts).then(function(data) { +var tags = ["tags_example"]; // [String] | Tags to filter by + +apiInstance.findPetsByTags(tags).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); @@ -198,7 +195,7 @@ apiInstance.findPetsByTags(opts).then(function(data) { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **tags** | [**[String]**](String.md)| Tags to filter by | [optional] + **tags** | [**[String]**](String.md)| Tags to filter by | ### Return type @@ -211,7 +208,7 @@ Name | Type | Description | Notes ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **getPetById** @@ -219,7 +216,7 @@ Name | Type | Description | Notes Find pet by ID -Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions +Returns a single pet ### Example ```javascript @@ -232,13 +229,9 @@ api_key.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //api_key.apiKeyPrefix = 'Token'; -// Configure OAuth2 access token for authorization: petstore_auth -var petstore_auth = defaultClient.authentications['petstore_auth']; -petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; - var apiInstance = new SwaggerPetstore.PetApi(); -var petId = 789; // Integer | ID of pet that needs to be fetched +var petId = 789; // Integer | ID of pet to return apiInstance.getPetById(petId).then(function(data) { console.log('API called successfully. Returned data: ' + data); @@ -252,7 +245,7 @@ apiInstance.getPetById(petId).then(function(data) { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **petId** | **Integer**| ID of pet that needs to be fetched | + **petId** | **Integer**| ID of pet to return | ### Return type @@ -260,16 +253,16 @@ Name | Type | Description | Notes ### Authorization -[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) +[api_key](../README.md#api_key) ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **updatePet** -> updatePet(opts) +> updatePet(body) Update an existing pet @@ -286,10 +279,9 @@ petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; var apiInstance = new SwaggerPetstore.PetApi(); -var opts = { - 'body': new SwaggerPetstore.Pet() // Pet | Pet object that needs to be added to the store -}; -apiInstance.updatePet(opts).then(function() { +var body = new SwaggerPetstore.Pet(); // Pet | Pet object that needs to be added to the store + +apiInstance.updatePet(body).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -301,7 +293,7 @@ apiInstance.updatePet(opts).then(function() { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -314,7 +306,7 @@ null (empty response body) ### HTTP request headers - **Content-Type**: application/json, application/xml - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **updatePetWithForm** @@ -335,7 +327,7 @@ petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; var apiInstance = new SwaggerPetstore.PetApi(); -var petId = "petId_example"; // String | ID of pet that needs to be updated +var petId = 789; // Integer | ID of pet that needs to be updated var opts = { 'name': "name_example", // String | Updated name of the pet @@ -353,7 +345,7 @@ apiInstance.updatePetWithForm(petId, opts).then(function() { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **petId** | **String**| ID of pet that needs to be updated | + **petId** | **Integer**| ID of pet that needs to be updated | **name** | **String**| Updated name of the pet | [optional] **status** | **String**| Updated status of the pet | [optional] @@ -368,11 +360,11 @@ null (empty response body) ### HTTP request headers - **Content-Type**: application/x-www-form-urlencoded - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **uploadFile** -> uploadFile(petId, opts) +> ApiResponse uploadFile(petId, opts) uploads an image @@ -395,8 +387,8 @@ var opts = { 'additionalMetadata': "additionalMetadata_example", // String | Additional data to pass to server 'file': "/path/to/file.txt" // File | file to upload }; -apiInstance.uploadFile(petId, opts).then(function() { - console.log('API called successfully.'); +apiInstance.uploadFile(petId, opts).then(function(data) { + console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); @@ -413,7 +405,7 @@ Name | Type | Description | Notes ### Return type -null (empty response body) +[**ApiResponse**](ApiResponse.md) ### Authorization @@ -422,5 +414,5 @@ null (empty response body) ### HTTP request headers - **Content-Type**: multipart/form-data - - **Accept**: application/json, application/xml + - **Accept**: application/json diff --git a/samples/client/petstore/javascript-promise/docs/StoreApi.md b/samples/client/petstore/javascript-promise/docs/StoreApi.md index ce57b57bc4f..0d96cfc9e34 100644 --- a/samples/client/petstore/javascript-promise/docs/StoreApi.md +++ b/samples/client/petstore/javascript-promise/docs/StoreApi.md @@ -51,7 +51,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **getInventory** @@ -95,7 +95,7 @@ This endpoint does not need any parameter. ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/json # **getOrderById** @@ -111,7 +111,7 @@ var SwaggerPetstore = require('swagger-petstore'); var apiInstance = new SwaggerPetstore.StoreApi(); -var orderId = "orderId_example"; // String | ID of pet that needs to be fetched +var orderId = 789; // Integer | ID of pet that needs to be fetched apiInstance.getOrderById(orderId).then(function(data) { console.log('API called successfully. Returned data: ' + data); @@ -125,7 +125,7 @@ apiInstance.getOrderById(orderId).then(function(data) { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **orderId** | **String**| ID of pet that needs to be fetched | + **orderId** | **Integer**| ID of pet that needs to be fetched | ### Return type @@ -138,11 +138,11 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **placeOrder** -> Order placeOrder(opts) +> Order placeOrder(body) Place an order for a pet @@ -154,10 +154,9 @@ var SwaggerPetstore = require('swagger-petstore'); var apiInstance = new SwaggerPetstore.StoreApi(); -var opts = { - 'body': new SwaggerPetstore.Order() // Order | order placed for purchasing the pet -}; -apiInstance.placeOrder(opts).then(function(data) { +var body = new SwaggerPetstore.Order(); // Order | order placed for purchasing the pet + +apiInstance.placeOrder(body).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); @@ -169,7 +168,7 @@ apiInstance.placeOrder(opts).then(function(data) { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Order**](Order.md)| order placed for purchasing the pet | [optional] + **body** | [**Order**](Order.md)| order placed for purchasing the pet | ### Return type @@ -182,5 +181,5 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json diff --git a/samples/client/petstore/javascript-promise/docs/UserApi.md b/samples/client/petstore/javascript-promise/docs/UserApi.md index 99b56e9cf3d..2634d41e611 100644 --- a/samples/client/petstore/javascript-promise/docs/UserApi.md +++ b/samples/client/petstore/javascript-promise/docs/UserApi.md @@ -16,7 +16,7 @@ Method | HTTP request | Description # **createUser** -> createUser(opts) +> createUser(body) Create user @@ -28,10 +28,9 @@ var SwaggerPetstore = require('swagger-petstore'); var apiInstance = new SwaggerPetstore.UserApi(); -var opts = { - 'body': new SwaggerPetstore.User() // User | Created user object -}; -apiInstance.createUser(opts).then(function() { +var body = new SwaggerPetstore.User(); // User | Created user object + +apiInstance.createUser(body).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -43,7 +42,7 @@ apiInstance.createUser(opts).then(function() { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**User**](User.md)| Created user object | [optional] + **body** | [**User**](User.md)| Created user object | ### Return type @@ -56,11 +55,11 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **createUsersWithArrayInput** -> createUsersWithArrayInput(opts) +> createUsersWithArrayInput(body) Creates list of users with given input array @@ -72,10 +71,9 @@ var SwaggerPetstore = require('swagger-petstore'); var apiInstance = new SwaggerPetstore.UserApi(); -var opts = { - 'body': [new SwaggerPetstore.User()] // [User] | List of user object -}; -apiInstance.createUsersWithArrayInput(opts).then(function() { +var body = [new SwaggerPetstore.User()]; // [User] | List of user object + +apiInstance.createUsersWithArrayInput(body).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -87,7 +85,7 @@ apiInstance.createUsersWithArrayInput(opts).then(function() { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**[User]**](User.md)| List of user object | [optional] + **body** | [**[User]**](User.md)| List of user object | ### Return type @@ -100,11 +98,11 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **createUsersWithListInput** -> createUsersWithListInput(opts) +> createUsersWithListInput(body) Creates list of users with given input array @@ -116,10 +114,9 @@ var SwaggerPetstore = require('swagger-petstore'); var apiInstance = new SwaggerPetstore.UserApi(); -var opts = { - 'body': [new SwaggerPetstore.User()] // [User] | List of user object -}; -apiInstance.createUsersWithListInput(opts).then(function() { +var body = [new SwaggerPetstore.User()]; // [User] | List of user object + +apiInstance.createUsersWithListInput(body).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -131,7 +128,7 @@ apiInstance.createUsersWithListInput(opts).then(function() { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**[User]**](User.md)| List of user object | [optional] + **body** | [**[User]**](User.md)| List of user object | ### Return type @@ -144,7 +141,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **deleteUser** @@ -187,7 +184,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **getUserByName** @@ -230,11 +227,11 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **loginUser** -> 'String' loginUser(opts) +> 'String' loginUser(username, password) Logs user into the system @@ -246,11 +243,11 @@ var SwaggerPetstore = require('swagger-petstore'); var apiInstance = new SwaggerPetstore.UserApi(); -var opts = { - 'username': "username_example", // String | The user name for login - 'password': "password_example" // String | The password for login in clear text -}; -apiInstance.loginUser(opts).then(function(data) { +var username = "username_example"; // String | The user name for login + +var password = "password_example"; // String | The password for login in clear text + +apiInstance.loginUser(username, password).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); @@ -262,8 +259,8 @@ apiInstance.loginUser(opts).then(function(data) { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **username** | **String**| The user name for login | [optional] - **password** | **String**| The password for login in clear text | [optional] + **username** | **String**| The user name for login | + **password** | **String**| The password for login in clear text | ### Return type @@ -276,7 +273,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **logoutUser** @@ -313,11 +310,11 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **updateUser** -> updateUser(username, opts) +> updateUser(username, body) Updated user @@ -331,10 +328,9 @@ var apiInstance = new SwaggerPetstore.UserApi(); var username = "username_example"; // String | name that need to be deleted -var opts = { - 'body': new SwaggerPetstore.User() // User | Updated user object -}; -apiInstance.updateUser(username, opts).then(function() { +var body = new SwaggerPetstore.User(); // User | Updated user object + +apiInstance.updateUser(username, body).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -347,7 +343,7 @@ apiInstance.updateUser(username, opts).then(function() { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **username** | **String**| name that need to be deleted | - **body** | [**User**](User.md)| Updated user object | [optional] + **body** | [**User**](User.md)| Updated user object | ### Return type @@ -360,5 +356,5 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json diff --git a/samples/client/petstore/javascript-promise/package.json b/samples/client/petstore/javascript-promise/package.json index 72a48ac71de..8ff02a78ae3 100644 --- a/samples/client/petstore/javascript-promise/package.json +++ b/samples/client/petstore/javascript-promise/package.json @@ -1,7 +1,7 @@ { "name": "swagger-petstore", "version": "1.0.0", - "description": "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters", + "description": "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose.", "license": "Apache 2.0", "main": "src/index.js", "scripts": { diff --git a/samples/client/petstore/javascript-promise/src/ApiClient.js b/samples/client/petstore/javascript-promise/src/ApiClient.js index ac0b172ff22..4033ad41e00 100644 --- a/samples/client/petstore/javascript-promise/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise/src/ApiClient.js @@ -40,8 +40,8 @@ * @type {Array.} */ this.authentications = { - 'api_key': {type: 'apiKey', 'in': 'header', name: 'api_key'}, - 'petstore_auth': {type: 'oauth2'} + 'petstore_auth': {type: 'oauth2'}, + 'api_key': {type: 'apiKey', 'in': 'header', name: 'api_key'} }; /** * 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 new file mode 100644 index 00000000000..84d262725a2 --- /dev/null +++ b/samples/client/petstore/javascript-promise/src/api/FakeApi.js @@ -0,0 +1,113 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['ApiClient'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(require('../ApiClient')); + } else { + // Browser globals (root is window) + if (!root.SwaggerPetstore) { + root.SwaggerPetstore = {}; + } + root.SwaggerPetstore.FakeApi = factory(root.SwaggerPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + /** + * Fake service. + * @module api/FakeApi + * @version 1.0.0 + */ + + /** + * Constructs a new FakeApi. + * @alias module:api/FakeApi + * @class + * @param {module:ApiClient} apiClient Optional API client implementation to use, + * default to {@link module:ApiClient#instance} if unspecified. + */ + var exports = function(apiClient) { + this.apiClient = apiClient || ApiClient.instance; + + + + /** + * Fake endpoint for testing various parameters + * Fake endpoint for testing various parameters + * @param {Number} _number None + * @param {Number} _double None + * @param {String} _string None + * @param {String} _byte None + * @param {Object} opts Optional parameters + * @param {Integer} opts.integer None + * @param {Integer} opts.int32 None + * @param {Integer} opts.int64 None + * @param {Number} opts._float None + * @param {String} opts.binary None + * @param {Date} opts._date None + * @param {Date} opts.dateTime None + * @param {String} opts.password None + */ + this.testEndpointParameters = function(_number, _double, _string, _byte, opts) { + opts = opts || {}; + var postBody = null; + + // verify the required parameter '_number' is set + if (_number == undefined || _number == null) { + throw "Missing the required parameter '_number' when calling testEndpointParameters"; + } + + // verify the required parameter '_double' is set + if (_double == undefined || _double == null) { + throw "Missing the required parameter '_double' when calling testEndpointParameters"; + } + + // verify the required parameter '_string' is set + if (_string == undefined || _string == null) { + throw "Missing the required parameter '_string' when calling testEndpointParameters"; + } + + // verify the required parameter '_byte' is set + if (_byte == undefined || _byte == null) { + throw "Missing the required parameter '_byte' when calling testEndpointParameters"; + } + + + var pathParams = { + }; + var queryParams = { + }; + var headerParams = { + }; + var formParams = { + 'integer': opts['integer'], + 'int32': opts['int32'], + 'int64': opts['int64'], + 'number': _number, + 'float': opts['_float'], + 'double': _double, + 'string': _string, + 'byte': _byte, + 'binary': opts['binary'], + 'date': opts['_date'], + 'dateTime': opts['dateTime'], + 'password': opts['password'] + }; + + var authNames = []; + var contentTypes = []; + var accepts = ['application/xml', 'application/json']; + var returnType = null; + + return this.apiClient.callApi( + '/fake', 'POST', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType + ); + } + }; + + return exports; +})); diff --git a/samples/client/petstore/javascript-promise/src/api/PetApi.js b/samples/client/petstore/javascript-promise/src/api/PetApi.js index 1b0855e5287..572fe19dbf2 100644 --- a/samples/client/petstore/javascript-promise/src/api/PetApi.js +++ b/samples/client/petstore/javascript-promise/src/api/PetApi.js @@ -1,18 +1,18 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['ApiClient', 'model/Pet'], factory); + define(['ApiClient', 'model/Pet', 'model/ApiResponse'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('../ApiClient'), require('../model/Pet')); + module.exports = factory(require('../ApiClient'), require('../model/Pet'), require('../model/ApiResponse')); } else { // Browser globals (root is window) if (!root.SwaggerPetstore) { root.SwaggerPetstore = {}; } - root.SwaggerPetstore.PetApi = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Pet); + root.SwaggerPetstore.PetApi = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Pet, root.SwaggerPetstore.ApiResponse); } -}(this, function(ApiClient, Pet) { +}(this, function(ApiClient, Pet, ApiResponse) { 'use strict'; /** @@ -36,12 +36,15 @@ /** * Add a new pet to the store * - * @param {Object} opts Optional parameters - * @param {module:model/Pet} opts.body Pet object that needs to be added to the store + * @param {module:model/Pet} body Pet object that needs to be added to the store */ - this.addPet = function(opts) { - opts = opts || {}; - var postBody = opts['body']; + this.addPet = 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 addPet"; + } var pathParams = { @@ -55,7 +58,7 @@ var authNames = ['petstore_auth']; var contentTypes = ['application/json', 'application/xml']; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = null; return this.apiClient.callApi( @@ -96,7 +99,7 @@ var authNames = ['petstore_auth']; var contentTypes = []; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = null; return this.apiClient.callApi( @@ -109,20 +112,23 @@ /** * Finds Pets by status - * Multiple status values can be provided with comma seperated strings - * @param {Object} opts Optional parameters - * @param {Array.} opts.status Status values that need to be considered for filter (default to available) + * Multiple status values can be provided with comma separated strings + * @param {Array.} status Status values that need to be considered for filter * data is of type: {Array.} */ - this.findPetsByStatus = function(opts) { - opts = opts || {}; + this.findPetsByStatus = function(status) { var postBody = null; + // verify the required parameter 'status' is set + if (status == undefined || status == null) { + throw "Missing the required parameter 'status' when calling findPetsByStatus"; + } + var pathParams = { }; var queryParams = { - 'status': this.apiClient.buildCollectionParam(opts['status'], 'multi') + 'status': this.apiClient.buildCollectionParam(status, 'csv') }; var headerParams = { }; @@ -131,7 +137,7 @@ var authNames = ['petstore_auth']; var contentTypes = []; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = [Pet]; return this.apiClient.callApi( @@ -144,20 +150,23 @@ /** * Finds Pets by tags - * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - * @param {Object} opts Optional parameters - * @param {Array.} opts.tags Tags to filter by + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param {Array.} tags Tags to filter by * data is of type: {Array.} */ - this.findPetsByTags = function(opts) { - opts = opts || {}; + this.findPetsByTags = function(tags) { var postBody = null; + // verify the required parameter 'tags' is set + if (tags == undefined || tags == null) { + throw "Missing the required parameter 'tags' when calling findPetsByTags"; + } + var pathParams = { }; var queryParams = { - 'tags': this.apiClient.buildCollectionParam(opts['tags'], 'multi') + 'tags': this.apiClient.buildCollectionParam(tags, 'csv') }; var headerParams = { }; @@ -166,7 +175,7 @@ var authNames = ['petstore_auth']; var contentTypes = []; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = [Pet]; return this.apiClient.callApi( @@ -179,8 +188,8 @@ /** * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param {Integer} petId ID of pet that needs to be fetched + * Returns a single pet + * @param {Integer} petId ID of pet to return * data is of type: {module:model/Pet} */ this.getPetById = function(petId) { @@ -202,9 +211,9 @@ var formParams = { }; - var authNames = ['api_key', 'petstore_auth']; + var authNames = ['api_key']; var contentTypes = []; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = Pet; return this.apiClient.callApi( @@ -218,12 +227,15 @@ /** * Update an existing pet * - * @param {Object} opts Optional parameters - * @param {module:model/Pet} opts.body Pet object that needs to be added to the store + * @param {module:model/Pet} body Pet object that needs to be added to the store */ - this.updatePet = function(opts) { - opts = opts || {}; - var postBody = opts['body']; + this.updatePet = 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 updatePet"; + } var pathParams = { @@ -237,7 +249,7 @@ var authNames = ['petstore_auth']; var contentTypes = ['application/json', 'application/xml']; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = null; return this.apiClient.callApi( @@ -251,7 +263,7 @@ /** * Updates a pet in the store with form data * - * @param {String} petId ID of pet that needs to be updated + * @param {Integer} petId ID of pet that needs to be updated * @param {Object} opts Optional parameters * @param {String} opts.name Updated name of the pet * @param {String} opts.status Updated status of the pet @@ -280,7 +292,7 @@ var authNames = ['petstore_auth']; var contentTypes = ['application/x-www-form-urlencoded']; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = null; return this.apiClient.callApi( @@ -298,6 +310,7 @@ * @param {Object} opts Optional parameters * @param {String} opts.additionalMetadata Additional data to pass to server * @param {File} opts.file file to upload + * data is of type: {module:model/ApiResponse} */ this.uploadFile = function(petId, opts) { opts = opts || {}; @@ -323,8 +336,8 @@ var authNames = ['petstore_auth']; var contentTypes = ['multipart/form-data']; - var accepts = ['application/json', 'application/xml']; - var returnType = null; + var accepts = ['application/json']; + var returnType = ApiResponse; return this.apiClient.callApi( '/pet/{petId}/uploadImage', 'POST', diff --git a/samples/client/petstore/javascript-promise/src/api/StoreApi.js b/samples/client/petstore/javascript-promise/src/api/StoreApi.js index 6c6f7ea5dc4..f8b889256b2 100644 --- a/samples/client/petstore/javascript-promise/src/api/StoreApi.js +++ b/samples/client/petstore/javascript-promise/src/api/StoreApi.js @@ -59,7 +59,7 @@ var authNames = []; var contentTypes = []; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = null; return this.apiClient.callApi( @@ -90,7 +90,7 @@ var authNames = ['api_key']; var contentTypes = []; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/json']; var returnType = {'String': 'Integer'}; return this.apiClient.callApi( @@ -104,7 +104,7 @@ /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * @param {String} orderId ID of pet that needs to be fetched + * @param {Integer} orderId ID of pet that needs to be fetched * data is of type: {module:model/Order} */ this.getOrderById = function(orderId) { @@ -128,7 +128,7 @@ var authNames = []; var contentTypes = []; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = Order; return this.apiClient.callApi( @@ -142,13 +142,16 @@ /** * Place an order for a pet * - * @param {Object} opts Optional parameters - * @param {module:model/Order} opts.body order placed for purchasing the pet + * @param {module:model/Order} body order placed for purchasing the pet * data is of type: {module:model/Order} */ - this.placeOrder = function(opts) { - opts = opts || {}; - var postBody = opts['body']; + this.placeOrder = 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 placeOrder"; + } var pathParams = { @@ -162,7 +165,7 @@ var authNames = []; var contentTypes = []; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = Order; return this.apiClient.callApi( diff --git a/samples/client/petstore/javascript-promise/src/api/UserApi.js b/samples/client/petstore/javascript-promise/src/api/UserApi.js index e58ee580d3b..ff8f745735d 100644 --- a/samples/client/petstore/javascript-promise/src/api/UserApi.js +++ b/samples/client/petstore/javascript-promise/src/api/UserApi.js @@ -36,12 +36,15 @@ /** * Create user * This can only be done by the logged in user. - * @param {Object} opts Optional parameters - * @param {module:model/User} opts.body Created user object + * @param {module:model/User} body Created user object */ - this.createUser = function(opts) { - opts = opts || {}; - var postBody = opts['body']; + this.createUser = 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 createUser"; + } var pathParams = { @@ -55,7 +58,7 @@ var authNames = []; var contentTypes = []; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = null; return this.apiClient.callApi( @@ -69,12 +72,15 @@ /** * Creates list of users with given input array * - * @param {Object} opts Optional parameters - * @param {Array.} opts.body List of user object + * @param {Array.} body List of user object */ - this.createUsersWithArrayInput = function(opts) { - opts = opts || {}; - var postBody = opts['body']; + this.createUsersWithArrayInput = 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 createUsersWithArrayInput"; + } var pathParams = { @@ -88,7 +94,7 @@ var authNames = []; var contentTypes = []; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = null; return this.apiClient.callApi( @@ -102,12 +108,15 @@ /** * Creates list of users with given input array * - * @param {Object} opts Optional parameters - * @param {Array.} opts.body List of user object + * @param {Array.} body List of user object */ - this.createUsersWithListInput = function(opts) { - opts = opts || {}; - var postBody = opts['body']; + this.createUsersWithListInput = 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 createUsersWithListInput"; + } var pathParams = { @@ -121,7 +130,7 @@ var authNames = []; var contentTypes = []; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = null; return this.apiClient.callApi( @@ -158,7 +167,7 @@ var authNames = []; var contentTypes = []; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = null; return this.apiClient.callApi( @@ -196,7 +205,7 @@ var authNames = []; var contentTypes = []; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = User; return this.apiClient.callApi( @@ -210,21 +219,29 @@ /** * Logs user into the system * - * @param {Object} opts Optional parameters - * @param {String} opts.username The user name for login - * @param {String} opts.password The password for login in clear text + * @param {String} username The user name for login + * @param {String} password The password for login in clear text * data is of type: {'String'} */ - this.loginUser = function(opts) { - opts = opts || {}; + this.loginUser = function(username, password) { var postBody = null; + // verify the required parameter 'username' is set + if (username == undefined || username == null) { + throw "Missing the required parameter 'username' when calling loginUser"; + } + + // verify the required parameter 'password' is set + if (password == undefined || password == null) { + throw "Missing the required parameter 'password' when calling loginUser"; + } + var pathParams = { }; var queryParams = { - 'username': opts['username'], - 'password': opts['password'] + 'username': username, + 'password': password }; var headerParams = { }; @@ -233,7 +250,7 @@ var authNames = []; var contentTypes = []; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = 'String'; return this.apiClient.callApi( @@ -263,7 +280,7 @@ var authNames = []; var contentTypes = []; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = null; return this.apiClient.callApi( @@ -278,18 +295,21 @@ * Updated user * This can only be done by the logged in user. * @param {String} username name that need to be deleted - * @param {Object} opts Optional parameters - * @param {module:model/User} opts.body Updated user object + * @param {module:model/User} body Updated user object */ - this.updateUser = function(username, opts) { - opts = opts || {}; - var postBody = opts['body']; + this.updateUser = function(username, body) { + var postBody = body; // verify the required parameter 'username' is set if (username == undefined || username == null) { throw "Missing the required parameter 'username' when calling updateUser"; } + // verify the required parameter 'body' is set + if (body == undefined || body == null) { + throw "Missing the required parameter 'body' when calling updateUser"; + } + var pathParams = { 'username': username @@ -303,7 +323,7 @@ var authNames = []; var contentTypes = []; - var accepts = ['application/json', 'application/xml']; + var accepts = ['application/xml', 'application/json']; var returnType = null; return this.apiClient.callApi( diff --git a/samples/client/petstore/javascript-promise/src/index.js b/samples/client/petstore/javascript-promise/src/index.js index b0d17b3ef3a..727b4782f45 100644 --- a/samples/client/petstore/javascript-promise/src/index.js +++ b/samples/client/petstore/javascript-promise/src/index.js @@ -1,16 +1,16 @@ (function(factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['ApiClient', 'model/Category', 'model/Order', 'model/Pet', 'model/Tag', 'model/User', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory); + define(['ApiClient', 'model/Animal', 'model/AnimalFarm', 'model/ApiResponse', 'model/Cat', 'model/Category', 'model/Dog', 'model/EnumClass', 'model/EnumTest', 'model/FormatTest', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/Order', 'model/Pet', 'model/SpecialModelName', 'model/Tag', 'model/User', 'api/FakeApi', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('./ApiClient'), require('./model/Category'), require('./model/Order'), require('./model/Pet'), require('./model/Tag'), require('./model/User'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); + module.exports = factory(require('./ApiClient'), require('./model/Animal'), require('./model/AnimalFarm'), require('./model/ApiResponse'), require('./model/Cat'), require('./model/Category'), require('./model/Dog'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/FormatTest'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/Order'), require('./model/Pet'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/FakeApi'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); } -}(function(ApiClient, Category, Order, Pet, Tag, User, PetApi, StoreApi, UserApi) { +}(function(ApiClient, Animal, AnimalFarm, ApiResponse, Cat, Category, Dog, EnumClass, EnumTest, FormatTest, Model200Response, ModelReturn, Name, Order, Pet, SpecialModelName, Tag, User, FakeApi, PetApi, StoreApi, UserApi) { 'use strict'; /** - * This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters.
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose..
* The index module provides access to constructors for all the classes which comprise the public API. *

* An AMD (recommended!) or CommonJS application will generally do something equivalent to the following: @@ -46,11 +46,66 @@ * @property {module:ApiClient} */ ApiClient: ApiClient, + /** + * The Animal model constructor. + * @property {module:model/Animal} + */ + Animal: Animal, + /** + * The AnimalFarm model constructor. + * @property {module:model/AnimalFarm} + */ + AnimalFarm: AnimalFarm, + /** + * The ApiResponse model constructor. + * @property {module:model/ApiResponse} + */ + ApiResponse: ApiResponse, + /** + * The Cat model constructor. + * @property {module:model/Cat} + */ + Cat: Cat, /** * The Category model constructor. * @property {module:model/Category} */ Category: Category, + /** + * The Dog model constructor. + * @property {module:model/Dog} + */ + Dog: Dog, + /** + * The EnumClass model constructor. + * @property {module:model/EnumClass} + */ + EnumClass: EnumClass, + /** + * The EnumTest model constructor. + * @property {module:model/EnumTest} + */ + EnumTest: EnumTest, + /** + * The FormatTest model constructor. + * @property {module:model/FormatTest} + */ + FormatTest: FormatTest, + /** + * The Model200Response model constructor. + * @property {module:model/Model200Response} + */ + Model200Response: Model200Response, + /** + * The ModelReturn model constructor. + * @property {module:model/ModelReturn} + */ + ModelReturn: ModelReturn, + /** + * The Name model constructor. + * @property {module:model/Name} + */ + Name: Name, /** * The Order model constructor. * @property {module:model/Order} @@ -61,6 +116,11 @@ * @property {module:model/Pet} */ Pet: Pet, + /** + * The SpecialModelName model constructor. + * @property {module:model/SpecialModelName} + */ + SpecialModelName: SpecialModelName, /** * The Tag model constructor. * @property {module:model/Tag} @@ -71,6 +131,11 @@ * @property {module:model/User} */ User: User, + /** + * The FakeApi service constructor. + * @property {module:api/FakeApi} + */ + FakeApi: FakeApi, /** * The PetApi service constructor. * @property {module:api/PetApi} diff --git a/samples/client/petstore/javascript-promise/src/model/Animal.js b/samples/client/petstore/javascript-promise/src/model/Animal.js index 674471a30ee..e42874c669b 100644 --- a/samples/client/petstore/javascript-promise/src/model/Animal.js +++ b/samples/client/petstore/javascript-promise/src/model/Animal.js @@ -1,7 +1,7 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['../ApiClient'], factory); + define(['ApiClient'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. module.exports = factory(require('../ApiClient')); @@ -15,6 +15,9 @@ }(this, function(ApiClient) { 'use strict'; + + + /** * The Animal model module. * @module model/Animal @@ -28,8 +31,9 @@ * @param className */ var exports = function(className) { + var _this = this; - this['className'] = className; + _this['className'] = className; }; /** @@ -40,7 +44,7 @@ * @return {module:model/Animal} The populated Animal instance. */ exports.constructFromObject = function(data, obj) { - if (data) { + if (data) { obj = obj || new exports(); if (data.hasOwnProperty('className')) { @@ -50,7 +54,6 @@ return obj; } - /** * @member {String} className */ @@ -61,3 +64,5 @@ return exports; })); + + diff --git a/samples/client/petstore/javascript-promise/src/model/AnimalFarm.js b/samples/client/petstore/javascript-promise/src/model/AnimalFarm.js new file mode 100644 index 00000000000..d5f6aa2a424 --- /dev/null +++ b/samples/client/petstore/javascript-promise/src/model/AnimalFarm.js @@ -0,0 +1,64 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['ApiClient', 'model/Animal'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(require('../ApiClient'), require('./Animal')); + } else { + // Browser globals (root is window) + if (!root.SwaggerPetstore) { + root.SwaggerPetstore = {}; + } + root.SwaggerPetstore.AnimalFarm = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Animal); + } +}(this, function(ApiClient, Animal) { + 'use strict'; + + + + + /** + * The AnimalFarm model module. + * @module model/AnimalFarm + * @version 1.0.0 + */ + + /** + * Constructs a new AnimalFarm. + * @alias module:model/AnimalFarm + * @class + * @extends Array + */ + var exports = function() { + var _this = this; + _this = new Array(); + Object.setPrototypeOf(_this, exports); + + return _this; + }; + + /** + * Constructs a AnimalFarm 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/AnimalFarm} obj Optional instance to populate. + * @return {module:model/AnimalFarm} The populated AnimalFarm instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + ApiClient.constructFromObject(data, obj, Animal); + + } + return obj; + } + + + + + + return exports; +})); + + diff --git a/samples/client/petstore/javascript-promise/src/model/ApiResponse.js b/samples/client/petstore/javascript-promise/src/model/ApiResponse.js new file mode 100644 index 00000000000..6d4c970264b --- /dev/null +++ b/samples/client/petstore/javascript-promise/src/model/ApiResponse.js @@ -0,0 +1,83 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['ApiClient'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(require('../ApiClient')); + } else { + // Browser globals (root is window) + if (!root.SwaggerPetstore) { + root.SwaggerPetstore = {}; + } + root.SwaggerPetstore.ApiResponse = factory(root.SwaggerPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + + + + /** + * The ApiResponse model module. + * @module model/ApiResponse + * @version 1.0.0 + */ + + /** + * Constructs a new ApiResponse. + * @alias module:model/ApiResponse + * @class + */ + var exports = function() { + var _this = this; + + + + + }; + + /** + * Constructs a ApiResponse from a plain JavaScript object, optionally creating a new instance. + * Copies all relevant properties from data to obj if supplied or a new instance if not. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @param {module:model/ApiResponse} obj Optional instance to populate. + * @return {module:model/ApiResponse} The populated ApiResponse instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + + if (data.hasOwnProperty('code')) { + obj['code'] = ApiClient.convertToType(data['code'], 'Integer'); + } + if (data.hasOwnProperty('type')) { + obj['type'] = ApiClient.convertToType(data['type'], 'String'); + } + if (data.hasOwnProperty('message')) { + obj['message'] = ApiClient.convertToType(data['message'], 'String'); + } + } + return obj; + } + + /** + * @member {Integer} code + */ + exports.prototype['code'] = undefined; + /** + * @member {String} type + */ + exports.prototype['type'] = undefined; + /** + * @member {String} message + */ + exports.prototype['message'] = undefined; + + + + + return exports; +})); + + diff --git a/samples/client/petstore/javascript-promise/src/model/Cat.js b/samples/client/petstore/javascript-promise/src/model/Cat.js index c878af6edec..a6b25bc6d58 100644 --- a/samples/client/petstore/javascript-promise/src/model/Cat.js +++ b/samples/client/petstore/javascript-promise/src/model/Cat.js @@ -1,7 +1,7 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['../ApiClient', './Animal'], factory); + define(['ApiClient', 'model/Animal'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. module.exports = factory(require('../ApiClient'), require('./Animal')); @@ -15,6 +15,9 @@ }(this, function(ApiClient, Animal) { 'use strict'; + + + /** * The Cat model module. * @module model/Cat @@ -29,7 +32,8 @@ * @param className */ var exports = function(className) { - Animal.call(this, className); + var _this = this; + Animal.call(_this, className); }; @@ -41,7 +45,7 @@ * @return {module:model/Cat} The populated Cat instance. */ exports.constructFromObject = function(data, obj) { - if (data) { + if (data) { obj = obj || new exports(); Animal.constructFromObject(data, obj); if (data.hasOwnProperty('declawed')) { @@ -54,7 +58,6 @@ exports.prototype = Object.create(Animal.prototype); exports.prototype.constructor = exports; - /** * @member {Boolean} declawed */ @@ -65,3 +68,5 @@ return exports; })); + + diff --git a/samples/client/petstore/javascript-promise/src/model/Category.js b/samples/client/petstore/javascript-promise/src/model/Category.js index 9956525e037..9e2e19ac5bb 100644 --- a/samples/client/petstore/javascript-promise/src/model/Category.js +++ b/samples/client/petstore/javascript-promise/src/model/Category.js @@ -15,6 +15,9 @@ }(this, function(ApiClient) { 'use strict'; + + + /** * The Category model module. * @module model/Category @@ -54,12 +57,10 @@ return obj; } - /** * @member {Integer} id */ exports.prototype['id'] = undefined; - /** * @member {String} name */ @@ -70,3 +71,5 @@ return exports; })); + + diff --git a/samples/client/petstore/javascript-promise/src/model/Dog.js b/samples/client/petstore/javascript-promise/src/model/Dog.js index e5e55581a70..ee17ae3467f 100644 --- a/samples/client/petstore/javascript-promise/src/model/Dog.js +++ b/samples/client/petstore/javascript-promise/src/model/Dog.js @@ -1,7 +1,7 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['../ApiClient', './Animal'], factory); + define(['ApiClient', 'model/Animal'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. module.exports = factory(require('../ApiClient'), require('./Animal')); @@ -15,6 +15,9 @@ }(this, function(ApiClient, Animal) { 'use strict'; + + + /** * The Dog model module. * @module model/Dog @@ -29,7 +32,8 @@ * @param className */ var exports = function(className) { - Animal.call(this, className); + var _this = this; + Animal.call(_this, className); }; @@ -41,7 +45,7 @@ * @return {module:model/Dog} The populated Dog instance. */ exports.constructFromObject = function(data, obj) { - if (data) { + if (data) { obj = obj || new exports(); Animal.constructFromObject(data, obj); if (data.hasOwnProperty('breed')) { @@ -54,7 +58,6 @@ exports.prototype = Object.create(Animal.prototype); exports.prototype.constructor = exports; - /** * @member {String} breed */ @@ -65,3 +68,5 @@ return exports; })); + + diff --git a/samples/client/petstore/javascript-promise/src/model/EnumClass.js b/samples/client/petstore/javascript-promise/src/model/EnumClass.js new file mode 100644 index 00000000000..e9bf5219ee5 --- /dev/null +++ b/samples/client/petstore/javascript-promise/src/model/EnumClass.js @@ -0,0 +1,44 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['ApiClient'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(require('../ApiClient')); + } else { + // Browser globals (root is window) + if (!root.SwaggerPetstore) { + root.SwaggerPetstore = {}; + } + root.SwaggerPetstore.EnumClass = factory(root.SwaggerPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + + /** + * Enum class EnumClass. + * @enum {} + * @readonly + */ + var exports = { + /** + * value: "_abc" + * @const + */ + "_abc": "_abc", + /** + * value: "-efg" + * @const + */ + "-efg": "-efg", + /** + * value: "(xyz)" + * @const + */ + "(xyz)": "(xyz)" }; + + return exports; +})); + + diff --git a/samples/client/petstore/javascript-promise/src/model/EnumTest.js b/samples/client/petstore/javascript-promise/src/model/EnumTest.js new file mode 100644 index 00000000000..6f8f0de3836 --- /dev/null +++ b/samples/client/petstore/javascript-promise/src/model/EnumTest.js @@ -0,0 +1,131 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['ApiClient'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(require('../ApiClient')); + } else { + // Browser globals (root is window) + if (!root.SwaggerPetstore) { + root.SwaggerPetstore = {}; + } + root.SwaggerPetstore.EnumTest = factory(root.SwaggerPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + + + + /** + * The EnumTest model module. + * @module model/EnumTest + * @version 1.0.0 + */ + + /** + * Constructs a new EnumTest. + * @alias module:model/EnumTest + * @class + */ + var exports = function() { + var _this = this; + + + + + }; + + /** + * Constructs a EnumTest from a plain JavaScript object, optionally creating a new instance. + * Copies all relevant properties from data to obj if supplied or a new instance if not. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @param {module:model/EnumTest} obj Optional instance to populate. + * @return {module:model/EnumTest} The populated EnumTest instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + + if (data.hasOwnProperty('enum_string')) { + obj['enum_string'] = ApiClient.convertToType(data['enum_string'], 'String'); + } + if (data.hasOwnProperty('enum_integer')) { + obj['enum_integer'] = ApiClient.convertToType(data['enum_integer'], 'Integer'); + } + if (data.hasOwnProperty('enum_number')) { + obj['enum_number'] = ApiClient.convertToType(data['enum_number'], 'Number'); + } + } + return obj; + } + + /** + * @member {module:model/EnumTest.EnumStringEnum} enum_string + */ + exports.prototype['enum_string'] = undefined; + /** + * @member {module:model/EnumTest.EnumIntegerEnum} enum_integer + */ + exports.prototype['enum_integer'] = undefined; + /** + * @member {module:model/EnumTest.EnumNumberEnum} enum_number + */ + exports.prototype['enum_number'] = undefined; + + + /** + * Allowed values for the enum_string property. + * @enum {String} + * @readonly + */ + exports.EnumStringEnum = { + /** + * value: "UPPER" + * @const + */ + "UPPER": "UPPER", + /** + * value: "lower" + * @const + */ + "lower": "lower" }; + /** + * Allowed values for the enum_integer property. + * @enum {Integer} + * @readonly + */ + exports.EnumIntegerEnum = { + /** + * value: 1 + * @const + */ + "1": 1, + /** + * value: -1 + * @const + */ + "-1": -1 }; + /** + * Allowed values for the enum_number property. + * @enum {Number} + * @readonly + */ + exports.EnumNumberEnum = { + /** + * value: 1.1 + * @const + */ + "1.1": 1.1, + /** + * value: -1.2 + * @const + */ + "-1.2": -1.2 }; + + + return exports; +})); + + diff --git a/samples/client/petstore/javascript-promise/src/model/FormatTest.js b/samples/client/petstore/javascript-promise/src/model/FormatTest.js index 46a9bc854fc..ed9e0cfcaf8 100644 --- a/samples/client/petstore/javascript-promise/src/model/FormatTest.js +++ b/samples/client/petstore/javascript-promise/src/model/FormatTest.js @@ -1,7 +1,7 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['../ApiClient'], factory); + define(['ApiClient'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. module.exports = factory(require('../ApiClient')); @@ -15,6 +15,9 @@ }(this, function(ApiClient) { 'use strict'; + + + /** * The FormatTest model module. * @module model/FormatTest @@ -26,20 +29,26 @@ * @alias module:model/FormatTest * @class * @param _number + * @param _byte + * @param _date + * @param password */ - var exports = function(_number) { + var exports = function(_number, _byte, _date, password) { + var _this = this; - this['number'] = _number; - - + _this['number'] = _number; + _this['byte'] = _byte; + + _this['date'] = _date; + _this['password'] = password; }; /** @@ -50,7 +59,7 @@ * @return {module:model/FormatTest} The populated FormatTest instance. */ exports.constructFromObject = function(data, obj) { - if (data) { + if (data) { obj = obj || new exports(); if (data.hasOwnProperty('integer')) { @@ -84,70 +93,75 @@ obj['date'] = ApiClient.convertToType(data['date'], 'Date'); } if (data.hasOwnProperty('dateTime')) { - obj['dateTime'] = ApiClient.convertToType(data['dateTime'], 'String'); + obj['dateTime'] = ApiClient.convertToType(data['dateTime'], 'Date'); + } + if (data.hasOwnProperty('uuid')) { + obj['uuid'] = ApiClient.convertToType(data['uuid'], 'String'); + } + if (data.hasOwnProperty('password')) { + obj['password'] = ApiClient.convertToType(data['password'], 'String'); } } return obj; } - /** * @member {Integer} integer */ exports.prototype['integer'] = undefined; - /** * @member {Integer} int32 */ exports.prototype['int32'] = undefined; - /** * @member {Integer} int64 */ exports.prototype['int64'] = undefined; - /** * @member {Number} number */ exports.prototype['number'] = undefined; - /** * @member {Number} float */ exports.prototype['float'] = undefined; - /** * @member {Number} double */ exports.prototype['double'] = undefined; - /** * @member {String} string */ exports.prototype['string'] = undefined; - /** * @member {String} byte */ exports.prototype['byte'] = undefined; - /** * @member {String} binary */ exports.prototype['binary'] = undefined; - /** * @member {Date} date */ exports.prototype['date'] = undefined; - /** - * @member {String} dateTime + * @member {Date} dateTime */ exports.prototype['dateTime'] = undefined; + /** + * @member {String} uuid + */ + exports.prototype['uuid'] = undefined; + /** + * @member {String} password + */ + exports.prototype['password'] = undefined; return exports; })); + + diff --git a/samples/client/petstore/javascript-promise/src/model/InlineResponse200.js b/samples/client/petstore/javascript-promise/src/model/InlineResponse200.js deleted file mode 100644 index f2abaf1bd1b..00000000000 --- a/samples/client/petstore/javascript-promise/src/model/InlineResponse200.js +++ /dev/null @@ -1,132 +0,0 @@ -(function(root, factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['ApiClient', 'model/Tag'], factory); - } else if (typeof module === 'object' && module.exports) { - // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('../ApiClient'), require('./Tag')); - } else { - // Browser globals (root is window) - if (!root.SwaggerPetstore) { - root.SwaggerPetstore = {}; - } - root.SwaggerPetstore.InlineResponse200 = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Tag); - } -}(this, function(ApiClient, Tag) { - 'use strict'; - - /** - * The InlineResponse200 model module. - * @module model/InlineResponse200 - * @version 1.0.0 - */ - - /** - * Constructs a new InlineResponse200. - * @alias module:model/InlineResponse200 - * @class - * @param id - */ - var exports = function(id) { - - - this['id'] = id; - - - - - }; - - /** - * Constructs a InlineResponse200 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/InlineResponse200} obj Optional instance to populate. - * @return {module:model/InlineResponse200} The populated InlineResponse200 instance. - */ - exports.constructFromObject = function(data, obj) { - if (data) { - obj = obj || new exports(); - - if (data.hasOwnProperty('tags')) { - obj['tags'] = ApiClient.convertToType(data['tags'], [Tag]); - } - if (data.hasOwnProperty('id')) { - obj['id'] = ApiClient.convertToType(data['id'], 'Integer'); - } - if (data.hasOwnProperty('category')) { - obj['category'] = ApiClient.convertToType(data['category'], Object); - } - if (data.hasOwnProperty('status')) { - obj['status'] = ApiClient.convertToType(data['status'], 'String'); - } - if (data.hasOwnProperty('name')) { - obj['name'] = ApiClient.convertToType(data['name'], 'String'); - } - if (data.hasOwnProperty('photoUrls')) { - obj['photoUrls'] = ApiClient.convertToType(data['photoUrls'], ['String']); - } - } - return obj; - } - - - /** - * @member {Array.} tags - */ - exports.prototype['tags'] = undefined; - - /** - * @member {Integer} id - */ - exports.prototype['id'] = undefined; - - /** - * @member {Object} category - */ - exports.prototype['category'] = undefined; - - /** - * pet status in the store - * @member {module:model/InlineResponse200.StatusEnum} status - */ - exports.prototype['status'] = undefined; - - /** - * @member {String} name - */ - exports.prototype['name'] = undefined; - - /** - * @member {Array.} photoUrls - */ - exports.prototype['photoUrls'] = undefined; - - - /** - * Allowed values for the status property. - * @enum {String} - * @readonly - */ - exports.StatusEnum = { - /** - * value: available - * @const - */ - AVAILABLE: "available", - - /** - * value: pending - * @const - */ - PENDING: "pending", - - /** - * value: sold - * @const - */ - SOLD: "sold" - }; - - return exports; -})); diff --git a/samples/client/petstore/javascript-promise/src/model/Model200Response.js b/samples/client/petstore/javascript-promise/src/model/Model200Response.js index 8381185d9d0..1d83d420287 100644 --- a/samples/client/petstore/javascript-promise/src/model/Model200Response.js +++ b/samples/client/petstore/javascript-promise/src/model/Model200Response.js @@ -15,6 +15,9 @@ }(this, function(ApiClient) { 'use strict'; + + + /** * The Model200Response model module. * @module model/Model200Response @@ -28,6 +31,7 @@ * @class */ var exports = function() { + var _this = this; }; @@ -40,7 +44,7 @@ * @return {module:model/Model200Response} The populated Model200Response instance. */ exports.constructFromObject = function(data, obj) { - if (data) { + if (data) { obj = obj || new exports(); if (data.hasOwnProperty('name')) { @@ -50,7 +54,6 @@ return obj; } - /** * @member {Integer} name */ @@ -61,3 +64,5 @@ return exports; })); + + diff --git a/samples/client/petstore/javascript-promise/src/model/ModelReturn.js b/samples/client/petstore/javascript-promise/src/model/ModelReturn.js index 9549db64d46..d0236e77b17 100644 --- a/samples/client/petstore/javascript-promise/src/model/ModelReturn.js +++ b/samples/client/petstore/javascript-promise/src/model/ModelReturn.js @@ -15,6 +15,9 @@ }(this, function(ApiClient) { 'use strict'; + + + /** * The ModelReturn model module. * @module model/ModelReturn @@ -28,6 +31,7 @@ * @class */ var exports = function() { + var _this = this; }; @@ -40,7 +44,7 @@ * @return {module:model/ModelReturn} The populated ModelReturn instance. */ exports.constructFromObject = function(data, obj) { - if (data) { + if (data) { obj = obj || new exports(); if (data.hasOwnProperty('return')) { @@ -50,7 +54,6 @@ return obj; } - /** * @member {Integer} return */ @@ -61,3 +64,5 @@ return exports; })); + + diff --git a/samples/client/petstore/javascript-promise/src/model/Name.js b/samples/client/petstore/javascript-promise/src/model/Name.js index 08a5a34c29a..93d1d55deb2 100644 --- a/samples/client/petstore/javascript-promise/src/model/Name.js +++ b/samples/client/petstore/javascript-promise/src/model/Name.js @@ -15,6 +15,9 @@ }(this, function(ApiClient) { 'use strict'; + + + /** * The Name model module. * @module model/Name @@ -29,8 +32,10 @@ * @param name */ var exports = function(name) { + var _this = this; + + _this['name'] = name; - this['name'] = name; }; @@ -42,7 +47,7 @@ * @return {module:model/Name} The populated Name instance. */ exports.constructFromObject = function(data, obj) { - if (data) { + if (data) { obj = obj || new exports(); if (data.hasOwnProperty('name')) { @@ -51,23 +56,30 @@ if (data.hasOwnProperty('snake_case')) { obj['snake_case'] = ApiClient.convertToType(data['snake_case'], 'Integer'); } + if (data.hasOwnProperty('property')) { + obj['property'] = ApiClient.convertToType(data['property'], 'String'); + } } return obj; } - /** * @member {Integer} name */ exports.prototype['name'] = undefined; - /** * @member {Integer} snake_case */ exports.prototype['snake_case'] = undefined; + /** + * @member {String} property + */ + exports.prototype['property'] = undefined; return exports; })); + + diff --git a/samples/client/petstore/javascript-promise/src/model/Order.js b/samples/client/petstore/javascript-promise/src/model/Order.js index 664908b77a9..57f77d84ccd 100644 --- a/samples/client/petstore/javascript-promise/src/model/Order.js +++ b/samples/client/petstore/javascript-promise/src/model/Order.js @@ -15,6 +15,9 @@ }(this, function(ApiClient) { 'use strict'; + + + /** * The Order model module. * @module model/Order @@ -70,37 +73,32 @@ return obj; } - /** * @member {Integer} id */ exports.prototype['id'] = undefined; - /** * @member {Integer} petId */ exports.prototype['petId'] = undefined; - /** * @member {Integer} quantity */ exports.prototype['quantity'] = undefined; - /** * @member {Date} shipDate */ exports.prototype['shipDate'] = undefined; - /** * Order Status * @member {module:model/Order.StatusEnum} status */ exports.prototype['status'] = undefined; - /** * @member {Boolean} complete + * @default false */ - exports.prototype['complete'] = undefined; + exports.prototype['complete'] = false; /** @@ -108,25 +106,25 @@ * @enum {String} * @readonly */ - exports.StatusEnum = { + exports.StatusEnum = { /** - * value: placed + * value: "placed" * @const */ - PLACED: "placed", - + "placed": "placed", /** - * value: approved + * value: "approved" * @const */ - APPROVED: "approved", - + "approved": "approved", /** - * value: delivered + * value: "delivered" * @const */ - DELIVERED: "delivered" - }; + "delivered": "delivered" }; + return exports; })); + + diff --git a/samples/client/petstore/javascript-promise/src/model/Pet.js b/samples/client/petstore/javascript-promise/src/model/Pet.js index ae907d35ca2..fe14361dbf2 100644 --- a/samples/client/petstore/javascript-promise/src/model/Pet.js +++ b/samples/client/petstore/javascript-promise/src/model/Pet.js @@ -15,6 +15,9 @@ }(this, function(ApiClient, Category, Tag) { 'use strict'; + + + /** * The Pet model module. * @module model/Pet @@ -72,32 +75,26 @@ return obj; } - /** * @member {Integer} id */ exports.prototype['id'] = undefined; - /** * @member {module:model/Category} category */ exports.prototype['category'] = undefined; - /** * @member {String} name */ exports.prototype['name'] = undefined; - /** * @member {Array.} photoUrls */ exports.prototype['photoUrls'] = undefined; - /** * @member {Array.} tags */ exports.prototype['tags'] = undefined; - /** * pet status in the store * @member {module:model/Pet.StatusEnum} status @@ -110,25 +107,25 @@ * @enum {String} * @readonly */ - exports.StatusEnum = { + exports.StatusEnum = { /** - * value: available + * value: "available" * @const */ - AVAILABLE: "available", - + "available": "available", /** - * value: pending + * value: "pending" * @const */ - PENDING: "pending", - + "pending": "pending", /** - * value: sold + * value: "sold" * @const */ - SOLD: "sold" - }; + "sold": "sold" }; + return exports; })); + + diff --git a/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js b/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js index 8694196cdd9..d5a0e992a73 100644 --- a/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js +++ b/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js @@ -15,6 +15,9 @@ }(this, function(ApiClient) { 'use strict'; + + + /** * The SpecialModelName model module. * @module model/SpecialModelName @@ -27,6 +30,7 @@ * @class */ var exports = function() { + var _this = this; }; @@ -39,7 +43,7 @@ * @return {module:model/SpecialModelName} The populated SpecialModelName instance. */ exports.constructFromObject = function(data, obj) { - if (data) { + if (data) { obj = obj || new exports(); if (data.hasOwnProperty('$special[property.name]')) { @@ -49,7 +53,6 @@ return obj; } - /** * @member {Integer} $special[property.name] */ @@ -60,3 +63,5 @@ return exports; })); + + diff --git a/samples/client/petstore/javascript-promise/src/model/Tag.js b/samples/client/petstore/javascript-promise/src/model/Tag.js index d9ab35fb8b5..443d312b76a 100644 --- a/samples/client/petstore/javascript-promise/src/model/Tag.js +++ b/samples/client/petstore/javascript-promise/src/model/Tag.js @@ -15,6 +15,9 @@ }(this, function(ApiClient) { 'use strict'; + + + /** * The Tag model module. * @module model/Tag @@ -54,12 +57,10 @@ return obj; } - /** * @member {Integer} id */ exports.prototype['id'] = undefined; - /** * @member {String} name */ @@ -70,3 +71,5 @@ return exports; })); + + diff --git a/samples/client/petstore/javascript-promise/src/model/User.js b/samples/client/petstore/javascript-promise/src/model/User.js index 3bc6aaab630..2360c7c6314 100644 --- a/samples/client/petstore/javascript-promise/src/model/User.js +++ b/samples/client/petstore/javascript-promise/src/model/User.js @@ -15,6 +15,9 @@ }(this, function(ApiClient) { 'use strict'; + + + /** * The User model module. * @module model/User @@ -78,42 +81,34 @@ return obj; } - /** * @member {Integer} id */ exports.prototype['id'] = undefined; - /** * @member {String} username */ exports.prototype['username'] = undefined; - /** * @member {String} firstName */ exports.prototype['firstName'] = undefined; - /** * @member {String} lastName */ exports.prototype['lastName'] = undefined; - /** * @member {String} email */ exports.prototype['email'] = undefined; - /** * @member {String} password */ exports.prototype['password'] = undefined; - /** * @member {String} phone */ exports.prototype['phone'] = undefined; - /** * User Status * @member {Integer} userStatus @@ -125,3 +120,5 @@ return exports; })); + + diff --git a/samples/client/petstore/javascript-promise/test/api/PetApiTest.js b/samples/client/petstore/javascript-promise/test/api/PetApiTest.js index 1119546014d..98debb8ea19 100644 --- a/samples/client/petstore/javascript-promise/test/api/PetApiTest.js +++ b/samples/client/petstore/javascript-promise/test/api/PetApiTest.js @@ -49,7 +49,7 @@ var createRandomPet = function() { describe('PetApi', function() { it('should create and get pet', function(done) { var pet = createRandomPet(); - api.addPet({body: pet}) + api.addPet(pet) .then(function() { return api.getPetById(pet.id) }) @@ -63,7 +63,7 @@ describe('PetApi', function() { .to.be(getProperty(getProperty(pet, "getCategory", "category"), "getName", "name")); api.deletePet(pet.id); - done(); + done(); }); }); }); diff --git a/samples/client/petstore/javascript/README.md b/samples/client/petstore/javascript/README.md index 651e1e6047f..1bf60abb9c3 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-05-03T11:05:41.851+08:00 +- Build date: 2016-05-06T18:34:50.267+08:00 - Build package: class io.swagger.codegen.languages.JavascriptClientCodegen ## Installation @@ -117,6 +117,7 @@ Class | Method | HTTP request | Description ## Documentation for Models - [SwaggerPetstore.Animal](docs/Animal.md) + - [SwaggerPetstore.AnimalFarm](docs/AnimalFarm.md) - [SwaggerPetstore.ApiResponse](docs/ApiResponse.md) - [SwaggerPetstore.Cat](docs/Cat.md) - [SwaggerPetstore.Category](docs/Category.md) @@ -137,12 +138,6 @@ 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 @@ -152,3 +147,9 @@ 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/AnimalFarm.md b/samples/client/petstore/javascript/docs/AnimalFarm.md new file mode 100644 index 00000000000..b72739a44c4 --- /dev/null +++ b/samples/client/petstore/javascript/docs/AnimalFarm.md @@ -0,0 +1,7 @@ +# SwaggerPetstore.AnimalFarm + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + + diff --git a/samples/client/petstore/javascript/docs/EnumClass.md b/samples/client/petstore/javascript/docs/EnumClass.md index 5159ccfb454..04b89362941 100644 --- a/samples/client/petstore/javascript/docs/EnumClass.md +++ b/samples/client/petstore/javascript/docs/EnumClass.md @@ -1,7 +1,12 @@ # SwaggerPetstore.EnumClass -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- +## Enum + + +* `_abc` (value: `"_abc"`) + +* `-efg` (value: `"-efg"`) + +* `(xyz)` (value: `"(xyz)"`) diff --git a/samples/client/petstore/javascript/docs/EnumTest.md b/samples/client/petstore/javascript/docs/EnumTest.md index 724eea8a25e..22c4da11b9d 100644 --- a/samples/client/petstore/javascript/docs/EnumTest.md +++ b/samples/client/petstore/javascript/docs/EnumTest.md @@ -8,3 +8,36 @@ Name | Type | Description | Notes **enumNumber** | **Number** | | [optional] + +## Enum: EnumStringEnum + + +* `UPPER` (value: `"UPPER"`) + +* `lower` (value: `"lower"`) + + + + + +## Enum: EnumIntegerEnum + + +* `1` (value: `1`) + +* `-1` (value: `-1`) + + + + + +## Enum: EnumNumberEnum + + +* `1.1` (value: `1.1`) + +* `-1.2` (value: `-1.2`) + + + + diff --git a/samples/client/petstore/javascript/docs/InlineResponse200.md b/samples/client/petstore/javascript/docs/InlineResponse200.md deleted file mode 100644 index bbb11067e9a..00000000000 --- a/samples/client/petstore/javascript/docs/InlineResponse200.md +++ /dev/null @@ -1,13 +0,0 @@ -# SwaggerPetstore.InlineResponse200 - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**tags** | [**[Tag]**](Tag.md) | | [optional] -**id** | **Integer** | | -**category** | **Object** | | [optional] -**status** | **String** | pet status in the store | [optional] -**name** | **String** | | [optional] -**photoUrls** | **[String]** | | [optional] - - diff --git a/samples/client/petstore/javascript/docs/Order.md b/samples/client/petstore/javascript/docs/Order.md index 10503b58206..95ee5946ed2 100644 --- a/samples/client/petstore/javascript/docs/Order.md +++ b/samples/client/petstore/javascript/docs/Order.md @@ -11,3 +11,16 @@ Name | Type | Description | Notes **complete** | **Boolean** | | [optional] [default to false] + +## Enum: StatusEnum + + +* `placed` (value: `"placed"`) + +* `approved` (value: `"approved"`) + +* `delivered` (value: `"delivered"`) + + + + diff --git a/samples/client/petstore/javascript/docs/Pet.md b/samples/client/petstore/javascript/docs/Pet.md index f1b049dcadd..a08333731c0 100644 --- a/samples/client/petstore/javascript/docs/Pet.md +++ b/samples/client/petstore/javascript/docs/Pet.md @@ -11,3 +11,16 @@ Name | Type | Description | Notes **status** | **String** | pet status in the store | [optional] + +## Enum: StatusEnum + + +* `available` (value: `"available"`) + +* `pending` (value: `"pending"`) + +* `sold` (value: `"sold"`) + + + + diff --git a/samples/client/petstore/javascript/src/ApiClient.js b/samples/client/petstore/javascript/src/ApiClient.js index d45704dcdac..2598dd8d9ea 100644 --- a/samples/client/petstore/javascript/src/ApiClient.js +++ b/samples/client/petstore/javascript/src/ApiClient.js @@ -40,8 +40,8 @@ * @type {Array.} */ this.authentications = { - 'api_key': {type: 'apiKey', 'in': 'header', name: 'api_key'}, - 'petstore_auth': {type: 'oauth2'} + 'petstore_auth': {type: 'oauth2'}, + 'api_key': {type: 'apiKey', 'in': 'header', name: 'api_key'} }; /** * The default HTTP headers to be included for all API calls. diff --git a/samples/client/petstore/javascript/src/index.js b/samples/client/petstore/javascript/src/index.js index 2c3fb27ef65..727b4782f45 100644 --- a/samples/client/petstore/javascript/src/index.js +++ b/samples/client/petstore/javascript/src/index.js @@ -1,12 +1,12 @@ (function(factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['ApiClient', 'model/Animal', 'model/ApiResponse', 'model/Cat', 'model/Category', 'model/Dog', 'model/EnumClass', 'model/EnumTest', 'model/FormatTest', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/Order', 'model/Pet', 'model/SpecialModelName', 'model/Tag', 'model/User', 'api/FakeApi', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory); + define(['ApiClient', 'model/Animal', 'model/AnimalFarm', 'model/ApiResponse', 'model/Cat', 'model/Category', 'model/Dog', 'model/EnumClass', 'model/EnumTest', 'model/FormatTest', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/Order', 'model/Pet', 'model/SpecialModelName', 'model/Tag', 'model/User', 'api/FakeApi', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('./ApiClient'), require('./model/Animal'), require('./model/ApiResponse'), require('./model/Cat'), require('./model/Category'), require('./model/Dog'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/FormatTest'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/Order'), require('./model/Pet'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/FakeApi'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); + module.exports = factory(require('./ApiClient'), require('./model/Animal'), require('./model/AnimalFarm'), require('./model/ApiResponse'), require('./model/Cat'), require('./model/Category'), require('./model/Dog'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/FormatTest'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/Order'), require('./model/Pet'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/FakeApi'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); } -}(function(ApiClient, Animal, ApiResponse, Cat, Category, Dog, EnumClass, EnumTest, FormatTest, Model200Response, ModelReturn, Name, Order, Pet, SpecialModelName, Tag, User, FakeApi, PetApi, StoreApi, UserApi) { +}(function(ApiClient, Animal, AnimalFarm, ApiResponse, Cat, Category, Dog, EnumClass, EnumTest, FormatTest, Model200Response, ModelReturn, Name, Order, Pet, SpecialModelName, Tag, User, FakeApi, PetApi, StoreApi, UserApi) { 'use strict'; /** @@ -51,6 +51,11 @@ * @property {module:model/Animal} */ Animal: Animal, + /** + * The AnimalFarm model constructor. + * @property {module:model/AnimalFarm} + */ + AnimalFarm: AnimalFarm, /** * The ApiResponse model constructor. * @property {module:model/ApiResponse} diff --git a/samples/client/petstore/javascript/src/model/AnimalFarm.js b/samples/client/petstore/javascript/src/model/AnimalFarm.js new file mode 100644 index 00000000000..d5f6aa2a424 --- /dev/null +++ b/samples/client/petstore/javascript/src/model/AnimalFarm.js @@ -0,0 +1,64 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['ApiClient', 'model/Animal'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(require('../ApiClient'), require('./Animal')); + } else { + // Browser globals (root is window) + if (!root.SwaggerPetstore) { + root.SwaggerPetstore = {}; + } + root.SwaggerPetstore.AnimalFarm = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Animal); + } +}(this, function(ApiClient, Animal) { + 'use strict'; + + + + + /** + * The AnimalFarm model module. + * @module model/AnimalFarm + * @version 1.0.0 + */ + + /** + * Constructs a new AnimalFarm. + * @alias module:model/AnimalFarm + * @class + * @extends Array + */ + var exports = function() { + var _this = this; + _this = new Array(); + Object.setPrototypeOf(_this, exports); + + return _this; + }; + + /** + * Constructs a AnimalFarm 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/AnimalFarm} obj Optional instance to populate. + * @return {module:model/AnimalFarm} The populated AnimalFarm instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + ApiClient.constructFromObject(data, obj, Animal); + + } + return obj; + } + + + + + + return exports; +})); + + diff --git a/samples/client/petstore/javascript/src/model/EnumClass.js b/samples/client/petstore/javascript/src/model/EnumClass.js index 2ff3398113a..e9bf5219ee5 100644 --- a/samples/client/petstore/javascript/src/model/EnumClass.js +++ b/samples/client/petstore/javascript/src/model/EnumClass.js @@ -21,19 +21,19 @@ * @enum {} * @readonly */ - exports.EnumClass = { + var exports = { /** - * value: _abc + * value: "_abc" * @const */ "_abc": "_abc", /** - * value: -efg + * value: "-efg" * @const */ "-efg": "-efg", /** - * value: (xyz) + * value: "(xyz)" * @const */ "(xyz)": "(xyz)" }; diff --git a/samples/client/petstore/javascript/src/model/InlineResponse200.js b/samples/client/petstore/javascript/src/model/InlineResponse200.js deleted file mode 100644 index f2abaf1bd1b..00000000000 --- a/samples/client/petstore/javascript/src/model/InlineResponse200.js +++ /dev/null @@ -1,132 +0,0 @@ -(function(root, factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['ApiClient', 'model/Tag'], factory); - } else if (typeof module === 'object' && module.exports) { - // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('../ApiClient'), require('./Tag')); - } else { - // Browser globals (root is window) - if (!root.SwaggerPetstore) { - root.SwaggerPetstore = {}; - } - root.SwaggerPetstore.InlineResponse200 = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Tag); - } -}(this, function(ApiClient, Tag) { - 'use strict'; - - /** - * The InlineResponse200 model module. - * @module model/InlineResponse200 - * @version 1.0.0 - */ - - /** - * Constructs a new InlineResponse200. - * @alias module:model/InlineResponse200 - * @class - * @param id - */ - var exports = function(id) { - - - this['id'] = id; - - - - - }; - - /** - * Constructs a InlineResponse200 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/InlineResponse200} obj Optional instance to populate. - * @return {module:model/InlineResponse200} The populated InlineResponse200 instance. - */ - exports.constructFromObject = function(data, obj) { - if (data) { - obj = obj || new exports(); - - if (data.hasOwnProperty('tags')) { - obj['tags'] = ApiClient.convertToType(data['tags'], [Tag]); - } - if (data.hasOwnProperty('id')) { - obj['id'] = ApiClient.convertToType(data['id'], 'Integer'); - } - if (data.hasOwnProperty('category')) { - obj['category'] = ApiClient.convertToType(data['category'], Object); - } - if (data.hasOwnProperty('status')) { - obj['status'] = ApiClient.convertToType(data['status'], 'String'); - } - if (data.hasOwnProperty('name')) { - obj['name'] = ApiClient.convertToType(data['name'], 'String'); - } - if (data.hasOwnProperty('photoUrls')) { - obj['photoUrls'] = ApiClient.convertToType(data['photoUrls'], ['String']); - } - } - return obj; - } - - - /** - * @member {Array.} tags - */ - exports.prototype['tags'] = undefined; - - /** - * @member {Integer} id - */ - exports.prototype['id'] = undefined; - - /** - * @member {Object} category - */ - exports.prototype['category'] = undefined; - - /** - * pet status in the store - * @member {module:model/InlineResponse200.StatusEnum} status - */ - exports.prototype['status'] = undefined; - - /** - * @member {String} name - */ - exports.prototype['name'] = undefined; - - /** - * @member {Array.} photoUrls - */ - exports.prototype['photoUrls'] = undefined; - - - /** - * Allowed values for the status property. - * @enum {String} - * @readonly - */ - exports.StatusEnum = { - /** - * value: available - * @const - */ - AVAILABLE: "available", - - /** - * value: pending - * @const - */ - PENDING: "pending", - - /** - * value: sold - * @const - */ - SOLD: "sold" - }; - - return exports; -})); diff --git a/samples/client/petstore/objc/README.md b/samples/client/petstore/objc/README.md index bd0f24851a7..a3550545c24 100644 --- a/samples/client/petstore/objc/README.md +++ b/samples/client/petstore/objc/README.md @@ -6,7 +6,7 @@ This ObjC package is automatically generated by the [Swagger Codegen](https://gi - API version: 1.0.0 - Package version: -- Build date: 2016-04-25T18:52:19.055+02:00 +- Build date: 2016-05-06T12:20:47.112+02:00 - Build package: class io.swagger.codegen.languages.ObjcClientCodegen ## Requirements @@ -19,7 +19,7 @@ The SDK requires [**ARC (Automatic Reference Counting)**](http://stackoverflow.c Add the following to the Podfile: ```ruby -pod 'SwaggerClient', :git => 'https://github.com/YOUR_GIT_USR_ID/YOUR_GIT_REPO_ID.git' +pod 'SwaggerClient', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git' ``` To specify a particular branch, append `, :branch => 'branch-name-here'` diff --git a/samples/client/petstore/objc/SwaggerClient/SWG200Response.h b/samples/client/petstore/objc/SwaggerClient/SWG200Response.h deleted file mode 100644 index c576bc204ad..00000000000 --- a/samples/client/petstore/objc/SwaggerClient/SWG200Response.h +++ /dev/null @@ -1,20 +0,0 @@ -#import -#import "SWGObject.h" - -/** - * 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. - */ - - - -@protocol SWG200Response -@end - -@interface SWG200Response : SWGObject - - -@property(nonatomic) NSNumber* name; - -@end diff --git a/samples/client/petstore/objc/SwaggerClient/SWG200Response.m b/samples/client/petstore/objc/SwaggerClient/SWG200Response.m deleted file mode 100644 index 9cafc782f1a..00000000000 --- a/samples/client/petstore/objc/SwaggerClient/SWG200Response.m +++ /dev/null @@ -1,51 +0,0 @@ -#import "SWG200Response.h" - -@implementation SWG200Response - -- (instancetype)init { - self = [super init]; - - if (self) { - // initalise property's default value, if any - - } - - return self; -} - - -/** - * Maps json key to property name. - * This method is used by `JSONModel`. - */ -+ (JSONKeyMapper *)keyMapper -{ - return [[JSONKeyMapper alloc] initWithDictionary:@{ @"name": @"name" }]; -} - -/** - * Indicates whether the property with the given name is optional. - * If `propertyName` is optional, then return `YES`, otherwise return `NO`. - * This method is used by `JSONModel`. - */ -+ (BOOL)propertyIsOptional:(NSString *)propertyName -{ - NSArray *optionalProperties = @[@"name"]; - - if ([optionalProperties containsObject:propertyName]) { - return YES; - } - else { - return NO; - } -} - -/** - * Gets the string presentation of the object. - * This method will be called when logging model object using `NSLog`. - */ -- (NSString *)description { - return [[self toDictionary] description]; -} - -@end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h index 5d40ef2f5f0..7dea87a3327 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h @@ -5,7 +5,7 @@ #import "SWGJSONRequestSerializer.h" #import "SWGQueryParamCollection.h" #import "SWGConfiguration.h" - +#import "SWGResponseDeserializer.h" /** * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen @@ -29,16 +29,6 @@ */ extern NSString *const SWGResponseObjectErrorKey; -/** - * A key for deserialization ErrorDomain - */ -extern NSString *const SWGDeserializationErrorDomainKey; - -/** - * Code for deserialization type mismatch error - */ -extern NSInteger const SWGTypeMismatchErrorCode; - /** * Log debug message macro */ @@ -53,6 +43,7 @@ extern NSInteger const SWGTypeMismatchErrorCode; /// In order to ensure the HTTPResponseHeaders are correct, it is recommended to initialize one SWGApiClient instance per thread. @property(nonatomic, readonly) NSDictionary* HTTPResponseHeaders; +@property(nonatomic, strong) id responseDeserializer; /** * Clears Cache */ @@ -180,15 +171,6 @@ extern NSInteger const SWGTypeMismatchErrorCode; queryParams:(NSDictionary **)querys WithAuthSettings:(NSArray *)authSettings; -/** - * Deserializes the given data to Objective-C object. - * - * @param data The data will be deserialized. - * @param class The type of objective-c object. - * @param error The error - */ -- (id) deserialize:(id) data class:(NSString *) class error:(NSError**)error; - /** * Logs request and response * diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m index ecdf4aaafb2..5d5d2019b0f 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m @@ -2,10 +2,6 @@ NSString *const SWGResponseObjectErrorKey = @"SWGResponseObject"; -NSString *const SWGDeserializationErrorDomainKey = @"SWGDeserializationErrorDomainKey"; - -NSInteger const SWGTypeMismatchErrorCode = 143553; - static long requestId = 0; static bool offlineState = false; static NSMutableSet * queuedRequests = nil; @@ -33,6 +29,7 @@ static void (^reachabilityChangeBlock)(int); self.requestSerializer = [AFJSONRequestSerializer serializer]; self.responseSerializer = [AFJSONResponseSerializer serializer]; self.securityPolicy = [self customSecurityPolicy]; + self.responseDeserializer = [[SWGResponseDeserializer alloc] init]; // configure reachability [self configureCacheReachibility]; } @@ -290,154 +287,6 @@ static void (^reachabilityChangeBlock)(int); [self.reachabilityManager startMonitoring]; } -#pragma mark - Deserialize methods - -- (id) deserialize:(id) data class:(NSString *) class error:(NSError **) error { - // return nil if data is nil or class is nil - if (!data || !class) { - return nil; - } - - // remove "*" from class, if ends with "*" - if ([class hasSuffix:@"*"]) { - class = [class substringToIndex:[class length] - 1]; - } - - // pure object - if ([class isEqualToString:@"NSObject"]) { - return data; - } - - NSRegularExpression *regexp = nil; - NSTextCheckingResult *match = nil; - NSMutableArray *resultArray = nil; - NSMutableDictionary *resultDict = nil; - NSString *innerType = nil; - - // list of models - NSString *arrayOfModelsPat = @"NSArray<(.+)>"; - regexp = [NSRegularExpression regularExpressionWithPattern:arrayOfModelsPat - options:NSRegularExpressionCaseInsensitive - error:nil]; - - match = [regexp firstMatchInString:class - options:0 - range:NSMakeRange(0, [class length])]; - - if (match) { - if(![data isKindOfClass: [NSArray class]]) { - if(error) { - NSDictionary * userInfo = @{NSLocalizedDescriptionKey : NSLocalizedString(@"Received response is not an array", nil)}; - *error = [NSError errorWithDomain:SWGDeserializationErrorDomainKey code:SWGTypeMismatchErrorCode userInfo:userInfo]; - } - return nil; - } - NSArray *dataArray = data; - innerType = [class substringWithRange:[match rangeAtIndex:1]]; - - resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; - [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - id arrObj = [self deserialize:obj class:innerType error:error]; - if(arrObj) { - [resultArray addObject:arrObj]; - } else { - * stop = YES; - } - }]; - - return resultArray; - } - - // list of primitives - NSString *arrayOfPrimitivesPat = @"NSArray\\* /\\* (.+) \\*/"; - regexp = [NSRegularExpression regularExpressionWithPattern:arrayOfPrimitivesPat - options:NSRegularExpressionCaseInsensitive - error:nil]; - match = [regexp firstMatchInString:class - options:0 - range:NSMakeRange(0, [class length])]; - - if (match) { - NSArray *dataArray = data; - innerType = [class substringWithRange:[match rangeAtIndex:1]]; - - resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; - [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - id arrObj = [self deserialize:obj class:innerType error:error]; - if(arrObj) { - [resultArray addObject:arrObj]; - } else { - * stop = YES; - } - }]; - - return resultArray; - } - - // map - NSString *dictPat = @"NSDictionary\\* /\\* (.+?), (.+) \\*/"; - regexp = [NSRegularExpression regularExpressionWithPattern:dictPat - options:NSRegularExpressionCaseInsensitive - error:nil]; - match = [regexp firstMatchInString:class - options:0 - range:NSMakeRange(0, [class length])]; - - if (match) { - NSDictionary *dataDict = data; - NSString *valueType = [class substringWithRange:[match rangeAtIndex:2]]; - - resultDict = [NSMutableDictionary dictionaryWithCapacity:[dataDict count]]; - [data enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { - id dicObj = [self deserialize:obj class:valueType error:error]; - if(dicObj) { - [resultDict setValue:dicObj forKey:key]; - } else { - * stop = YES; - } - }]; - - return resultDict; - } - - // primitives - NSArray *primitiveTypes = @[@"NSString", @"NSDate", @"NSNumber"]; - - if ([primitiveTypes containsObject:class]) { - if ([class isEqualToString:@"NSString"]) { - return [NSString stringWithString:data]; - } - else if ([class isEqualToString:@"NSDate"]) { - return [NSDate dateWithISO8601String:data]; - } - else if ([class isEqualToString:@"NSNumber"]) { - // NSNumber from NSNumber - if ([data isKindOfClass:[NSNumber class]]) { - return data; - } - else if ([data isKindOfClass:[NSString class]]) { - // NSNumber (NSCFBoolean) from NSString - if ([[data lowercaseString] isEqualToString:@"true"] || [[data lowercaseString] isEqualToString:@"false"]) { - return [NSNumber numberWithBool:[data boolValue]]; - // NSNumber from NSString - } else { - NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; - formatter.numberStyle = NSNumberFormatterDecimalStyle; - return [formatter numberFromString:data]; - } - } - } - } - - // model - Class ModelClass = NSClassFromString(class); - if ([ModelClass instancesRespondToSelector:@selector(initWithDictionary:error:)]) { - return [(JSONModel *) [ModelClass alloc] initWithDictionary:data error:error]; - } - - return nil; -} - #pragma mark - Operation Methods - (void) operationWithCompletionBlock: (NSURLRequest *)request @@ -661,7 +510,7 @@ static void (^reachabilityChangeBlock)(int); else { [self operationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) { NSError * serializationError; - id response = [self deserialize:data class:responseType error:&serializationError]; + id response = [self.responseDeserializer deserialize:data class:responseType error:&serializationError]; if(!response && !error){ error = serializationError; } diff --git a/samples/client/petstore/objc/SwaggerClient/SWGCategory.m b/samples/client/petstore/objc/SwaggerClient/SWGCategory.m index c323eda5a0a..29e3bc16226 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGCategory.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGCategory.m @@ -4,12 +4,10 @@ - (instancetype)init { self = [super init]; - if (self) { // initalise property's default value, if any } - return self; } @@ -18,8 +16,7 @@ * Maps json key to property name. * This method is used by `JSONModel`. */ -+ (JSONKeyMapper *)keyMapper -{ ++ (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }]; } @@ -28,24 +25,11 @@ * If `propertyName` is optional, then return `YES`, otherwise return `NO`. * This method is used by `JSONModel`. */ -+ (BOOL)propertyIsOptional:(NSString *)propertyName -{ ++ (BOOL)propertyIsOptional:(NSString *)propertyName { + NSArray *optionalProperties = @[@"_id", @"name"]; + return [optionalProperties containsObject:propertyName]; - if ([optionalProperties containsObject:propertyName]) { - return YES; - } - else { - return NO; - } -} - -/** - * Gets the string presentation of the object. - * This method will be called when logging model object using `NSLog`. - */ -- (NSString *)description { - return [[self toDictionary] description]; } @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h b/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h deleted file mode 100644 index 577434faae6..00000000000 --- a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h +++ /dev/null @@ -1,32 +0,0 @@ -#import -#import "SWGObject.h" - -/** - * 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. - */ - -#import "SWGTag.h" - - -@protocol SWGInlineResponse200 -@end - -@interface SWGInlineResponse200 : SWGObject - - -@property(nonatomic) NSArray* /* NSString */ photoUrls; - -@property(nonatomic) NSString* name; - -@property(nonatomic) NSNumber* _id; - -@property(nonatomic) NSObject* category; - -@property(nonatomic) NSArray* tags; -/* pet status in the store [optional] - */ -@property(nonatomic) NSString* status; - -@end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m b/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m deleted file mode 100644 index 5fbe9ec6ec2..00000000000 --- a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m +++ /dev/null @@ -1,51 +0,0 @@ -#import "SWGInlineResponse200.h" - -@implementation SWGInlineResponse200 - -- (instancetype)init { - self = [super init]; - - if (self) { - // initalise property's default value, if any - - } - - return self; -} - - -/** - * Maps json key to property name. - * This method is used by `JSONModel`. - */ -+ (JSONKeyMapper *)keyMapper -{ - return [[JSONKeyMapper alloc] initWithDictionary:@{ @"photoUrls": @"photoUrls", @"name": @"name", @"id": @"_id", @"category": @"category", @"tags": @"tags", @"status": @"status" }]; -} - -/** - * Indicates whether the property with the given name is optional. - * If `propertyName` is optional, then return `YES`, otherwise return `NO`. - * This method is used by `JSONModel`. - */ -+ (BOOL)propertyIsOptional:(NSString *)propertyName -{ - NSArray *optionalProperties = @[@"photoUrls", @"name", @"category", @"tags", @"status"]; - - if ([optionalProperties containsObject:propertyName]) { - return YES; - } - else { - return NO; - } -} - -/** - * Gets the string presentation of the object. - * This method will be called when logging model object using `NSLog`. - */ -- (NSString *)description { - return [[self toDictionary] description]; -} - -@end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGName.h b/samples/client/petstore/objc/SwaggerClient/SWGName.h deleted file mode 100644 index fd34af7b66a..00000000000 --- a/samples/client/petstore/objc/SwaggerClient/SWGName.h +++ /dev/null @@ -1,22 +0,0 @@ -#import -#import "SWGObject.h" - -/** - * 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. - */ - - - -@protocol SWGName -@end - -@interface SWGName : SWGObject - - -@property(nonatomic) NSNumber* name; - -@property(nonatomic) NSNumber* snakeCase; - -@end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGName.m b/samples/client/petstore/objc/SwaggerClient/SWGName.m deleted file mode 100644 index 16aec784549..00000000000 --- a/samples/client/petstore/objc/SwaggerClient/SWGName.m +++ /dev/null @@ -1,51 +0,0 @@ -#import "SWGName.h" - -@implementation SWGName - -- (instancetype)init { - self = [super init]; - - if (self) { - // initalise property's default value, if any - - } - - return self; -} - - -/** - * Maps json key to property name. - * This method is used by `JSONModel`. - */ -+ (JSONKeyMapper *)keyMapper -{ - return [[JSONKeyMapper alloc] initWithDictionary:@{ @"name": @"name", @"snake_case": @"snakeCase" }]; -} - -/** - * Indicates whether the property with the given name is optional. - * If `propertyName` is optional, then return `YES`, otherwise return `NO`. - * This method is used by `JSONModel`. - */ -+ (BOOL)propertyIsOptional:(NSString *)propertyName -{ - NSArray *optionalProperties = @[@"snakeCase"]; - - if ([optionalProperties containsObject:propertyName]) { - return YES; - } - else { - return NO; - } -} - -/** - * Gets the string presentation of the object. - * This method will be called when logging model object using `NSLog`. - */ -- (NSString *)description { - return [[self toDictionary] description]; -} - -@end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGObject.m b/samples/client/petstore/objc/SwaggerClient/SWGObject.m index 1f897ab1d56..8085c404f7e 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGObject.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGObject.m @@ -1,4 +1,13 @@ #import "SWGObject.h" @implementation SWGObject + +/** + * Gets the string presentation of the object. + * This method will be called when logging model object using `NSLog`. + */ +- (NSString *)description { + return [[self toDictionary] description]; +} + @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m index e41bc7a188d..d10ed802b8d 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m @@ -4,12 +4,10 @@ - (instancetype)init { self = [super init]; - if (self) { // initalise property's default value, if any } - return self; } @@ -18,8 +16,7 @@ * Maps json key to property name. * This method is used by `JSONModel`. */ -+ (JSONKeyMapper *)keyMapper -{ ++ (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"petId": @"petId", @"quantity": @"quantity", @"shipDate": @"shipDate", @"status": @"status", @"complete": @"complete" }]; } @@ -28,24 +25,11 @@ * If `propertyName` is optional, then return `YES`, otherwise return `NO`. * This method is used by `JSONModel`. */ -+ (BOOL)propertyIsOptional:(NSString *)propertyName -{ ++ (BOOL)propertyIsOptional:(NSString *)propertyName { + NSArray *optionalProperties = @[@"_id", @"petId", @"quantity", @"shipDate", @"status", @"complete"]; + return [optionalProperties containsObject:propertyName]; - if ([optionalProperties containsObject:propertyName]) { - return YES; - } - else { - return NO; - } -} - -/** - * Gets the string presentation of the object. - * This method will be called when logging model object using `NSLog`. - */ -- (NSString *)description { - return [[self toDictionary] description]; } @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPet.m b/samples/client/petstore/objc/SwaggerClient/SWGPet.m index 86389c2590b..98e75189ed3 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPet.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGPet.m @@ -4,12 +4,10 @@ - (instancetype)init { self = [super init]; - if (self) { // initalise property's default value, if any } - return self; } @@ -18,8 +16,7 @@ * Maps json key to property name. * This method is used by `JSONModel`. */ -+ (JSONKeyMapper *)keyMapper -{ ++ (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"category": @"category", @"name": @"name", @"photoUrls": @"photoUrls", @"tags": @"tags", @"status": @"status" }]; } @@ -28,24 +25,11 @@ * If `propertyName` is optional, then return `YES`, otherwise return `NO`. * This method is used by `JSONModel`. */ -+ (BOOL)propertyIsOptional:(NSString *)propertyName -{ ++ (BOOL)propertyIsOptional:(NSString *)propertyName { + NSArray *optionalProperties = @[@"_id", @"category", @"tags", @"status"]; + return [optionalProperties containsObject:propertyName]; - if ([optionalProperties containsObject:propertyName]) { - return YES; - } - else { - return NO; - } -} - -/** - * Gets the string presentation of the object. - * This method will be called when logging model object using `NSLog`. - */ -- (NSString *)description { - return [[self toDictionary] description]; } @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGResponseDeserializer.h b/samples/client/petstore/objc/SwaggerClient/SWGResponseDeserializer.h new file mode 100644 index 00000000000..b20ead44f83 --- /dev/null +++ b/samples/client/petstore/objc/SwaggerClient/SWGResponseDeserializer.h @@ -0,0 +1,50 @@ +#import + +/** + * 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. + */ + +/** + * A key for deserialization ErrorDomain + */ +extern NSString *const SWGDeserializationErrorDomainKey; + +/** + * Code for deserialization type mismatch error + */ +extern NSInteger const SWGTypeMismatchErrorCode; + +/** + * Code for deserialization empty value error + */ +extern NSInteger const SWGEmptyValueOccurredErrorCode; + +/** + * Error code for unknown response + */ +extern NSInteger const SWGUnknownResponseObjectErrorCode; + +@protocol SWGResponseDeserializer + +/** + * Deserializes the given data to Objective-C object. + * + * @param data The data will be deserialized. + * @param class The type of objective-c object. + * @param error The error + */ +- (id) deserialize:(id) data class:(NSString *) className error:(NSError**)error; + +@end + +@interface SWGResponseDeserializer : NSObject + +/** + * If an null value occurs in dictionary or array if set to YES whole response will be invalid else will be ignored + * @default NO + */ +@property (nonatomic, assign) BOOL treatNullAsError; + +@end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGResponseDeserializer.m b/samples/client/petstore/objc/SwaggerClient/SWGResponseDeserializer.m new file mode 100644 index 00000000000..fa5be3af3d2 --- /dev/null +++ b/samples/client/petstore/objc/SwaggerClient/SWGResponseDeserializer.m @@ -0,0 +1,231 @@ +#import "SWGResponseDeserializer.h" +#import +#import + +NSString *const SWGDeserializationErrorDomainKey = @"SWGDeserializationErrorDomainKey"; + +NSInteger const SWGTypeMismatchErrorCode = 143553; + +NSInteger const SWGEmptyValueOccurredErrorCode = 143509; + +NSInteger const SWGUnknownResponseObjectErrorCode = 143528; + + +@interface SWGResponseDeserializer () + +@property (nonatomic, strong) NSNumberFormatter* numberFormatter; +@property (nonatomic, strong) NSArray *primitiveTypes; +@property (nonatomic, strong) NSArray *basicReturnTypes; + +@property (nonatomic, strong) NSRegularExpression* arrayOfModelsPatExpression; +@property (nonatomic, strong) NSRegularExpression* arrayOfPrimitivesPatExpression; +@property (nonatomic, strong) NSRegularExpression* dictPatExpression; +@property (nonatomic, strong) NSRegularExpression* dictModelsPatExpression; + +@end + +@implementation SWGResponseDeserializer + +- (instancetype)init { + self = [super init]; + if (self) { + NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; + formatter.numberStyle = NSNumberFormatterDecimalStyle; + _numberFormatter = formatter; + _primitiveTypes = @[@"NSString", @"NSDate", @"NSNumber"]; + _basicReturnTypes = @[@"NSObject", @"id"]; + _arrayOfModelsPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSArray<(.+)>" + options:NSRegularExpressionCaseInsensitive + error:nil]; + _arrayOfPrimitivesPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSArray\\* /\\* (.+) \\*/" + options:NSRegularExpressionCaseInsensitive + error:nil]; + _dictPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSDictionary\\* /\\* (.+?), (.+) \\*/" + options:NSRegularExpressionCaseInsensitive + error:nil]; + _dictModelsPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSDictionary\\<(.+?), (.+)*\\>" + options:NSRegularExpressionCaseInsensitive + error:nil]; + } + return self; +} + +#pragma mark - Deserialize methods + +- (id) deserialize:(id) data class:(NSString *) className error:(NSError **) error { + // return nil if data is nil or className is nil + if (!data || !className || [data isKindOfClass:[NSNull class]]) { + return nil; + } + + // remove "*" from className, if ends with "*" + if ([className hasSuffix:@"*"]) { + className = [className substringToIndex:[className length] - 1]; + } + // pure object + if ([self.basicReturnTypes containsObject:className]) { + return data; + } + + // primitives + if ([self.primitiveTypes containsObject:className]) { + return [self deserializePrimitiveValue:data class:className error:error]; + } + + NSTextCheckingResult *match = nil; + NSRange range = NSMakeRange(0, [className length]); + // list of models + match = [self.arrayOfModelsPatExpression firstMatchInString:className options:0 range:range]; + if (match) { + NSString *innerType = [className substringWithRange:[match rangeAtIndex:1]]; + return [self deserializeArrayValue:data innerType:innerType error:error]; + } + + // list of primitives + match = [self.arrayOfPrimitivesPatExpression firstMatchInString:className options:0 range:range]; + if (match) { + NSString *innerType = [className substringWithRange:[match rangeAtIndex:1]]; + return [self deserializeArrayValue:data innerType:innerType error:error]; + } + + // map + match = [self.dictPatExpression firstMatchInString:className options:0 range:range]; + if (match) { + NSString *valueType = [className substringWithRange:[match rangeAtIndex:2]]; + return [self deserializeDictionaryValue:data valueType:valueType error:error]; + } + + match = [self.dictModelsPatExpression firstMatchInString:className options:0 range:range]; + if (match) { + NSString *valueType = [className substringWithRange:[match rangeAtIndex:2]]; + return [self deserializeDictionaryValue:data valueType:valueType error:error]; + } + + // model + Class ModelClass = NSClassFromString(className); + if ([ModelClass instancesRespondToSelector:@selector(initWithDictionary:error:)]) { + return [(JSONModel *) [ModelClass alloc] initWithDictionary:data error:error]; + } + + if(error) { + *error = [self unknownResponseErrorWithExpectedType:className data:data]; + } + return nil; +} + +- (id) deserializeDictionaryValue:(id) data valueType:(NSString *) valueType error:(NSError**)error { + if(![data isKindOfClass: [NSDictionary class]]) { + if(error) { + *error = [self typeMismatchErrorWithExpectedType:NSStringFromClass([NSDictionary class]) data:data]; + } + return nil; + } + __block NSMutableDictionary *resultDict = [NSMutableDictionary dictionaryWithCapacity:[data count]]; + for (id key in [data allKeys]) { + id obj = [data valueForKey:key]; + id dicObj = [self deserialize:obj class:valueType error:error]; + if(dicObj) { + [resultDict setValue:dicObj forKey:key]; + } else if([obj isKindOfClass:[NSNull class]]) { + if(self.treatNullAsError) { + if (error) { + *error = [self emptyValueOccurredError]; + } + resultDict = nil; + break; + } + } else { + resultDict = nil; + break; + } + } + return resultDict; +} + +- (id) deserializeArrayValue:(id) data innerType:(NSString *) innerType error:(NSError**)error { + if(![data isKindOfClass: [NSArray class]]) { + if(error) { + *error = [self typeMismatchErrorWithExpectedType:NSStringFromClass([NSArray class]) data:data]; + } + return nil; + } + NSMutableArray* resultArray = [NSMutableArray arrayWithCapacity:[data count]]; + for (id obj in data) { + id arrObj = [self deserialize:obj class:innerType error:error]; + if(arrObj) { + [resultArray addObject:arrObj]; + } else if([obj isKindOfClass:[NSNull class]]) { + if(self.treatNullAsError) { + if (error) { + *error = [self emptyValueOccurredError]; + } + resultArray = nil; + break; + } + } else { + resultArray = nil; + break; + } + } + return resultArray; +}; + +- (id) deserializePrimitiveValue:(id) data class:(NSString *) className error:(NSError**)error { + if ([className isEqualToString:@"NSString"]) { + return [NSString stringWithString:data]; + } + else if ([className isEqualToString:@"NSDate"]) { + return [self deserializeDateValue:data error:error]; + } + else if ([className isEqualToString:@"NSNumber"]) { + // NSNumber from NSNumber + if ([data isKindOfClass:[NSNumber class]]) { + return data; + } + else if ([data isKindOfClass:[NSString class]]) { + // NSNumber (NSCFBoolean) from NSString + if ([[data lowercaseString] isEqualToString:@"true"] || [[data lowercaseString] isEqualToString:@"false"]) { + return @([data boolValue]); + // NSNumber from NSString + } else { + NSNumber* formattedValue = [self.numberFormatter numberFromString:data]; + if(!formattedValue && [data length] > 0 && error) { + *error = [self typeMismatchErrorWithExpectedType:className data:data]; + } + return formattedValue; + } + } + } + if(error) { + *error = [self typeMismatchErrorWithExpectedType:className data:data]; + } + return nil; +} + +- (id) deserializeDateValue:(id) data error:(NSError**)error { + NSDate *date =[NSDate dateWithISO8601String:data]; + if(!date && [data length] > 0 && error) { + *error = [self typeMismatchErrorWithExpectedType:NSStringFromClass([NSDate class]) data:data]; + } + return date; +}; + +-(NSError *)typeMismatchErrorWithExpectedType:(NSString *)expected data:(id)data { + NSString * message = [NSString stringWithFormat:NSLocalizedString(@"Received response [%@] is not an object of type %@",nil),data, expected]; + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : message}; + return [NSError errorWithDomain:SWGDeserializationErrorDomainKey code:SWGTypeMismatchErrorCode userInfo:userInfo]; +} + +-(NSError *)emptyValueOccurredError { + NSString * message = NSLocalizedString(@"Received response contains null value in dictionary or array response",nil); + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : message}; + return [NSError errorWithDomain:SWGDeserializationErrorDomainKey code:SWGEmptyValueOccurredErrorCode userInfo:userInfo]; +} + +-(NSError *)unknownResponseErrorWithExpectedType:(NSString *)expected data:(id)data { + NSString * message = [NSString stringWithFormat:NSLocalizedString(@"Unknown response expected type %@ [reponse: %@]",nil),expected,data]; + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : message}; + return [NSError errorWithDomain:SWGDeserializationErrorDomainKey code:SWGUnknownResponseObjectErrorCode userInfo:userInfo]; +} + +@end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGReturn.h b/samples/client/petstore/objc/SwaggerClient/SWGReturn.h deleted file mode 100644 index fcce78f3681..00000000000 --- a/samples/client/petstore/objc/SwaggerClient/SWGReturn.h +++ /dev/null @@ -1,20 +0,0 @@ -#import -#import "SWGObject.h" - -/** - * 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. - */ - - - -@protocol SWGReturn -@end - -@interface SWGReturn : SWGObject - - -@property(nonatomic) NSNumber* _return; - -@end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGReturn.m b/samples/client/petstore/objc/SwaggerClient/SWGReturn.m deleted file mode 100644 index ad97f1b15e9..00000000000 --- a/samples/client/petstore/objc/SwaggerClient/SWGReturn.m +++ /dev/null @@ -1,51 +0,0 @@ -#import "SWGReturn.h" - -@implementation SWGReturn - -- (instancetype)init { - self = [super init]; - - if (self) { - // initalise property's default value, if any - - } - - return self; -} - - -/** - * Maps json key to property name. - * This method is used by `JSONModel`. - */ -+ (JSONKeyMapper *)keyMapper -{ - return [[JSONKeyMapper alloc] initWithDictionary:@{ @"return": @"_return" }]; -} - -/** - * Indicates whether the property with the given name is optional. - * If `propertyName` is optional, then return `YES`, otherwise return `NO`. - * This method is used by `JSONModel`. - */ -+ (BOOL)propertyIsOptional:(NSString *)propertyName -{ - NSArray *optionalProperties = @[@"_return"]; - - if ([optionalProperties containsObject:propertyName]) { - return YES; - } - else { - return NO; - } -} - -/** - * Gets the string presentation of the object. - * This method will be called when logging model object using `NSLog`. - */ -- (NSString *)description { - return [[self toDictionary] description]; -} - -@end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGSpecialModelName_.h b/samples/client/petstore/objc/SwaggerClient/SWGSpecialModelName_.h deleted file mode 100644 index 88187b28877..00000000000 --- a/samples/client/petstore/objc/SwaggerClient/SWGSpecialModelName_.h +++ /dev/null @@ -1,20 +0,0 @@ -#import -#import "SWGObject.h" - -/** - * 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. - */ - - - -@protocol SWGSpecialModelName_ -@end - -@interface SWGSpecialModelName_ : SWGObject - - -@property(nonatomic) NSNumber* specialPropertyName; - -@end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGSpecialModelName_.m b/samples/client/petstore/objc/SwaggerClient/SWGSpecialModelName_.m deleted file mode 100644 index 9e1e680787d..00000000000 --- a/samples/client/petstore/objc/SwaggerClient/SWGSpecialModelName_.m +++ /dev/null @@ -1,51 +0,0 @@ -#import "SWGSpecialModelName_.h" - -@implementation SWGSpecialModelName_ - -- (instancetype)init { - self = [super init]; - - if (self) { - // initalise property's default value, if any - - } - - return self; -} - - -/** - * Maps json key to property name. - * This method is used by `JSONModel`. - */ -+ (JSONKeyMapper *)keyMapper -{ - return [[JSONKeyMapper alloc] initWithDictionary:@{ @"$special[property.name]": @"specialPropertyName" }]; -} - -/** - * Indicates whether the property with the given name is optional. - * If `propertyName` is optional, then return `YES`, otherwise return `NO`. - * This method is used by `JSONModel`. - */ -+ (BOOL)propertyIsOptional:(NSString *)propertyName -{ - NSArray *optionalProperties = @[@"specialPropertyName"]; - - if ([optionalProperties containsObject:propertyName]) { - return YES; - } - else { - return NO; - } -} - -/** - * Gets the string presentation of the object. - * This method will be called when logging model object using `NSLog`. - */ -- (NSString *)description { - return [[self toDictionary] description]; -} - -@end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGTag.m b/samples/client/petstore/objc/SwaggerClient/SWGTag.m index 9eb00a157e3..8ad1742750d 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGTag.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGTag.m @@ -4,12 +4,10 @@ - (instancetype)init { self = [super init]; - if (self) { // initalise property's default value, if any } - return self; } @@ -18,8 +16,7 @@ * Maps json key to property name. * This method is used by `JSONModel`. */ -+ (JSONKeyMapper *)keyMapper -{ ++ (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }]; } @@ -28,24 +25,11 @@ * If `propertyName` is optional, then return `YES`, otherwise return `NO`. * This method is used by `JSONModel`. */ -+ (BOOL)propertyIsOptional:(NSString *)propertyName -{ ++ (BOOL)propertyIsOptional:(NSString *)propertyName { + NSArray *optionalProperties = @[@"_id", @"name"]; + return [optionalProperties containsObject:propertyName]; - if ([optionalProperties containsObject:propertyName]) { - return YES; - } - else { - return NO; - } -} - -/** - * Gets the string presentation of the object. - * This method will be called when logging model object using `NSLog`. - */ -- (NSString *)description { - return [[self toDictionary] description]; } @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUser.m b/samples/client/petstore/objc/SwaggerClient/SWGUser.m index 2445dd37854..2551108cb5f 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUser.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGUser.m @@ -4,12 +4,10 @@ - (instancetype)init { self = [super init]; - if (self) { // initalise property's default value, if any } - return self; } @@ -18,8 +16,7 @@ * Maps json key to property name. * This method is used by `JSONModel`. */ -+ (JSONKeyMapper *)keyMapper -{ ++ (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"username": @"username", @"firstName": @"firstName", @"lastName": @"lastName", @"email": @"email", @"password": @"password", @"phone": @"phone", @"userStatus": @"userStatus" }]; } @@ -28,24 +25,11 @@ * If `propertyName` is optional, then return `YES`, otherwise return `NO`. * This method is used by `JSONModel`. */ -+ (BOOL)propertyIsOptional:(NSString *)propertyName -{ ++ (BOOL)propertyIsOptional:(NSString *)propertyName { + NSArray *optionalProperties = @[@"_id", @"username", @"firstName", @"lastName", @"email", @"password", @"phone", @"userStatus"]; + return [optionalProperties containsObject:propertyName]; - if ([optionalProperties containsObject:propertyName]) { - return YES; - } - else { - return NO; - } -} - -/** - * Gets the string presentation of the object. - * This method will be called when logging model object using `NSLog`. - */ -- (NSString *)description { - return [[self toDictionary] description]; } @end diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m b/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m index 5f5d274b4b0..3284336a64b 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m +++ b/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m @@ -27,11 +27,28 @@ [formatter setDateFormat:@"yyyy-MM-dd"]; NSDate *date = [formatter dateFromString:dateStr]; NSError* error; - NSDate *deserializedDate = [apiClient deserialize:dateStr class:@"NSDate*" error:&error]; + NSDate *deserializedDate = [apiClient.responseDeserializer deserialize:dateStr class:@"NSDate*" error:&error]; XCTAssertNil(error); XCTAssertEqualWithAccuracy([date timeIntervalSinceReferenceDate], [deserializedDate timeIntervalSinceReferenceDate], 0.001); } +- (void)testDeserializeInvalidDate { + NSString *dateStr = @"random string"; + + NSError* error; + NSDate *deserializedDate = [apiClient.responseDeserializer deserialize:dateStr class:@"NSDate*" error:&error]; + XCTAssertNotNil(error); + XCTAssertNil(deserializedDate); +} + +- (void)testDeserializeEmptyDate { + NSString *dateStr = @""; + NSError* error; + NSDate *deserializedDate = [apiClient.responseDeserializer deserialize:dateStr class:@"NSDate*" error:&error]; + XCTAssertNil(error); + XCTAssertNil(deserializedDate); +} + - (void)testDeserializeDateTime { NSString *dateTimeStr = @"1997-07-16T19:20:30+00:00"; @@ -39,15 +56,23 @@ [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"]; NSDate *dateTime = [formatter dateFromString:dateTimeStr]; NSError* error; - NSDate *deserializedDateTime = [apiClient deserialize:dateTimeStr class:@"NSDate*" error:&error]; + NSDate *deserializedDateTime = [apiClient.responseDeserializer deserialize:dateTimeStr class:@"NSDate*" error:&error]; XCTAssertNil(error); XCTAssertEqualWithAccuracy([dateTime timeIntervalSinceReferenceDate], [deserializedDateTime timeIntervalSinceReferenceDate], 0.001); } +- (void)testDeserializeUnknownObject { + NSString *data = @"random string"; + NSError* error; + NSNumber *result = [apiClient.responseDeserializer deserialize:data class:@"DeserializationTest*" error:&error]; + XCTAssertNotNil(error); + XCTAssertNil(result); +} + - (void)testDeserializeObject { NSNumber *data = @1; NSError* error; - NSNumber *result = [apiClient deserialize:data class:@"NSObject*" error:&error]; + NSNumber *result = [apiClient.responseDeserializer deserialize:data class:@"NSObject*" error:&error]; XCTAssertNil(error); XCTAssertEqualObjects(data, result); } @@ -55,7 +80,7 @@ - (void)testDeserializeString { NSString *data = @"test string"; NSError* error; - NSString *result = [apiClient deserialize:data class:@"NSString*" error:&error]; + NSString *result = [apiClient.responseDeserializer deserialize:data class:@"NSString*" error:&error]; XCTAssertNil(error); XCTAssertTrue([result isEqualToString:data]); } @@ -63,12 +88,29 @@ - (void)testDeserializeListOfString { NSArray *data = @[@"test string"]; NSError* error; - NSArray *result = [apiClient deserialize:data class:@"NSArray* /* NSString */" error:&error]; + NSArray *result = [apiClient.responseDeserializer deserialize:data class:@"NSArray*" error:&error]; XCTAssertNil(error); XCTAssertTrue([result isKindOfClass:[NSArray class]]); XCTAssertTrue([result[0] isKindOfClass:[NSString class]]); } +- (void)testDeserializeInvalidListOfNumbers { + NSArray *data = @[@"test string"]; + NSError* error; + NSArray *result = [apiClient.responseDeserializer deserialize:data class:@"NSArray*" error:&error]; + XCTAssertNotNil(error); + XCTAssertNil(result); +} + +- (void)testDeserializeListOfNumbers { + NSArray *data = @[@"1.0"]; + NSError* error; + NSArray *result = [apiClient.responseDeserializer deserialize:data class:@"NSArray*" error:&error]; + XCTAssertNil(error); + XCTAssertTrue([result isKindOfClass:[NSArray class]]); + XCTAssertTrue([result[0] isKindOfClass:[NSNumber class]]); +} + - (void)testDeserializeListOfModels { NSArray *data = @[ @@ -92,7 +134,7 @@ }]; NSError* error; - NSArray *result = [apiClient deserialize:data class:@"NSArray*" error:&error]; + NSArray *result = [apiClient.responseDeserializer deserialize:data class:@"NSArray*" error:&error]; XCTAssertTrue([result isKindOfClass:[NSArray class]]); XCTAssertTrue([[result firstObject] isKindOfClass:[SWGPet class]]); @@ -123,7 +165,7 @@ } }; NSError* error; - NSDictionary *result = [apiClient deserialize:data class:@"NSDictionary* /* NSString, SWGPet */" error:&error]; + NSDictionary *result = [apiClient.responseDeserializer deserialize:data class:@"NSDictionary* /* NSString, SWGPet */" error:&error]; XCTAssertTrue([result isKindOfClass:[NSDictionary class]]); XCTAssertTrue([result[@"pet"] isKindOfClass:[SWGPet class]]); @@ -134,11 +176,44 @@ NSDictionary *data = @{ @"foo": @{ - @"bar": @1 + @"bar": @1, + @"bar2": [NSNull null] } }; + SWGResponseDeserializer* responseDeserializer = [[SWGResponseDeserializer alloc] init]; NSError* error; - NSDictionary *result = [apiClient deserialize:data class:@"NSDictionary* /* NSString, NSDictionary* /* NSString, NSNumber */ */" error:&error]; + NSDictionary *result = [responseDeserializer deserialize:data class:@"NSDictionary* /* NSString, NSDictionary* /* NSString, NSNumber */ */" error:&error]; + + XCTAssertTrue([result isKindOfClass:[NSDictionary class]]); + XCTAssertTrue([result[@"foo"] isKindOfClass:[NSDictionary class]]); + XCTAssertTrue([result[@"foo"][@"bar"] isKindOfClass:[NSNumber class]]); +} + + +- (void)testDeserializeNestedMapWithNullValue { + NSDictionary *data = + @{ + @"foo": @{ + @"bar": @1, + @"bar2": [NSNull null] + } + }; + SWGResponseDeserializer* responseDeserializer = [[SWGResponseDeserializer alloc] init]; + responseDeserializer.treatNullAsError = YES; + NSError* error; + NSDictionary *result = [responseDeserializer deserialize:data class:@"NSDictionary* /* NSString, NSDictionary* /* NSString, NSNumber */ */" error:&error]; + XCTAssertNil(result); + XCTAssertNotNil(error); +} + +- (void)testDeserializeNestedMap2 { + NSDictionary *data = @{ + @"foo": @{ + @"bar": @1 + } + }; + NSError* error; + NSDictionary *result = [apiClient.responseDeserializer deserialize:data class:@"NSDictionary*>*" error:&error]; XCTAssertTrue([result isKindOfClass:[NSDictionary class]]); XCTAssertTrue([result[@"foo"] isKindOfClass:[NSDictionary class]]); @@ -148,7 +223,7 @@ - (void)testDeserializeNestedList { NSArray *data = @[@[@"foo"]]; NSError* error; - NSArray *result = [apiClient deserialize:data class:@"NSArray* /* NSArray* /* NSString */ */" error:&error]; + NSArray *result = [apiClient.responseDeserializer deserialize:data class:@"NSArray* /* NSArray* /* NSString */ */" error:&error]; XCTAssertTrue([result isKindOfClass:[NSArray class]]); XCTAssertTrue([result[0] isKindOfClass:[NSArray class]]); @@ -161,11 +236,11 @@ data = @"true"; NSError* error; - result = [apiClient deserialize:data class:@"NSNumber*" error:&error]; + result = [apiClient.responseDeserializer deserialize:data class:@"NSNumber*" error:&error]; XCTAssertTrue([result isEqual:@YES]); data = @"false"; - result = [apiClient deserialize:data class:@"NSNumber*" error:&error]; + result = [apiClient.responseDeserializer deserialize:data class:@"NSNumber*" error:&error]; XCTAssertTrue([result isEqual:@NO]); } diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/PetApiTest.m b/samples/client/petstore/objc/SwaggerClientTests/Tests/PetApiTest.m index 7fd3d4f97c8..7ddc817e9ef 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/Tests/PetApiTest.m +++ b/samples/client/petstore/objc/SwaggerClientTests/Tests/PetApiTest.m @@ -165,7 +165,7 @@ which causes an exception when deserializing the data SWGTag* tag = [[SWGTag alloc] init]; tag.name = @"tony"; NSLog(@"%@", pet._id); - pet.tags = [[NSArray alloc] initWithObjects:tag, nil]; + pet.tags = (id)[[NSArray alloc] initWithObjects:tag, nil]; [api addPetWithBody:pet completionHandler:^(NSError *error) { if(error) { diff --git a/samples/client/petstore/objc/git_push.sh b/samples/client/petstore/objc/git_push.sh index 1a36388db02..ed374619b13 100644 --- a/samples/client/petstore/objc/git_push.sh +++ b/samples/client/petstore/objc/git_push.sh @@ -8,12 +8,12 @@ git_repo_id=$2 release_note=$3 if [ "$git_user_id" = "" ]; then - git_user_id="YOUR_GIT_USR_ID" + git_user_id="GIT_USER_ID" echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" fi if [ "$git_repo_id" = "" ]; then - git_repo_id="YOUR_GIT_REPO_ID" + git_repo_id="GIT_REPO_ID" echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" fi diff --git a/samples/server/petstore/nodejs/api/swagger.yaml b/samples/server/petstore/nodejs/api/swagger.yaml index 1aad0a1d4f4..f6987daa915 100644 --- a/samples/server/petstore/nodejs/api/swagger.yaml +++ b/samples/server/petstore/nodejs/api/swagger.yaml @@ -587,10 +587,6 @@ paths: description: "User not found" x-swagger-router-controller: "User" securityDefinitions: - api_key: - type: "apiKey" - name: "api_key" - in: "header" petstore_auth: type: "oauth2" authorizationUrl: "http://petstore.swagger.io/api/oauth/dialog" @@ -598,6 +594,10 @@ securityDefinitions: scopes: write:pets: "modify pets in your account" read:pets: "read your pets" + api_key: + type: "apiKey" + name: "api_key" + in: "header" definitions: Order: type: "object" diff --git a/samples/server/petstore/nodejs/controllers/PetService.js b/samples/server/petstore/nodejs/controllers/PetService.js index 95f42f6a038..2c464714aa7 100644 --- a/samples/server/petstore/nodejs/controllers/PetService.js +++ b/samples/server/petstore/nodejs/controllers/PetService.js @@ -13,7 +13,7 @@ exports.deletePet = function(args, res, next) { /** * parameters expected in the args: * petId (Long) - * apiKey (String) + * api_key (String) **/ // no response value expected for this operation res.end(); @@ -26,18 +26,18 @@ exports.findPetsByStatus = function(args, res, next) { **/ var examples = {}; examples['application/json'] = [ { - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 123456789, "category" : { - "id" : 123456789, - "name" : "aeiou" + "name" : "aeiou", + "id" : 123456789 }, - "status" : "aeiou", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" } ]; if(Object.keys(examples).length > 0) { res.setHeader('Content-Type', 'application/json'); @@ -56,18 +56,18 @@ exports.findPetsByTags = function(args, res, next) { **/ var examples = {}; examples['application/json'] = [ { - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 123456789, "category" : { - "id" : 123456789, - "name" : "aeiou" + "name" : "aeiou", + "id" : 123456789 }, - "status" : "aeiou", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" } ]; if(Object.keys(examples).length > 0) { res.setHeader('Content-Type', 'application/json'); @@ -86,18 +86,18 @@ exports.getPetById = function(args, res, next) { **/ var examples = {}; examples['application/json'] = { - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 123456789, "category" : { - "id" : 123456789, - "name" : "aeiou" + "name" : "aeiou", + "id" : 123456789 }, - "status" : "aeiou", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" }; if(Object.keys(examples).length > 0) { res.setHeader('Content-Type', 'application/json'); @@ -138,9 +138,9 @@ exports.uploadFile = function(args, res, next) { **/ var examples = {}; examples['application/json'] = { - "message" : "aeiou", "code" : 123, - "type" : "aeiou" + "type" : "aeiou", + "message" : "aeiou" }; if(Object.keys(examples).length > 0) { res.setHeader('Content-Type', 'application/json'); diff --git a/samples/server/petstore/nodejs/controllers/StoreService.js b/samples/server/petstore/nodejs/controllers/StoreService.js index 01759173bd4..d20619ceb9b 100644 --- a/samples/server/petstore/nodejs/controllers/StoreService.js +++ b/samples/server/petstore/nodejs/controllers/StoreService.js @@ -34,12 +34,12 @@ exports.getOrderById = function(args, res, next) { **/ var examples = {}; examples['application/json'] = { - "id" : 123456789, "petId" : 123456789, - "complete" : true, - "status" : "aeiou", "quantity" : 123, - "shipDate" : "2000-01-23T04:56:07.000+0000" + "id" : 123456789, + "shipDate" : "2000-01-23T04:56:07.000+0000", + "complete" : true, + "status" : "aeiou" }; if(Object.keys(examples).length > 0) { res.setHeader('Content-Type', 'application/json'); @@ -58,12 +58,12 @@ exports.placeOrder = function(args, res, next) { **/ var examples = {}; examples['application/json'] = { - "id" : 123456789, "petId" : 123456789, - "complete" : true, - "status" : "aeiou", "quantity" : 123, - "shipDate" : "2000-01-23T04:56:07.000+0000" + "id" : 123456789, + "shipDate" : "2000-01-23T04:56:07.000+0000", + "complete" : true, + "status" : "aeiou" }; if(Object.keys(examples).length > 0) { res.setHeader('Content-Type', 'application/json'); diff --git a/samples/server/petstore/nodejs/controllers/UserService.js b/samples/server/petstore/nodejs/controllers/UserService.js index 69fc1a81391..3a62feeaf3f 100644 --- a/samples/server/petstore/nodejs/controllers/UserService.js +++ b/samples/server/petstore/nodejs/controllers/UserService.js @@ -43,14 +43,14 @@ exports.getUserByName = function(args, res, next) { **/ var examples = {}; examples['application/json'] = { - "id" : 123456789, - "lastName" : "aeiou", - "phone" : "aeiou", - "username" : "aeiou", - "email" : "aeiou", - "userStatus" : 123, "firstName" : "aeiou", - "password" : "aeiou" + "lastName" : "aeiou", + "password" : "aeiou", + "userStatus" : 123, + "phone" : "aeiou", + "id" : 123456789, + "email" : "aeiou", + "username" : "aeiou" }; if(Object.keys(examples).length > 0) { res.setHeader('Content-Type', 'application/json'); diff --git a/samples/server/petstore/nodejs/package.json b/samples/server/petstore/nodejs/package.json index 293316dac0e..c5884b196b9 100644 --- a/samples/server/petstore/nodejs/package.json +++ b/samples/server/petstore/nodejs/package.json @@ -11,6 +11,6 @@ "dependencies": { "connect": "^3.2.0", "js-yaml": "^3.3.0", - "swagger-tools": "0.9.*" + "swagger-tools": "0.10.1" } }