forked from loafle/openapi-generator-original
Merge branch 'master' of https://github.com/swagger-api/swagger-codegen
This commit is contained in:
commit
c3690d8675
10
.gitignore
vendored
10
.gitignore
vendored
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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%
|
||||
|
@ -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<String> collectionTypes;
|
||||
protected Set<String> 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";
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -839,6 +839,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
objs = super.postProcessModelsEnum(objs);
|
||||
List<Object> models = (List<Object>) objs.get("models");
|
||||
for (Object _mo : models) {
|
||||
Map<String, Object> mo = (Map<String, Object>) _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<String, Object> 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<Object> values = (List<Object>) allowableValues.get("values");
|
||||
if (values == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// put "enumVars" map into `allowableValues", including `name` and `value`
|
||||
List<Map<String, String>> enumVars = new ArrayList<Map<String, String>>();
|
||||
String commonPrefix = findCommonPrefixOfVars(values);
|
||||
int truncateIdx = commonPrefix.length();
|
||||
for (Object value : values) {
|
||||
Map<String, String> enumVar = new HashMap<String, String>();
|
||||
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) {
|
||||
|
@ -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"));
|
||||
|
@ -2,6 +2,6 @@
|
||||
|
||||
## Enum
|
||||
|
||||
{{#allowableValues}}
|
||||
* `{{.}}`
|
||||
{{/allowableValues}}
|
||||
{{#allowableValues}}{{#enumVars}}
|
||||
* `{{name}}` (value: `{{{value}}}`)
|
||||
{{/enumVars}}{{/allowableValues}}
|
||||
|
@ -3,5 +3,5 @@
|
||||
## Enum
|
||||
|
||||
{{#allowableValues}}{{#enumVars}}
|
||||
* `{{name}}` (value: `{{value}}`)
|
||||
* `{{name}}` (value: `{{{value}}}`)
|
||||
{{/enumVars}}{{/allowableValues}}
|
||||
|
@ -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}}
|
||||
<a name="{{{datatypeWithEnum}}}"></a>
|
||||
## Enum: {{datatypeWithEnum}}
|
||||
|
||||
{{#allowableValues}}{{#enumVars}}
|
||||
* `{{name}}` (value: `{{{value}}}`)
|
||||
{{/enumVars}}{{/allowableValues}}
|
||||
|
||||
{{/isEnum}}{{/vars}}
|
||||
{{/isEnum}}{{/model}}{{/models}}
|
||||
|
@ -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}}
|
||||
};
|
||||
|
||||
|
@ -39,8 +39,6 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Net.Http.WebRequest" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
@ -48,18 +46,23 @@
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>{{binRelativePath}}/Newtonsoft.Json.8.0.2/lib/{{targetFrameworkNuget}}/Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp">
|
||||
<HintPath>{{binRelativePath}}/RestSharp.105.2.3/lib/{{targetFrameworkNuget}}/RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs"/>
|
||||
<Compile Include="Api\*.cs"/>
|
||||
<Compile Include="Client\*.cs"/>
|
||||
<Compile Include="Model\*.cs"/>
|
||||
<Compile Include="**\*.cs"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{19F1DEBC-DE5E-4517-8062-F000CD499087}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>{{testPackageName}}</RootNamespace>
|
||||
<AssemblyName>{{testPackageName}}</AssemblyName>
|
||||
{{^supportsUWP}}
|
||||
<TargetFrameworkVersion>{{targetFramework}}</TargetFrameworkVersion>
|
||||
{{/supportsUWP}}
|
||||
{{#supportsUWP}}
|
||||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
|
||||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||
{{/supportsUWP}}
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\Newtonsoft.Json.8.0.2\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp">
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="**\*.cs"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\{{packageName}}\{{packageName}}.csproj">
|
||||
<Project>{{packageGuid}}</Project>
|
||||
<Name>{{packageName}}</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NUnit" version="2.6.3" targetFramework="{{targetFrameworkNuget}}" />
|
||||
<package id="RestSharp" version="105.1.0" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />
|
||||
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />
|
||||
</packages>
|
@ -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}}
|
||||
|
@ -127,6 +127,7 @@
|
||||
{{#responses}}
|
||||
<h4 class="field-label">{{code}}</h4>
|
||||
{{message}}
|
||||
{{#simpleType}}<a href="#{{dataType}}">{{dataType}}</a>{{/simpleType}}
|
||||
{{#examples}}
|
||||
<h3 class="field-label">Example data</h3>
|
||||
<div class="example-data-content-type">Content-Type: {{{contentType}}}</div>
|
||||
@ -158,7 +159,7 @@
|
||||
<div class="model">
|
||||
<h3 class="field-label"><a name="{{classname}}">{{classname}}</a> <a class="up" href="#__Models">Up</a></h3>
|
||||
<div class="field-items">
|
||||
{{#vars}}<div class="param">{{name}} {{^required}}(optional){{/required}}</div><div class="param-desc"><span class="param-type">{{datatype}}</span> {{description}}</div>
|
||||
{{#vars}}<div class="param">{{name}} {{^required}}(optional){{/required}}</div><div class="param-desc"><span class="param-type">{{^isPrimitiveType}}<a href="#{{complexType}}">{{datatype}}</a>{{/isPrimitiveType}}</span> {{description}}</div>
|
||||
{{#isEnum}}
|
||||
<div class="param-enum-header">Enum:</div>
|
||||
{{#_enum}}<div class="param-enum">{{this}}</div>{{/_enum}}
|
||||
|
@ -11,6 +11,6 @@
|
||||
"dependencies": {
|
||||
"connect": "^3.2.0",
|
||||
"js-yaml": "^3.3.0",
|
||||
"swagger-tools": "0.9.*"
|
||||
"swagger-tools": "0.10.1"
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -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
|
||||
|
@ -0,0 +1,231 @@
|
||||
#import "{{classPrefix}}ResponseDeserializer.h"
|
||||
#import <JSONModel/JSONModel.h>
|
||||
#import <ISO8601/ISO8601.h>
|
||||
|
||||
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
|
@ -0,0 +1,50 @@
|
||||
#import <Foundation/Foundation.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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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 <NSObject>
|
||||
|
||||
/**
|
||||
* 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
|
@ -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}}
|
||||
|
27
samples/client/petstore/csharp/SwaggerClient/IO.Swagger.sln
Normal file
27
samples/client/petstore/csharp/SwaggerClient/IO.Swagger.sln
Normal file
@ -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
|
@ -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
|
14
samples/client/petstore/csharp/SwaggerClient/build.bat
Normal file
14
samples/client/petstore/csharp/SwaggerClient/build.bat
Normal file
@ -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
|
@ -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
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
91
samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md
Normal file
91
samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md
Normal file
@ -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)
|
||||
|
@ -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)
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for testing FakeApi
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This file is automatically generated by Swagger Codegen.
|
||||
/// Please update the test case below to test the API endpoint.
|
||||
/// </remarks>
|
||||
[TestFixture]
|
||||
public class FakeApiTests
|
||||
{
|
||||
private FakeApi instance;
|
||||
|
||||
/// <summary>
|
||||
/// Setup before each unit test
|
||||
/// </summary>
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
instance = new FakeApi();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up after each unit test
|
||||
/// </summary>
|
||||
[TearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test an instance of FakeApi
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void InstanceTest()
|
||||
{
|
||||
Assert.IsInstanceOf<FakeApi> (instance, "instance is a FakeApi");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Test TestEndpointParameters
|
||||
/// </summary>
|
||||
[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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{19F1DEBC-DE5E-4517-8062-F000CD499087}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>IO.Swagger.Test</RootNamespace>
|
||||
<AssemblyName>IO.Swagger.Test</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp">
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="**\*.cs"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\IO.Swagger\IO.Swagger.csproj">
|
||||
<Project>{AC0D0300-7030-473F-B672-17C40187815A}</Project>
|
||||
<Name>IO.Swagger</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for testing AnimalFarm
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This file is automatically generated by Swagger Codegen.
|
||||
/// Please update the test case below to test the model.
|
||||
/// </remarks>
|
||||
[TestFixture]
|
||||
public class AnimalFarmTests
|
||||
{
|
||||
private AnimalFarm instance;
|
||||
|
||||
/// <summary>
|
||||
/// Setup before each test
|
||||
/// </summary>
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
instance = new AnimalFarm();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up after each test
|
||||
/// </summary>
|
||||
[TearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test an instance of AnimalFarm
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void AnimalFarmInstanceTest()
|
||||
{
|
||||
Assert.IsInstanceOf<AnimalFarm> (instance, "instance is a AnimalFarm");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for testing EnumClass
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This file is automatically generated by Swagger Codegen.
|
||||
/// Please update the test case below to test the model.
|
||||
/// </remarks>
|
||||
[TestFixture]
|
||||
public class EnumClassTests
|
||||
{
|
||||
private EnumClass instance;
|
||||
|
||||
/// <summary>
|
||||
/// Setup before each test
|
||||
/// </summary>
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
instance = new EnumClass();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up after each test
|
||||
/// </summary>
|
||||
[TearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test an instance of EnumClass
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void EnumClassInstanceTest()
|
||||
{
|
||||
Assert.IsInstanceOf<EnumClass> (instance, "instance is a EnumClass");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for testing EnumTest
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This file is automatically generated by Swagger Codegen.
|
||||
/// Please update the test case below to test the model.
|
||||
/// </remarks>
|
||||
[TestFixture]
|
||||
public class EnumTestTests
|
||||
{
|
||||
private EnumTest instance;
|
||||
|
||||
/// <summary>
|
||||
/// Setup before each test
|
||||
/// </summary>
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
instance = new EnumTest();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up after each test
|
||||
/// </summary>
|
||||
[TearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test an instance of EnumTest
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void EnumTestInstanceTest()
|
||||
{
|
||||
Assert.IsInstanceOf<EnumTest> (instance, "instance is a EnumTest");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'EnumString'
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void EnumStringTest()
|
||||
{
|
||||
// TODO: unit test for the property 'EnumString'
|
||||
}
|
||||
/// <summary>
|
||||
/// Test the property 'EnumInteger'
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void EnumIntegerTest()
|
||||
{
|
||||
// TODO: unit test for the property 'EnumInteger'
|
||||
}
|
||||
/// <summary>
|
||||
/// Test the property 'EnumNumber'
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void EnumNumberTest()
|
||||
{
|
||||
// TODO: unit test for the property 'EnumNumber'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NUnit" version="2.6.3" targetFramework="net45" />
|
||||
<package id="RestSharp" version="105.1.0" targetFramework="net45" developmentDependency="true" />
|
||||
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net45" developmentDependency="true" />
|
||||
</packages>
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// </summary>
|
||||
public interface IFakeApi
|
||||
{
|
||||
#region Synchronous Operations
|
||||
/// <summary>
|
||||
/// Fake endpoint for testing various parameters
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Fake endpoint for testing various parameters
|
||||
/// </remarks>
|
||||
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="number">None</param>
|
||||
/// <param name="_double">None</param>
|
||||
/// <param name="_string">None</param>
|
||||
/// <param name="_byte">None</param>
|
||||
/// <param name="integer">None (optional)</param>
|
||||
/// <param name="int32">None (optional)</param>
|
||||
/// <param name="int64">None (optional)</param>
|
||||
/// <param name="_float">None (optional)</param>
|
||||
/// <param name="binary">None (optional)</param>
|
||||
/// <param name="date">None (optional)</param>
|
||||
/// <param name="dateTime">None (optional)</param>
|
||||
/// <param name="password">None (optional)</param>
|
||||
/// <returns></returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Fake endpoint for testing various parameters
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Fake endpoint for testing various parameters
|
||||
/// </remarks>
|
||||
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="number">None</param>
|
||||
/// <param name="_double">None</param>
|
||||
/// <param name="_string">None</param>
|
||||
/// <param name="_byte">None</param>
|
||||
/// <param name="integer">None (optional)</param>
|
||||
/// <param name="int32">None (optional)</param>
|
||||
/// <param name="int64">None (optional)</param>
|
||||
/// <param name="_float">None (optional)</param>
|
||||
/// <param name="binary">None (optional)</param>
|
||||
/// <param name="date">None (optional)</param>
|
||||
/// <param name="dateTime">None (optional)</param>
|
||||
/// <param name="password">None (optional)</param>
|
||||
/// <returns>ApiResponse of Object(void)</returns>
|
||||
ApiResponse<Object> 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
|
||||
/// <summary>
|
||||
/// Fake endpoint for testing various parameters
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Fake endpoint for testing various parameters
|
||||
/// </remarks>
|
||||
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="number">None</param>
|
||||
/// <param name="_double">None</param>
|
||||
/// <param name="_string">None</param>
|
||||
/// <param name="_byte">None</param>
|
||||
/// <param name="integer">None (optional)</param>
|
||||
/// <param name="int32">None (optional)</param>
|
||||
/// <param name="int64">None (optional)</param>
|
||||
/// <param name="_float">None (optional)</param>
|
||||
/// <param name="binary">None (optional)</param>
|
||||
/// <param name="date">None (optional)</param>
|
||||
/// <param name="dateTime">None (optional)</param>
|
||||
/// <param name="password">None (optional)</param>
|
||||
/// <returns>Task of void</returns>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Fake endpoint for testing various parameters
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Fake endpoint for testing various parameters
|
||||
/// </remarks>
|
||||
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="number">None</param>
|
||||
/// <param name="_double">None</param>
|
||||
/// <param name="_string">None</param>
|
||||
/// <param name="_byte">None</param>
|
||||
/// <param name="integer">None (optional)</param>
|
||||
/// <param name="int32">None (optional)</param>
|
||||
/// <param name="int64">None (optional)</param>
|
||||
/// <param name="_float">None (optional)</param>
|
||||
/// <param name="binary">None (optional)</param>
|
||||
/// <param name="date">None (optional)</param>
|
||||
/// <param name="dateTime">None (optional)</param>
|
||||
/// <param name="password">None (optional)</param>
|
||||
/// <returns>Task of ApiResponse</returns>
|
||||
System.Threading.Tasks.Task<ApiResponse<Object>> 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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// </summary>
|
||||
public class FakeApi : IFakeApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FakeApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FakeApi"/> class
|
||||
/// using Configuration object
|
||||
/// </summary>
|
||||
/// <param name="configuration">An instance of Configuration</param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <value>The base path</value>
|
||||
public String GetBasePath()
|
||||
{
|
||||
return this.Configuration.ApiClient.RestClient.BaseUrl.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <value>The base path</value>
|
||||
[Obsolete("SetBasePath is deprecated, please do 'Configuraiton.ApiClient = new ApiClient(\"http://new-path\")' instead.")]
|
||||
public void SetBasePath(String basePath)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the configuration object
|
||||
/// </summary>
|
||||
/// <value>An instance of the Configuration</value>
|
||||
public Configuration Configuration {get; set;}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default header.
|
||||
/// </summary>
|
||||
/// <returns>Dictionary of HTTP header</returns>
|
||||
[Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")]
|
||||
public Dictionary<String, String> DefaultHeader()
|
||||
{
|
||||
return this.Configuration.DefaultHeader;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add default header.
|
||||
/// </summary>
|
||||
/// <param name="key">Header field name.</param>
|
||||
/// <param name="value">Header field value.</param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("AddDefaultHeader is deprecated, please use Configuration.AddDefaultHeader instead.")]
|
||||
public void AddDefaultHeader(string key, string value)
|
||||
{
|
||||
this.Configuration.AddDefaultHeader(key, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fake endpoint for testing various parameters Fake endpoint for testing various parameters
|
||||
/// </summary>
|
||||
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="number">None</param>
|
||||
/// <param name="_double">None</param>
|
||||
/// <param name="_string">None</param>
|
||||
/// <param name="_byte">None</param>
|
||||
/// <param name="integer">None (optional)</param>
|
||||
/// <param name="int32">None (optional)</param>
|
||||
/// <param name="int64">None (optional)</param>
|
||||
/// <param name="_float">None (optional)</param>
|
||||
/// <param name="binary">None (optional)</param>
|
||||
/// <param name="date">None (optional)</param>
|
||||
/// <param name="dateTime">None (optional)</param>
|
||||
/// <param name="password">None (optional)</param>
|
||||
/// <returns></returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fake endpoint for testing various parameters Fake endpoint for testing various parameters
|
||||
/// </summary>
|
||||
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="number">None</param>
|
||||
/// <param name="_double">None</param>
|
||||
/// <param name="_string">None</param>
|
||||
/// <param name="_byte">None</param>
|
||||
/// <param name="integer">None (optional)</param>
|
||||
/// <param name="int32">None (optional)</param>
|
||||
/// <param name="int64">None (optional)</param>
|
||||
/// <param name="_float">None (optional)</param>
|
||||
/// <param name="binary">None (optional)</param>
|
||||
/// <param name="date">None (optional)</param>
|
||||
/// <param name="dateTime">None (optional)</param>
|
||||
/// <param name="password">None (optional)</param>
|
||||
/// <returns>ApiResponse of Object(void)</returns>
|
||||
public ApiResponse<Object> 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<String, String>();
|
||||
var localVarQueryParams = new Dictionary<String, String>();
|
||||
var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
|
||||
var localVarFormParams = new Dictionary<String, String>();
|
||||
var localVarFileParams = new Dictionary<String, FileParameter>();
|
||||
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<Object>(localVarStatusCode,
|
||||
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
||||
null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fake endpoint for testing various parameters Fake endpoint for testing various parameters
|
||||
/// </summary>
|
||||
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="number">None</param>
|
||||
/// <param name="_double">None</param>
|
||||
/// <param name="_string">None</param>
|
||||
/// <param name="_byte">None</param>
|
||||
/// <param name="integer">None (optional)</param>
|
||||
/// <param name="int32">None (optional)</param>
|
||||
/// <param name="int64">None (optional)</param>
|
||||
/// <param name="_float">None (optional)</param>
|
||||
/// <param name="binary">None (optional)</param>
|
||||
/// <param name="date">None (optional)</param>
|
||||
/// <param name="dateTime">None (optional)</param>
|
||||
/// <param name="password">None (optional)</param>
|
||||
/// <returns>Task of void</returns>
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fake endpoint for testing various parameters Fake endpoint for testing various parameters
|
||||
/// </summary>
|
||||
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="number">None</param>
|
||||
/// <param name="_double">None</param>
|
||||
/// <param name="_string">None</param>
|
||||
/// <param name="_byte">None</param>
|
||||
/// <param name="integer">None (optional)</param>
|
||||
/// <param name="int32">None (optional)</param>
|
||||
/// <param name="int64">None (optional)</param>
|
||||
/// <param name="_float">None (optional)</param>
|
||||
/// <param name="binary">None (optional)</param>
|
||||
/// <param name="date">None (optional)</param>
|
||||
/// <param name="dateTime">None (optional)</param>
|
||||
/// <param name="password">None (optional)</param>
|
||||
/// <returns>Task of ApiResponse</returns>
|
||||
public async System.Threading.Tasks.Task<ApiResponse<Object>> 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<String, String>();
|
||||
var localVarQueryParams = new Dictionary<String, String>();
|
||||
var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
|
||||
var localVarFormParams = new Dictionary<String, String>();
|
||||
var localVarFileParams = new Dictionary<String, FileParameter>();
|
||||
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<Object>(localVarStatusCode,
|
||||
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
||||
null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{AC0D0300-7030-473F-B672-17C40187815A}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Swagger Library</RootNamespace>
|
||||
<AssemblyName>Swagger Library</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp">
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="**\*.cs"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
@ -12,31 +12,20 @@ using Newtonsoft.Json.Converters;
|
||||
namespace IO.Swagger.Model
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// AnimalFarm
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public partial class Task : IEquatable<Task>
|
||||
public partial class AnimalFarm : List<Animal>, IEquatable<AnimalFarm>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Task" /> class.
|
||||
/// Initializes a new instance of the <see cref="Task" />class.
|
||||
/// Initializes a new instance of the <see cref="AnimalFarm" /> class.
|
||||
/// </summary>
|
||||
/// <param name="_Return">_Return.</param>
|
||||
|
||||
public Task(int? _Return = null)
|
||||
public AnimalFarm()
|
||||
{
|
||||
this._Return = _Return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets _Return
|
||||
/// </summary>
|
||||
[DataMember(Name="return", EmitDefaultValue=false)]
|
||||
public int? _Return { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string presentation of the object
|
||||
/// </summary>
|
||||
@ -44,9 +33,7 @@ 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("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
|
||||
/// </summary>
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if Task instances are equal
|
||||
/// Returns true if AnimalFarm instances are equal
|
||||
/// </summary>
|
||||
/// <param name="other">Instance of Task to be compared</param>
|
||||
/// <param name="other">Instance of AnimalFarm to be compared</param>
|
||||
/// <returns>Boolean</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or Sets EnumClass
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum EnumClass
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Enum Abc for "_abc"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "_abc")]
|
||||
Abc,
|
||||
|
||||
/// <summary>
|
||||
/// Enum efg for "-efg"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "-efg")]
|
||||
efg,
|
||||
|
||||
/// <summary>
|
||||
/// Enum xyz for "(xyz)"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "(xyz)")]
|
||||
xyz
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// EnumTest
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public partial class EnumTest : IEquatable<EnumTest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or Sets EnumString
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum EnumStringEnum
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Enum Upper for "UPPER"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "UPPER")]
|
||||
Upper,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Lower for "lower"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "lower")]
|
||||
Lower
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets EnumInteger
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum EnumIntegerEnum
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Enum NUMBER_1 for 1
|
||||
/// </summary>
|
||||
[EnumMember(Value = "1")]
|
||||
NUMBER_1 = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Enum NUMBER_MINUS_1 for -1
|
||||
/// </summary>
|
||||
[EnumMember(Value = "-1")]
|
||||
NUMBER_MINUS_1 = -1
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets EnumNumber
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum EnumNumberEnum
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Enum NUMBER_1_DOT_1 for 1.1
|
||||
/// </summary>
|
||||
[EnumMember(Value = "1.1")]
|
||||
NUMBER_1_DOT_1,
|
||||
|
||||
/// <summary>
|
||||
/// Enum NUMBER_MINUS_1_DOT_2 for -1.2
|
||||
/// </summary>
|
||||
[EnumMember(Value = "-1.2")]
|
||||
NUMBER_MINUS_1_DOT_2
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets EnumString
|
||||
/// </summary>
|
||||
[DataMember(Name="enum_string", EmitDefaultValue=false)]
|
||||
public EnumStringEnum? EnumString { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or Sets EnumInteger
|
||||
/// </summary>
|
||||
[DataMember(Name="enum_integer", EmitDefaultValue=false)]
|
||||
public EnumIntegerEnum? EnumInteger { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or Sets EnumNumber
|
||||
/// </summary>
|
||||
[DataMember(Name="enum_number", EmitDefaultValue=false)]
|
||||
public EnumNumberEnum? EnumNumber { get; set; }
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EnumTest" /> class.
|
||||
/// </summary>
|
||||
/// <param name="EnumString">EnumString.</param>
|
||||
/// <param name="EnumInteger">EnumInteger.</param>
|
||||
/// <param name="EnumNumber">EnumNumber.</param>
|
||||
public EnumTest(EnumStringEnum? EnumString = null, EnumIntegerEnum? EnumInteger = null, EnumNumberEnum? EnumNumber = null)
|
||||
{
|
||||
|
||||
|
||||
this.EnumString = EnumString;
|
||||
|
||||
this.EnumInteger = EnumInteger;
|
||||
|
||||
this.EnumNumber = EnumNumber;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>String presentation of the object</returns>
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the JSON string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this, Formatting.Indented);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if objects are equal
|
||||
/// </summary>
|
||||
/// <param name="obj">Object to be compared</param>
|
||||
/// <returns>Boolean</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
// credit: http://stackoverflow.com/a/10454552/677735
|
||||
return this.Equals(obj as EnumTest);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if EnumTest instances are equal
|
||||
/// </summary>
|
||||
/// <param name="other">Instance of EnumTest to be compared</param>
|
||||
/// <returns>Boolean</returns>
|
||||
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)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code
|
||||
/// </summary>
|
||||
/// <returns>Hash code</returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -31,8 +31,9 @@ namespace IO.Swagger.Model
|
||||
/// <param name="Binary">Binary.</param>
|
||||
/// <param name="Date">Date (required).</param>
|
||||
/// <param name="DateTime">DateTime.</param>
|
||||
/// <param name="Uuid">Uuid.</param>
|
||||
/// <param name="Password">Password (required).</param>
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -146,6 +149,11 @@ namespace IO.Swagger.Model
|
||||
[DataMember(Name="dateTime", EmitDefaultValue=false)]
|
||||
public DateTime? DateTime { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or Sets Uuid
|
||||
/// </summary>
|
||||
[DataMember(Name="uuid", EmitDefaultValue=false)]
|
||||
public Guid? Uuid { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or Sets Password
|
||||
/// </summary>
|
||||
[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;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user