forked from loafle/openapi-generator-original
Decommission csharp
client generator (#15708)
* remove csharp client generator * update samples/docs
This commit is contained in:
parent
7466d06b89
commit
421bcd1787
13
appveyor.yml
13
appveyor.yml
@ -42,15 +42,6 @@ build_script:
|
|||||||
## build C# API client (.net 5.0 with ConditionalSerialization)
|
## build C# API client (.net 5.0 with ConditionalSerialization)
|
||||||
#- dotnet build samples\client\petstore\csharp-netcore\OpenAPIClient-ConditionalSerialization\Org.OpenAPITools.sln
|
#- dotnet build samples\client\petstore\csharp-netcore\OpenAPIClient-ConditionalSerialization\Org.OpenAPITools.sln
|
||||||
|
|
||||||
## build C# API client
|
|
||||||
#- nuget restore samples\client\petstore\csharp\OpenAPIClient\Org.OpenAPITools.sln
|
|
||||||
#- msbuild samples\client\petstore\csharp\OpenAPIClient\Org.OpenAPITools.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
|
||||||
## build C# API client (with PropertyChanged)
|
|
||||||
#- nuget restore samples\client\petstore\csharp\OpenAPIClientWithPropertyChanged\Org.OpenAPITools.sln
|
|
||||||
#- msbuild samples\client\petstore\csharp\OpenAPIClientWithPropertyChanged\Org.OpenAPITools.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
|
||||||
# build C# .net standard 1.3+ API client
|
|
||||||
#- nuget restore samples\client\petstore\csharp\OpenAPIClientNetStandard\Org.OpenAPITools.sln
|
|
||||||
#- msbuild samples\client\petstore\csharp\OpenAPIClientNetStandard\Org.OpenAPITools.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
|
||||||
test_script:
|
test_script:
|
||||||
# test c# API client (multiple frameworks)
|
# test c# API client (multiple frameworks)
|
||||||
- dotnet test samples\client\petstore\csharp-netcore\OpenAPIClientCoreAndNet47\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
- dotnet test samples\client\petstore\csharp-netcore\OpenAPIClientCoreAndNet47\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||||
@ -69,10 +60,6 @@ test_script:
|
|||||||
- dotnet test samples\client\petstore\csharp-netcore\OpenAPIClient-net5.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
- dotnet test samples\client\petstore\csharp-netcore\OpenAPIClient-net5.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||||
# test C# API Client using conditional-serialization
|
# test C# API Client using conditional-serialization
|
||||||
- dotnet test samples\client\petstore\csharp-netcore\OpenAPIClient-ConditionalSerialization\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
- dotnet test samples\client\petstore\csharp-netcore\OpenAPIClient-ConditionalSerialization\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||||
## test c# API client
|
|
||||||
#- nunit3-console samples\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\bin\Debug\Org.OpenAPITools.Test.dll --result=myresults.xml;format=AppVeyor
|
|
||||||
## test c# API client (with PropertyChanged)
|
|
||||||
#- nunit3-console samples\client\petstore\csharp\OpenAPIClientWithPropertyChanged\src\Org.OpenAPITools.Test\bin\Debug\Org.OpenAPITools.Test.dll --result=myresults.xml;format=AppVeyor
|
|
||||||
|
|
||||||
### TODO: Execute all generators via powershell or other
|
### TODO: Execute all generators via powershell or other
|
||||||
# generate all petstore clients
|
# generate all petstore clients
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
generatorName: csharp
|
|
||||||
outputDir: samples/client/petstore/csharp/OpenAPIClient
|
|
||||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
|
||||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
|
||||||
additionalProperties:
|
|
||||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
|
@ -1,7 +0,0 @@
|
|||||||
generatorName: csharp
|
|
||||||
outputDir: samples/client/petstore/csharp/OpenAPIClientNet35
|
|
||||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
|
||||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
|
||||||
additionalProperties:
|
|
||||||
targetFramework: v3.5
|
|
||||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
|
@ -1,7 +0,0 @@
|
|||||||
generatorName: csharp
|
|
||||||
outputDir: samples/client/petstore/csharp/OpenAPIClientNet40
|
|
||||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
|
||||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
|
||||||
additionalProperties:
|
|
||||||
targetFramework: v4.0
|
|
||||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
|
@ -1,8 +0,0 @@
|
|||||||
generatorName: csharp
|
|
||||||
outputDir: samples/client/petstore/csharp/OpenAPIClientNetCoreProject
|
|
||||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
|
||||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
|
||||||
additionalProperties:
|
|
||||||
targetFramework: netstandard1.3
|
|
||||||
packageGuid: '{67035b31-f8e5-41a4-9673-954035084f7d}'
|
|
||||||
netCoreProjectFile: "true"
|
|
@ -1,7 +0,0 @@
|
|||||||
generatorName: csharp
|
|
||||||
outputDir: samples/client/petstore/csharp/OpenAPIClientNetStandard
|
|
||||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
|
||||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
|
||||||
additionalProperties:
|
|
||||||
targetFramework: netstandard1.3
|
|
||||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
|
@ -1,8 +0,0 @@
|
|||||||
generatorName: csharp
|
|
||||||
outputDir: samples/client/petstore/csharp/OpenAPIClientWithPropertyChanged
|
|
||||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
|
||||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
|
||||||
additionalProperties:
|
|
||||||
packageGuid: '{5CD900DE-8266-412F-A758-28E1F9C623D5}'
|
|
||||||
generatePropertyChanged: "true"
|
|
||||||
optionalEmitDefaultValues: "true"
|
|
@ -18,7 +18,6 @@ The following generators are available:
|
|||||||
* [cpp-tizen](generators/cpp-tizen.md)
|
* [cpp-tizen](generators/cpp-tizen.md)
|
||||||
* [cpp-ue4 (beta)](generators/cpp-ue4.md)
|
* [cpp-ue4 (beta)](generators/cpp-ue4.md)
|
||||||
* [crystal (beta)](generators/crystal.md)
|
* [crystal (beta)](generators/crystal.md)
|
||||||
* [csharp](generators/csharp.md)
|
|
||||||
* [csharp-netcore](generators/csharp-netcore.md)
|
* [csharp-netcore](generators/csharp-netcore.md)
|
||||||
* [dart](generators/dart.md)
|
* [dart](generators/dart.md)
|
||||||
* [dart-dio](generators/dart-dio.md)
|
* [dart-dio](generators/dart-dio.md)
|
||||||
|
@ -1,318 +0,0 @@
|
|||||||
---
|
|
||||||
title: Documentation for the csharp Generator
|
|
||||||
---
|
|
||||||
|
|
||||||
## METADATA
|
|
||||||
|
|
||||||
| Property | Value | Notes |
|
|
||||||
| -------- | ----- | ----- |
|
|
||||||
| generator name | csharp | pass this to the generate command after -g |
|
|
||||||
| generator stability | STABLE | |
|
|
||||||
| generator type | CLIENT | |
|
|
||||||
| generator language | C# | |
|
|
||||||
| generator default templating engine | mustache | |
|
|
||||||
| helpTxt | Generates a CSharp client library. | |
|
|
||||||
|
|
||||||
## CONFIG OPTIONS
|
|
||||||
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
|
|
||||||
|
|
||||||
| Option | Description | Values | Default |
|
|
||||||
| ------ | ----------- | ------ | ------- |
|
|
||||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
|
||||||
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive| |false|
|
|
||||||
|generatePropertyChanged|Specifies a AssemblyDescription for the .NET Framework global assembly attributes stored in the AssemblyInfo file.| |false|
|
|
||||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
|
||||||
|interfacePrefix|Prefix interfaces with a community standard or widely accepted prefix.| |I|
|
|
||||||
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |PascalCase|
|
|
||||||
|netCoreProjectFile|Use the new format (.NET Core) for .NET project files (.csproj).| |false|
|
|
||||||
|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.| |false|
|
|
||||||
|optionalAssemblyInfo|Generate AssemblyInfo.cs.| |true|
|
|
||||||
|optionalEmitDefaultValues|Set DataMember's EmitDefaultValue.| |false|
|
|
||||||
|optionalMethodArgument|C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).| |true|
|
|
||||||
|optionalProjectFile|Generate {PackageName}.csproj.| |true|
|
|
||||||
|packageGuid|The GUID that will be associated with the C# project| |null|
|
|
||||||
|packageName|C# package name (convention: Title.Case).| |Org.OpenAPITools|
|
|
||||||
|packageVersion|C# package version.| |1.0.0|
|
|
||||||
|returnICollection|Return ICollection<T> instead of the concrete type.| |false|
|
|
||||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
|
||||||
|sourceFolder|source folder for generated code| |src|
|
|
||||||
|targetFramework|The target .NET framework version. To target multiple frameworks, use `;` as the separator, e.g. `netstandard2.1;netcoreapp3.1`|<dl><dt>**v3.5**</dt><dd>.NET Framework 3.5 compatible</dd><dt>**v4.0**</dt><dd>.NET Framework 4.0 compatible</dd><dt>**v4.5**</dt><dd>.NET Framework 4.5 compatible</dd><dt>**v4.5.2**</dt><dd>.NET Framework 4.5.2+ compatible</dd><dt>**netstandard1.3**</dt><dd>.NET Standard 1.3 compatible (DEPRECATED. Please use `csharp-netcore` generator instead)</dd><dt>**uwp**</dt><dd>Universal Windows Platform (DEPRECATED. Please use `csharp-netcore` generator instead)</dd></dl>|v4.5|
|
|
||||||
|useCollection|Deserialize array types to Collection<T> instead of List<T>.| |false|
|
|
||||||
|useCompareNetObjects|Use KellermanSoftware.CompareNetObjects for deep recursive object comparison. WARNING: this option incurs potential performance impact.| |false|
|
|
||||||
|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false|
|
|
||||||
|validatable|Generates self-validatable models.| |true|
|
|
||||||
|
|
||||||
## IMPORT MAPPING
|
|
||||||
|
|
||||||
| Type/Alias | Imports |
|
|
||||||
| ---------- | ------- |
|
|
||||||
|
|
||||||
|
|
||||||
## INSTANTIATION TYPES
|
|
||||||
|
|
||||||
| Type/Alias | Instantiated By |
|
|
||||||
| ---------- | --------------- |
|
|
||||||
|array|List|
|
|
||||||
|list|List|
|
|
||||||
|map|Dictionary|
|
|
||||||
|
|
||||||
|
|
||||||
## LANGUAGE PRIMITIVES
|
|
||||||
|
|
||||||
<ul class="column-ul">
|
|
||||||
<li>Boolean</li>
|
|
||||||
<li>Collection</li>
|
|
||||||
<li>DateTime</li>
|
|
||||||
<li>DateTime?</li>
|
|
||||||
<li>DateTimeOffset</li>
|
|
||||||
<li>DateTimeOffset?</li>
|
|
||||||
<li>Decimal</li>
|
|
||||||
<li>Dictionary</li>
|
|
||||||
<li>Double</li>
|
|
||||||
<li>Float</li>
|
|
||||||
<li>Guid</li>
|
|
||||||
<li>Guid?</li>
|
|
||||||
<li>ICollection</li>
|
|
||||||
<li>Int32</li>
|
|
||||||
<li>Int64</li>
|
|
||||||
<li>List</li>
|
|
||||||
<li>Object</li>
|
|
||||||
<li>String</li>
|
|
||||||
<li>System.IO.Stream</li>
|
|
||||||
<li>bool</li>
|
|
||||||
<li>bool?</li>
|
|
||||||
<li>byte[]</li>
|
|
||||||
<li>decimal</li>
|
|
||||||
<li>decimal?</li>
|
|
||||||
<li>double</li>
|
|
||||||
<li>double?</li>
|
|
||||||
<li>float</li>
|
|
||||||
<li>float?</li>
|
|
||||||
<li>int</li>
|
|
||||||
<li>int?</li>
|
|
||||||
<li>long</li>
|
|
||||||
<li>long?</li>
|
|
||||||
<li>string</li>
|
|
||||||
<li>uint</li>
|
|
||||||
<li>uint?</li>
|
|
||||||
<li>ulong</li>
|
|
||||||
<li>ulong?</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
## RESERVED WORDS
|
|
||||||
|
|
||||||
<ul class="column-ul">
|
|
||||||
<li>Client</li>
|
|
||||||
<li>Configuration</li>
|
|
||||||
<li>Version</li>
|
|
||||||
<li>abstract</li>
|
|
||||||
<li>as</li>
|
|
||||||
<li>base</li>
|
|
||||||
<li>bool</li>
|
|
||||||
<li>break</li>
|
|
||||||
<li>byte</li>
|
|
||||||
<li>case</li>
|
|
||||||
<li>catch</li>
|
|
||||||
<li>char</li>
|
|
||||||
<li>checked</li>
|
|
||||||
<li>class</li>
|
|
||||||
<li>client</li>
|
|
||||||
<li>const</li>
|
|
||||||
<li>continue</li>
|
|
||||||
<li>decimal</li>
|
|
||||||
<li>default</li>
|
|
||||||
<li>delegate</li>
|
|
||||||
<li>do</li>
|
|
||||||
<li>double</li>
|
|
||||||
<li>else</li>
|
|
||||||
<li>enum</li>
|
|
||||||
<li>event</li>
|
|
||||||
<li>explicit</li>
|
|
||||||
<li>extern</li>
|
|
||||||
<li>false</li>
|
|
||||||
<li>finally</li>
|
|
||||||
<li>fixed</li>
|
|
||||||
<li>float</li>
|
|
||||||
<li>for</li>
|
|
||||||
<li>foreach</li>
|
|
||||||
<li>goto</li>
|
|
||||||
<li>if</li>
|
|
||||||
<li>implicit</li>
|
|
||||||
<li>in</li>
|
|
||||||
<li>int</li>
|
|
||||||
<li>interface</li>
|
|
||||||
<li>internal</li>
|
|
||||||
<li>is</li>
|
|
||||||
<li>localVarFileParams</li>
|
|
||||||
<li>localVarFormParams</li>
|
|
||||||
<li>localVarHeaderParams</li>
|
|
||||||
<li>localVarHttpContentType</li>
|
|
||||||
<li>localVarHttpContentTypes</li>
|
|
||||||
<li>localVarHttpHeaderAccept</li>
|
|
||||||
<li>localVarHttpHeaderAccepts</li>
|
|
||||||
<li>localVarPath</li>
|
|
||||||
<li>localVarPathParams</li>
|
|
||||||
<li>localVarPostBody</li>
|
|
||||||
<li>localVarQueryParams</li>
|
|
||||||
<li>localVarResponse</li>
|
|
||||||
<li>localVarStatusCode</li>
|
|
||||||
<li>lock</li>
|
|
||||||
<li>long</li>
|
|
||||||
<li>namespace</li>
|
|
||||||
<li>new</li>
|
|
||||||
<li>null</li>
|
|
||||||
<li>object</li>
|
|
||||||
<li>operator</li>
|
|
||||||
<li>out</li>
|
|
||||||
<li>override</li>
|
|
||||||
<li>parameter</li>
|
|
||||||
<li>params</li>
|
|
||||||
<li>private</li>
|
|
||||||
<li>protected</li>
|
|
||||||
<li>public</li>
|
|
||||||
<li>readonly</li>
|
|
||||||
<li>ref</li>
|
|
||||||
<li>return</li>
|
|
||||||
<li>sbyte</li>
|
|
||||||
<li>sealed</li>
|
|
||||||
<li>short</li>
|
|
||||||
<li>sizeof</li>
|
|
||||||
<li>stackalloc</li>
|
|
||||||
<li>static</li>
|
|
||||||
<li>string</li>
|
|
||||||
<li>struct</li>
|
|
||||||
<li>switch</li>
|
|
||||||
<li>this</li>
|
|
||||||
<li>throw</li>
|
|
||||||
<li>true</li>
|
|
||||||
<li>try</li>
|
|
||||||
<li>typeof</li>
|
|
||||||
<li>uint</li>
|
|
||||||
<li>ulong</li>
|
|
||||||
<li>unchecked</li>
|
|
||||||
<li>unsafe</li>
|
|
||||||
<li>ushort</li>
|
|
||||||
<li>using</li>
|
|
||||||
<li>virtual</li>
|
|
||||||
<li>void</li>
|
|
||||||
<li>volatile</li>
|
|
||||||
<li>while</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
## FEATURE SET
|
|
||||||
|
|
||||||
|
|
||||||
### Client Modification Feature
|
|
||||||
| Name | Supported | Defined By |
|
|
||||||
| ---- | --------- | ---------- |
|
|
||||||
|BasePath|✓|ToolingExtension
|
|
||||||
|Authorizations|✗|ToolingExtension
|
|
||||||
|UserAgent|✓|ToolingExtension
|
|
||||||
|MockServer|✗|ToolingExtension
|
|
||||||
|
|
||||||
### Data Type Feature
|
|
||||||
| Name | Supported | Defined By |
|
|
||||||
| ---- | --------- | ---------- |
|
|
||||||
|Custom|✗|OAS2,OAS3
|
|
||||||
|Int32|✓|OAS2,OAS3
|
|
||||||
|Int64|✓|OAS2,OAS3
|
|
||||||
|Float|✓|OAS2,OAS3
|
|
||||||
|Double|✓|OAS2,OAS3
|
|
||||||
|Decimal|✓|ToolingExtension
|
|
||||||
|String|✓|OAS2,OAS3
|
|
||||||
|Byte|✓|OAS2,OAS3
|
|
||||||
|Binary|✓|OAS2,OAS3
|
|
||||||
|Boolean|✓|OAS2,OAS3
|
|
||||||
|Date|✓|OAS2,OAS3
|
|
||||||
|DateTime|✓|OAS2,OAS3
|
|
||||||
|Password|✓|OAS2,OAS3
|
|
||||||
|File|✓|OAS2
|
|
||||||
|Uuid|✗|
|
|
||||||
|Array|✓|OAS2,OAS3
|
|
||||||
|Null|✗|OAS3
|
|
||||||
|AnyType|✗|OAS2,OAS3
|
|
||||||
|Object|✓|OAS2,OAS3
|
|
||||||
|Maps|✓|ToolingExtension
|
|
||||||
|CollectionFormat|✓|OAS2
|
|
||||||
|CollectionFormatMulti|✓|OAS2
|
|
||||||
|Enum|✓|OAS2,OAS3
|
|
||||||
|ArrayOfEnum|✓|ToolingExtension
|
|
||||||
|ArrayOfModel|✓|ToolingExtension
|
|
||||||
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
|
|
||||||
|ArrayOfCollectionOfModel|✓|ToolingExtension
|
|
||||||
|ArrayOfCollectionOfEnum|✓|ToolingExtension
|
|
||||||
|MapOfEnum|✓|ToolingExtension
|
|
||||||
|MapOfModel|✓|ToolingExtension
|
|
||||||
|MapOfCollectionOfPrimitives|✓|ToolingExtension
|
|
||||||
|MapOfCollectionOfModel|✓|ToolingExtension
|
|
||||||
|MapOfCollectionOfEnum|✓|ToolingExtension
|
|
||||||
|
|
||||||
### Documentation Feature
|
|
||||||
| Name | Supported | Defined By |
|
|
||||||
| ---- | --------- | ---------- |
|
|
||||||
|Readme|✓|ToolingExtension
|
|
||||||
|Model|✓|ToolingExtension
|
|
||||||
|Api|✓|ToolingExtension
|
|
||||||
|
|
||||||
### Global Feature
|
|
||||||
| Name | Supported | Defined By |
|
|
||||||
| ---- | --------- | ---------- |
|
|
||||||
|Host|✓|OAS2,OAS3
|
|
||||||
|BasePath|✓|OAS2,OAS3
|
|
||||||
|Info|✓|OAS2,OAS3
|
|
||||||
|Schemes|✗|OAS2,OAS3
|
|
||||||
|PartialSchemes|✓|OAS2,OAS3
|
|
||||||
|Consumes|✓|OAS2
|
|
||||||
|Produces|✓|OAS2
|
|
||||||
|ExternalDocumentation|✓|OAS2,OAS3
|
|
||||||
|Examples|✓|OAS2,OAS3
|
|
||||||
|XMLStructureDefinitions|✗|OAS2,OAS3
|
|
||||||
|MultiServer|✗|OAS3
|
|
||||||
|ParameterizedServer|✗|OAS3
|
|
||||||
|ParameterStyling|✗|OAS3
|
|
||||||
|Callbacks|✗|OAS3
|
|
||||||
|LinkObjects|✗|OAS3
|
|
||||||
|
|
||||||
### Parameter Feature
|
|
||||||
| Name | Supported | Defined By |
|
|
||||||
| ---- | --------- | ---------- |
|
|
||||||
|Path|✓|OAS2,OAS3
|
|
||||||
|Query|✓|OAS2,OAS3
|
|
||||||
|Header|✓|OAS2,OAS3
|
|
||||||
|Body|✓|OAS2
|
|
||||||
|FormUnencoded|✓|OAS2
|
|
||||||
|FormMultipart|✓|OAS2
|
|
||||||
|Cookie|✗|OAS3
|
|
||||||
|
|
||||||
### Schema Support Feature
|
|
||||||
| Name | Supported | Defined By |
|
|
||||||
| ---- | --------- | ---------- |
|
|
||||||
|Simple|✓|OAS2,OAS3
|
|
||||||
|Composite|✓|OAS2,OAS3
|
|
||||||
|Polymorphism|✓|OAS2,OAS3
|
|
||||||
|Union|✗|OAS3
|
|
||||||
|allOf|✗|OAS2,OAS3
|
|
||||||
|anyOf|✗|OAS3
|
|
||||||
|oneOf|✗|OAS3
|
|
||||||
|not|✗|OAS3
|
|
||||||
|
|
||||||
### Security Feature
|
|
||||||
| Name | Supported | Defined By |
|
|
||||||
| ---- | --------- | ---------- |
|
|
||||||
|BasicAuth|✓|OAS2,OAS3
|
|
||||||
|ApiKey|✓|OAS2,OAS3
|
|
||||||
|OpenIDConnect|✗|OAS3
|
|
||||||
|BearerToken|✗|OAS3
|
|
||||||
|OAuth2_Implicit|✓|OAS2,OAS3
|
|
||||||
|OAuth2_Password|✗|OAS2,OAS3
|
|
||||||
|OAuth2_ClientCredentials|✗|OAS2,OAS3
|
|
||||||
|OAuth2_AuthorizationCode|✗|OAS2,OAS3
|
|
||||||
|SignatureAuth|✗|OAS3
|
|
||||||
|
|
||||||
### Wire Format Feature
|
|
||||||
| Name | Supported | Defined By |
|
|
||||||
| ---- | --------- | ---------- |
|
|
||||||
|JSON|✓|OAS2,OAS3
|
|
||||||
|XML|✓|OAS2,OAS3
|
|
||||||
|PROTOBUF|✗|ToolingExtension
|
|
||||||
|Custom|✗|OAS2,OAS3
|
|
@ -1,986 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
|
||||||
* Copyright 2018 SmartBear Software
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.openapitools.codegen.languages;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.samskivert.mustache.Mustache;
|
|
||||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
|
||||||
import io.swagger.v3.oas.models.media.Schema;
|
|
||||||
import org.openapitools.codegen.*;
|
|
||||||
import org.openapitools.codegen.meta.features.*;
|
|
||||||
import org.openapitools.codegen.utils.ModelUtils;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
|
||||||
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
|
|
||||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
|
||||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
|
||||||
|
|
||||||
public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
|
||||||
@SuppressWarnings("hiding")
|
|
||||||
private final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
|
|
||||||
private static final String NUNIT = "nunit";
|
|
||||||
private static final String RESTSHARP = "restsharp";
|
|
||||||
private static final String NEWTONSOFT_JSON = "newtonsoft-json";
|
|
||||||
private static final String JSON_SUBTYPES = "json-subtypes";
|
|
||||||
private static final String FODY = "fody";
|
|
||||||
private static final String PROPERTYCHANGED_FODY = "propertychanged-fody";
|
|
||||||
private static final String NET452 = "v4.5.2";
|
|
||||||
private static final String NET45 = "v4.5";
|
|
||||||
private static final String NET40 = "v4.0";
|
|
||||||
private static final String NET35 = "v3.5";
|
|
||||||
private static final String NETSTANDARD = "netstandard1.3";
|
|
||||||
private static final String UWP = "uwp";
|
|
||||||
|
|
||||||
// Defines the sdk option for targeted frameworks, which differs from targetFramework and targetFrameworkNuget
|
|
||||||
private static final String MCS_NET_VERSION_KEY = "x-mcs-sdk";
|
|
||||||
|
|
||||||
protected String packageGuid = "{" + java.util.UUID.randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
|
|
||||||
protected String clientPackage = "Org.OpenAPITools.Client";
|
|
||||||
protected String apiDocPath = "docs/";
|
|
||||||
protected String modelDocPath = "docs/";
|
|
||||||
|
|
||||||
// Defines TargetFrameworkVersion in csproj files
|
|
||||||
protected String targetFramework = NET45;
|
|
||||||
|
|
||||||
// Defines nuget identifiers for target framework
|
|
||||||
protected String targetFrameworkNuget = "net45";
|
|
||||||
protected boolean supportsAsync = Boolean.TRUE;
|
|
||||||
protected boolean supportsUWP = Boolean.FALSE;
|
|
||||||
protected boolean netStandard = Boolean.FALSE;
|
|
||||||
protected boolean generatePropertyChanged = Boolean.FALSE;
|
|
||||||
|
|
||||||
protected boolean validatable = Boolean.TRUE;
|
|
||||||
protected Map<Character, String> regexModifiers;
|
|
||||||
protected final Map<String, String> frameworks;
|
|
||||||
|
|
||||||
// By default, generated code is considered public
|
|
||||||
protected boolean nonPublicApi = Boolean.FALSE;
|
|
||||||
|
|
||||||
// use KellermanSoftware.CompareNetObjects for deep recursive object comparison
|
|
||||||
protected boolean useCompareNetObjects = Boolean.FALSE;
|
|
||||||
|
|
||||||
// To make API response's headers dictionary case insensitive
|
|
||||||
protected boolean caseInsensitiveResponseHeaders = Boolean.FALSE;
|
|
||||||
|
|
||||||
public CSharpClientCodegen() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
modifyFeatureSet(features -> features
|
|
||||||
.includeDocumentationFeatures(DocumentationFeature.Readme)
|
|
||||||
.securityFeatures(EnumSet.of(
|
|
||||||
SecurityFeature.OAuth2_Implicit,
|
|
||||||
SecurityFeature.BasicAuth,
|
|
||||||
SecurityFeature.ApiKey
|
|
||||||
))
|
|
||||||
.excludeGlobalFeatures(
|
|
||||||
GlobalFeature.XMLStructureDefinitions,
|
|
||||||
GlobalFeature.Callbacks,
|
|
||||||
GlobalFeature.LinkObjects,
|
|
||||||
GlobalFeature.ParameterStyling
|
|
||||||
)
|
|
||||||
.includeSchemaSupportFeatures(
|
|
||||||
SchemaSupportFeature.Polymorphism
|
|
||||||
)
|
|
||||||
.excludeParameterFeatures(
|
|
||||||
ParameterFeature.Cookie
|
|
||||||
)
|
|
||||||
.includeClientModificationFeatures(
|
|
||||||
ClientModificationFeature.BasePath,
|
|
||||||
ClientModificationFeature.UserAgent
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
supportsInheritance = true;
|
|
||||||
modelTemplateFiles.put("model.mustache", ".cs");
|
|
||||||
apiTemplateFiles.put("api.mustache", ".cs");
|
|
||||||
|
|
||||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
|
||||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
|
||||||
|
|
||||||
hideGenerationTimestamp = Boolean.TRUE;
|
|
||||||
|
|
||||||
cliOptions.clear();
|
|
||||||
|
|
||||||
typeMapping.put("boolean", "bool");
|
|
||||||
typeMapping.put("integer", "int");
|
|
||||||
typeMapping.put("long", "long");
|
|
||||||
typeMapping.put("UnsignedInteger", "uint");
|
|
||||||
typeMapping.put("UnsignedLong", "ulong");
|
|
||||||
typeMapping.put("float", "float");
|
|
||||||
typeMapping.put("double", "double");
|
|
||||||
typeMapping.put("number", "decimal");
|
|
||||||
typeMapping.put("decimal", "decimal");
|
|
||||||
typeMapping.put("DateTime", "DateTime");
|
|
||||||
typeMapping.put("date", "DateTime");
|
|
||||||
typeMapping.put("UUID", "Guid");
|
|
||||||
typeMapping.put("URI", "string");
|
|
||||||
|
|
||||||
setSupportNullable(Boolean.TRUE);
|
|
||||||
|
|
||||||
// CLI options
|
|
||||||
addOption(CodegenConstants.PACKAGE_NAME,
|
|
||||||
"C# package name (convention: Title.Case).",
|
|
||||||
this.packageName);
|
|
||||||
|
|
||||||
addOption(CodegenConstants.PACKAGE_VERSION,
|
|
||||||
"C# package version.",
|
|
||||||
this.packageVersion);
|
|
||||||
|
|
||||||
addOption(CodegenConstants.SOURCE_FOLDER,
|
|
||||||
CodegenConstants.SOURCE_FOLDER_DESC,
|
|
||||||
sourceFolder);
|
|
||||||
|
|
||||||
addOption(CodegenConstants.OPTIONAL_PROJECT_GUID,
|
|
||||||
CodegenConstants.OPTIONAL_PROJECT_GUID_DESC,
|
|
||||||
null);
|
|
||||||
|
|
||||||
addOption(CodegenConstants.INTERFACE_PREFIX,
|
|
||||||
CodegenConstants.INTERFACE_PREFIX_DESC,
|
|
||||||
interfacePrefix);
|
|
||||||
|
|
||||||
CliOption framework = new CliOption(
|
|
||||||
CodegenConstants.DOTNET_FRAMEWORK,
|
|
||||||
CodegenConstants.DOTNET_FRAMEWORK_DESC
|
|
||||||
);
|
|
||||||
frameworks = new ImmutableMap.Builder<String, String>()
|
|
||||||
.put(NET35, ".NET Framework 3.5 compatible")
|
|
||||||
.put(NET40, ".NET Framework 4.0 compatible")
|
|
||||||
.put(NET45, ".NET Framework 4.5 compatible")
|
|
||||||
.put(NET452, ".NET Framework 4.5.2+ compatible")
|
|
||||||
.put(NETSTANDARD, ".NET Standard 1.3 compatible (DEPRECATED. Please use `csharp-netcore` generator instead)")
|
|
||||||
.put(UWP, "Universal Windows Platform (DEPRECATED. Please use `csharp-netcore` generator instead)")
|
|
||||||
.build();
|
|
||||||
framework.defaultValue(this.targetFramework);
|
|
||||||
framework.setEnum(frameworks);
|
|
||||||
cliOptions.add(framework);
|
|
||||||
|
|
||||||
CliOption modelPropertyNaming = new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC);
|
|
||||||
cliOptions.add(modelPropertyNaming.defaultValue("PascalCase"));
|
|
||||||
|
|
||||||
// CLI Switches
|
|
||||||
addSwitch(CodegenConstants.HIDE_GENERATION_TIMESTAMP,
|
|
||||||
CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC,
|
|
||||||
this.hideGenerationTimestamp);
|
|
||||||
|
|
||||||
addSwitch(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
|
|
||||||
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC,
|
|
||||||
this.sortParamsByRequiredFlag);
|
|
||||||
|
|
||||||
addSwitch(CodegenConstants.USE_DATETIME_OFFSET,
|
|
||||||
CodegenConstants.USE_DATETIME_OFFSET_DESC,
|
|
||||||
this.useDateTimeOffsetFlag);
|
|
||||||
|
|
||||||
addSwitch(CodegenConstants.USE_COLLECTION,
|
|
||||||
CodegenConstants.USE_COLLECTION_DESC,
|
|
||||||
this.useCollection);
|
|
||||||
|
|
||||||
addSwitch(CodegenConstants.RETURN_ICOLLECTION,
|
|
||||||
CodegenConstants.RETURN_ICOLLECTION_DESC,
|
|
||||||
this.returnICollection);
|
|
||||||
|
|
||||||
addSwitch(CodegenConstants.OPTIONAL_METHOD_ARGUMENT,
|
|
||||||
"C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).",
|
|
||||||
this.optionalMethodArgumentFlag);
|
|
||||||
|
|
||||||
addSwitch(CodegenConstants.OPTIONAL_ASSEMBLY_INFO,
|
|
||||||
CodegenConstants.OPTIONAL_ASSEMBLY_INFO_DESC,
|
|
||||||
this.optionalAssemblyInfoFlag);
|
|
||||||
|
|
||||||
addSwitch(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES,
|
|
||||||
CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES_DESC,
|
|
||||||
this.optionalEmitDefaultValuesFlag);
|
|
||||||
|
|
||||||
addSwitch(CodegenConstants.OPTIONAL_PROJECT_FILE,
|
|
||||||
CodegenConstants.OPTIONAL_PROJECT_FILE_DESC,
|
|
||||||
this.optionalProjectFileFlag);
|
|
||||||
|
|
||||||
addSwitch(CodegenConstants.GENERATE_PROPERTY_CHANGED,
|
|
||||||
CodegenConstants.PACKAGE_DESCRIPTION_DESC,
|
|
||||||
this.generatePropertyChanged);
|
|
||||||
|
|
||||||
// NOTE: This will reduce visibility of all public members in templates. Users can use InternalsVisibleTo
|
|
||||||
// https://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute(v=vs.110).aspx
|
|
||||||
// to expose to shared code if the generated code is not embedded into another project. Otherwise, users of codegen
|
|
||||||
// should rely on default public visibility.
|
|
||||||
addSwitch(CodegenConstants.NON_PUBLIC_API,
|
|
||||||
CodegenConstants.NON_PUBLIC_API_DESC,
|
|
||||||
this.nonPublicApi);
|
|
||||||
|
|
||||||
addSwitch(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS,
|
|
||||||
CodegenConstants.ALLOW_UNICODE_IDENTIFIERS_DESC,
|
|
||||||
this.allowUnicodeIdentifiers);
|
|
||||||
|
|
||||||
addSwitch(CodegenConstants.NETCORE_PROJECT_FILE,
|
|
||||||
CodegenConstants.NETCORE_PROJECT_FILE_DESC,
|
|
||||||
this.netCoreProjectFileFlag);
|
|
||||||
|
|
||||||
addSwitch(CodegenConstants.VALIDATABLE,
|
|
||||||
CodegenConstants.VALIDATABLE_DESC,
|
|
||||||
this.validatable);
|
|
||||||
|
|
||||||
addSwitch(CodegenConstants.USE_COMPARE_NET_OBJECTS,
|
|
||||||
CodegenConstants.USE_COMPARE_NET_OBJECTS_DESC,
|
|
||||||
this.useCompareNetObjects);
|
|
||||||
|
|
||||||
addSwitch(CodegenConstants.CASE_INSENSITIVE_RESPONSE_HEADERS,
|
|
||||||
CodegenConstants.CASE_INSENSITIVE_RESPONSE_HEADERS_DESC,
|
|
||||||
this.caseInsensitiveResponseHeaders);
|
|
||||||
|
|
||||||
regexModifiers = new HashMap<Character, String>();
|
|
||||||
regexModifiers.put('i', "IgnoreCase");
|
|
||||||
regexModifiers.put('m', "Multiline");
|
|
||||||
regexModifiers.put('s', "Singleline");
|
|
||||||
regexModifiers.put('x', "IgnorePatternWhitespace");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void processOpts() {
|
|
||||||
super.processOpts();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: When supporting boolean additionalProperties, you should read the value and write it back as a boolean.
|
|
||||||
* This avoids oddities where additionalProperties contains "false" rather than false, which will cause the
|
|
||||||
* templating engine to behave unexpectedly.
|
|
||||||
*
|
|
||||||
* Use the pattern:
|
|
||||||
* if (additionalProperties.containsKey(prop)) convertPropertyToBooleanAndWriteBack(prop);
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.MODEL_PROPERTY_NAMING)) {
|
|
||||||
setModelPropertyNaming((String) additionalProperties.get(CodegenConstants.MODEL_PROPERTY_NAMING));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (isEmpty(apiPackage)) {
|
|
||||||
setApiPackage("Api");
|
|
||||||
}
|
|
||||||
if (isEmpty(modelPackage)) {
|
|
||||||
setModelPackage("Model");
|
|
||||||
}
|
|
||||||
clientPackage = "Client";
|
|
||||||
|
|
||||||
Boolean excludeTests = false;
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.EXCLUDE_TESTS)) {
|
|
||||||
excludeTests = convertPropertyToBooleanAndWriteBack(CodegenConstants.EXCLUDE_TESTS);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.VALIDATABLE)) {
|
|
||||||
setValidatable(convertPropertyToBooleanAndWriteBack(CodegenConstants.VALIDATABLE));
|
|
||||||
} else {
|
|
||||||
additionalProperties.put(CodegenConstants.VALIDATABLE, validatable);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.DOTNET_FRAMEWORK)) {
|
|
||||||
setTargetFramework((String) additionalProperties.get(CodegenConstants.DOTNET_FRAMEWORK));
|
|
||||||
} else {
|
|
||||||
// Ensure default is set.
|
|
||||||
setTargetFramework(NET45);
|
|
||||||
additionalProperties.put(CodegenConstants.DOTNET_FRAMEWORK, this.targetFramework);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NET35.equals(this.targetFramework)) {
|
|
||||||
// This is correct, mono will require you build .NET 3.5 sources using 4.0 SDK
|
|
||||||
additionalProperties.put(MCS_NET_VERSION_KEY, "4");
|
|
||||||
additionalProperties.put("net35", true);
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.SUPPORTS_ASYNC)) {
|
|
||||||
LOGGER.warn(".NET 3.5 generator does not support async.");
|
|
||||||
additionalProperties.remove(CodegenConstants.SUPPORTS_ASYNC);
|
|
||||||
}
|
|
||||||
|
|
||||||
setTargetFrameworkNuget("net35");
|
|
||||||
setValidatable(Boolean.FALSE);
|
|
||||||
setSupportsAsync(Boolean.FALSE);
|
|
||||||
} else if (NETSTANDARD.equals(this.targetFramework)) {
|
|
||||||
LOGGER.warn(".NET Standard 1.3 support has been DEPRECATED in this generator. Please use `csharp-netcore` generator instead.");
|
|
||||||
additionalProperties.put(MCS_NET_VERSION_KEY, "4.6-api");
|
|
||||||
if (additionalProperties.containsKey("supportsUWP")) {
|
|
||||||
LOGGER.warn(".NET {} generator does not support UWP.", NETSTANDARD);
|
|
||||||
additionalProperties.remove("supportsUWP");
|
|
||||||
}
|
|
||||||
|
|
||||||
setTargetFrameworkNuget("netstandard1.3");
|
|
||||||
setSupportsAsync(Boolean.TRUE);
|
|
||||||
setSupportsUWP(Boolean.FALSE);
|
|
||||||
setNetStandard(Boolean.TRUE);
|
|
||||||
|
|
||||||
//Tests not yet implemented for .NET Standard codegen
|
|
||||||
//Todo implement it
|
|
||||||
excludeTests = true;
|
|
||||||
} else if (UWP.equals(this.targetFramework)) {
|
|
||||||
LOGGER.warn("UWP support has been DEPRECATED in this generator. Please use `csharp-netcore` generator instead.");
|
|
||||||
// TODO: NETSTANDARD here is misrepresenting a PCL v5.0 which supports .NET Framework 4.6+, .NET Core 1.0, and Windows Universal 10.0
|
|
||||||
setTargetFrameworkNuget("uwp");
|
|
||||||
setSupportsAsync(Boolean.TRUE);
|
|
||||||
setSupportsUWP(Boolean.TRUE);
|
|
||||||
} else if (NET40.equals(this.targetFramework)) {
|
|
||||||
additionalProperties.put(MCS_NET_VERSION_KEY, "4");
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.SUPPORTS_ASYNC)) {
|
|
||||||
LOGGER.warn(".NET {} generator does not support async.", NET40);
|
|
||||||
additionalProperties.remove(CodegenConstants.SUPPORTS_ASYNC);
|
|
||||||
}
|
|
||||||
|
|
||||||
setTargetFrameworkNuget("net40");
|
|
||||||
setSupportsAsync(Boolean.FALSE);
|
|
||||||
} else if (NET452.equals(this.targetFramework)) {
|
|
||||||
additionalProperties.put(MCS_NET_VERSION_KEY, "4.5.2-api");
|
|
||||||
setTargetFrameworkNuget("net452");
|
|
||||||
setSupportsAsync(Boolean.TRUE);
|
|
||||||
} else {
|
|
||||||
additionalProperties.put(MCS_NET_VERSION_KEY, "4.5.2-api");
|
|
||||||
setTargetFrameworkNuget("net45");
|
|
||||||
setSupportsAsync(Boolean.TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.GENERATE_PROPERTY_CHANGED)) {
|
|
||||||
if (NET35.equals(targetFramework)) {
|
|
||||||
LOGGER.warn("{} is only supported by generated code for .NET 4+.", CodegenConstants.GENERATE_PROPERTY_CHANGED);
|
|
||||||
additionalProperties.remove(CodegenConstants.GENERATE_PROPERTY_CHANGED);
|
|
||||||
} else if (NETSTANDARD.equals(targetFramework)) {
|
|
||||||
LOGGER.warn("{} is not supported in .NET Standard generated code.", CodegenConstants.GENERATE_PROPERTY_CHANGED);
|
|
||||||
additionalProperties.remove(CodegenConstants.GENERATE_PROPERTY_CHANGED);
|
|
||||||
} else if (Boolean.TRUE.equals(netCoreProjectFileFlag)) {
|
|
||||||
LOGGER.warn("{} is not supported in .NET Core csproj project format.", CodegenConstants.GENERATE_PROPERTY_CHANGED);
|
|
||||||
additionalProperties.remove(CodegenConstants.GENERATE_PROPERTY_CHANGED);
|
|
||||||
} else {
|
|
||||||
setGeneratePropertyChanged(convertPropertyToBooleanAndWriteBack(CodegenConstants.GENERATE_PROPERTY_CHANGED));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
|
|
||||||
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
|
|
||||||
additionalProperties.put("clientPackage", clientPackage);
|
|
||||||
|
|
||||||
additionalProperties.put(CodegenConstants.EXCLUDE_TESTS, excludeTests);
|
|
||||||
additionalProperties.put(CodegenConstants.VALIDATABLE, this.validatable);
|
|
||||||
additionalProperties.put(CodegenConstants.SUPPORTS_ASYNC, this.supportsAsync);
|
|
||||||
additionalProperties.put("supportsUWP", this.supportsUWP);
|
|
||||||
additionalProperties.put("netStandard", this.netStandard);
|
|
||||||
additionalProperties.put("targetFrameworkNuget", this.targetFrameworkNuget);
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_PROJECT_FILE)) {
|
|
||||||
setOptionalProjectFileFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.OPTIONAL_PROJECT_FILE));
|
|
||||||
} else {
|
|
||||||
additionalProperties.put(CodegenConstants.OPTIONAL_PROJECT_FILE, optionalProjectFileFlag);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_PROJECT_GUID)) {
|
|
||||||
setPackageGuid((String) additionalProperties.get(CodegenConstants.OPTIONAL_PROJECT_GUID));
|
|
||||||
} else {
|
|
||||||
additionalProperties.put(CodegenConstants.OPTIONAL_PROJECT_GUID, packageGuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_METHOD_ARGUMENT)) {
|
|
||||||
setOptionalMethodArgumentFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.OPTIONAL_METHOD_ARGUMENT));
|
|
||||||
} else {
|
|
||||||
additionalProperties.put(CodegenConstants.OPTIONAL_METHOD_ARGUMENT, optionalMethodArgumentFlag);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_ASSEMBLY_INFO)) {
|
|
||||||
setOptionalAssemblyInfoFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.OPTIONAL_ASSEMBLY_INFO));
|
|
||||||
} else {
|
|
||||||
additionalProperties.put(CodegenConstants.OPTIONAL_ASSEMBLY_INFO, optionalAssemblyInfoFlag);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES)) {
|
|
||||||
setOptionalEmitDefaultValuesFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES));
|
|
||||||
} else {
|
|
||||||
additionalProperties.put(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES, optionalEmitDefaultValuesFlag);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.NON_PUBLIC_API)) {
|
|
||||||
setNonPublicApi(convertPropertyToBooleanAndWriteBack(CodegenConstants.NON_PUBLIC_API));
|
|
||||||
} else {
|
|
||||||
additionalProperties.put(CodegenConstants.NON_PUBLIC_API, isNonPublicApi());
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
int packageDepth = packageFolder.length() - packageFolder.replace(java.io.File.separator, "").length();
|
|
||||||
String binRelativePath = "..\\";
|
|
||||||
for (int i = 0; i < packageDepth; i = i + 1)
|
|
||||||
binRelativePath += "..\\";
|
|
||||||
binRelativePath += "vendor";
|
|
||||||
additionalProperties.put("binRelativePath", binRelativePath);
|
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("IApiAccessor.mustache",
|
|
||||||
clientPackageDir, "IApiAccessor.cs"));
|
|
||||||
supportingFiles.add(new SupportingFile("Configuration.mustache",
|
|
||||||
clientPackageDir, "Configuration.cs"));
|
|
||||||
supportingFiles.add(new SupportingFile("ApiClient.mustache",
|
|
||||||
clientPackageDir, "ApiClient.cs"));
|
|
||||||
supportingFiles.add(new SupportingFile("ApiException.mustache",
|
|
||||||
clientPackageDir, "ApiException.cs"));
|
|
||||||
supportingFiles.add(new SupportingFile("ApiResponse.mustache",
|
|
||||||
clientPackageDir, "ApiResponse.cs"));
|
|
||||||
supportingFiles.add(new SupportingFile("ExceptionFactory.mustache",
|
|
||||||
clientPackageDir, "ExceptionFactory.cs"));
|
|
||||||
supportingFiles.add(new SupportingFile("OpenAPIDateConverter.mustache",
|
|
||||||
clientPackageDir, "OpenAPIDateConverter.cs"));
|
|
||||||
|
|
||||||
if (NET40.equals(this.targetFramework)) {
|
|
||||||
// .net 4.0 doesn't include ReadOnlyDictionary…
|
|
||||||
supportingFiles.add(new SupportingFile("ReadOnlyDictionary.mustache",
|
|
||||||
clientPackageDir, "ReadOnlyDictionary.cs"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Boolean.FALSE.equals(this.netStandard) && Boolean.FALSE.equals(this.netCoreProjectFileFlag)) {
|
|
||||||
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"));
|
|
||||||
// .travis.yml for travis-ci.org CI
|
|
||||||
supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
|
|
||||||
} else if (Boolean.FALSE.equals(this.netCoreProjectFileFlag)) {
|
|
||||||
supportingFiles.add(new SupportingFile("project.json.mustache", packageFolder + File.separator, "project.json"));
|
|
||||||
}
|
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("IReadableConfiguration.mustache",
|
|
||||||
clientPackageDir, "IReadableConfiguration.cs"));
|
|
||||||
supportingFiles.add(new SupportingFile("GlobalConfiguration.mustache",
|
|
||||||
clientPackageDir, "GlobalConfiguration.cs"));
|
|
||||||
|
|
||||||
// Only write out test related files if excludeTests is unset or explicitly set to false (see start of this method)
|
|
||||||
if (Boolean.FALSE.equals(excludeTests)) {
|
|
||||||
// shell script to run the nunit test
|
|
||||||
supportingFiles.add(new SupportingFile("mono_nunit_test.mustache", "", "mono_nunit_test.sh"));
|
|
||||||
|
|
||||||
modelTestTemplateFiles.put("model_test.mustache", ".cs");
|
|
||||||
apiTestTemplateFiles.put("api_test.mustache", ".cs");
|
|
||||||
|
|
||||||
if (Boolean.FALSE.equals(this.netCoreProjectFileFlag)) {
|
|
||||||
supportingFiles.add(new SupportingFile("packages_test.config.mustache", testPackageFolder + File.separator, "packages.config"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NET40.equals(this.targetFramework)) {
|
|
||||||
// Include minimal tests for modifications made to JsonSubTypes, since code is quite different for .net 4.0 from original implementation
|
|
||||||
supportingFiles.add(new SupportingFile("JsonSubTypesTests.mustache",
|
|
||||||
testPackageFolder + File.separator + "Client",
|
|
||||||
"JsonSubTypesTests.cs"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Boolean.TRUE.equals(generatePropertyChanged)) {
|
|
||||||
supportingFiles.add(new SupportingFile("FodyWeavers.xml", packageFolder, "FodyWeavers.xml"));
|
|
||||||
}
|
|
||||||
|
|
||||||
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"));
|
|
||||||
|
|
||||||
if (optionalAssemblyInfoFlag && Boolean.FALSE.equals(this.netCoreProjectFileFlag)) {
|
|
||||||
supportingFiles.add(new SupportingFile("AssemblyInfo.mustache", packageFolder + File.separator + "Properties", "AssemblyInfo.cs"));
|
|
||||||
}
|
|
||||||
if (optionalProjectFileFlag) {
|
|
||||||
supportingFiles.add(new SupportingFile("Solution.mustache", "", packageName + ".sln"));
|
|
||||||
|
|
||||||
if (Boolean.TRUE.equals(this.netCoreProjectFileFlag)) {
|
|
||||||
supportingFiles.add(new SupportingFile("netcore_project.mustache", packageFolder, packageName + ".csproj"));
|
|
||||||
} else {
|
|
||||||
supportingFiles.add(new SupportingFile("Project.mustache", packageFolder, packageName + ".csproj"));
|
|
||||||
if (Boolean.FALSE.equals(this.netStandard)) {
|
|
||||||
supportingFiles.add(new SupportingFile("nuspec.mustache", packageFolder, packageName + ".nuspec"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Boolean.FALSE.equals(excludeTests)) {
|
|
||||||
// NOTE: This exists here rather than previous excludeTests block because the test project is considered an optional project file.
|
|
||||||
if (Boolean.TRUE.equals(this.netCoreProjectFileFlag)) {
|
|
||||||
supportingFiles.add(new SupportingFile("netcore_testproject.mustache", testPackageFolder, testPackageName + ".csproj"));
|
|
||||||
} else {
|
|
||||||
supportingFiles.add(new SupportingFile("TestProject.mustache", testPackageFolder, testPackageName + ".csproj"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
additionalProperties.put("apiDocPath", apiDocPath);
|
|
||||||
additionalProperties.put("modelDocPath", modelDocPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModelPropertyNaming(String naming) {
|
|
||||||
if ("original".equals(naming) || "camelCase".equals(naming) ||
|
|
||||||
"PascalCase".equals(naming) || "snake_case".equals(naming)) {
|
|
||||||
this.modelPropertyNaming = naming;
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("Invalid model property naming '" +
|
|
||||||
naming + "'. Must be 'original', 'camelCase', " +
|
|
||||||
"'PascalCase' or 'snake_case'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getModelPropertyNaming() {
|
|
||||||
return this.modelPropertyNaming;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CodegenType getTag() {
|
|
||||||
return CodegenType.CLIENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "csharp";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHelp() {
|
|
||||||
return "Generates a CSharp client library.";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOptionalAssemblyInfoFlag(boolean flag) {
|
|
||||||
this.optionalAssemblyInfoFlag = flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOptionalEmitDefaultValuesFlag(boolean flag) {
|
|
||||||
this.optionalEmitDefaultValuesFlag = flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CodegenModel fromModel(String name, Schema model) {
|
|
||||||
Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
|
|
||||||
CodegenModel codegenModel = super.fromModel(name, model);
|
|
||||||
if (allDefinitions != null && codegenModel != null && codegenModel.parent != null) {
|
|
||||||
final Schema parentModel = allDefinitions.get(toModelName(codegenModel.parent));
|
|
||||||
if (parentModel != null) {
|
|
||||||
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
|
|
||||||
if (codegenModel.hasEnums) {
|
|
||||||
codegenModel = this.reconcileInlineEnums(codegenModel, parentCodegenModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, CodegenProperty> propertyHash = new HashMap<>(codegenModel.vars.size());
|
|
||||||
for (final CodegenProperty property : codegenModel.vars) {
|
|
||||||
propertyHash.put(property.name, property);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (final CodegenProperty property : codegenModel.readWriteVars) {
|
|
||||||
if (property.defaultValue == null && parentCodegenModel.discriminator != null && property.name.equals(parentCodegenModel.discriminator.getPropertyName())) {
|
|
||||||
property.defaultValue = "\"" + name + "\"";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CodegenProperty last = null;
|
|
||||||
for (final CodegenProperty property : parentCodegenModel.vars) {
|
|
||||||
// helper list of parentVars simplifies templating
|
|
||||||
if (!propertyHash.containsKey(property.name)) {
|
|
||||||
final CodegenProperty parentVar = property.clone();
|
|
||||||
parentVar.isInherited = true;
|
|
||||||
last = parentVar;
|
|
||||||
LOGGER.info("adding parent variable {}", property.name);
|
|
||||||
codegenModel.parentVars.add(parentVar);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cleanup possible duplicates. Currently, readWriteVars can contain the same property twice. May or may not be isolated to C#.
|
|
||||||
if (codegenModel != null && codegenModel.readWriteVars != null && codegenModel.readWriteVars.size() > 1) {
|
|
||||||
int length = codegenModel.readWriteVars.size() - 1;
|
|
||||||
for (int i = length; i > (length / 2); i--) {
|
|
||||||
final CodegenProperty codegenProperty = codegenModel.readWriteVars.get(i);
|
|
||||||
// If the property at current index is found earlier in the list, remove this last instance.
|
|
||||||
if (codegenModel.readWriteVars.indexOf(codegenProperty) < i) {
|
|
||||||
codegenModel.readWriteVars.remove(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return codegenModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOptionalProjectFileFlag(boolean flag) {
|
|
||||||
this.optionalProjectFileFlag = flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPackageGuid(String packageGuid) {
|
|
||||||
this.packageGuid = packageGuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postProcessParameter(CodegenParameter parameter) {
|
|
||||||
postProcessPattern(parameter.pattern, parameter.vendorExtensions);
|
|
||||||
postProcessEmitDefaultValue(parameter.vendorExtensions);
|
|
||||||
super.postProcessParameter(parameter);
|
|
||||||
|
|
||||||
if (nullableType.contains(parameter.dataType)) {
|
|
||||||
if (!parameter.required) { //optional
|
|
||||||
parameter.dataType = parameter.dataType + "?";
|
|
||||||
} else {
|
|
||||||
parameter.vendorExtensions.put("x-csharp-value-type", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
|
||||||
postProcessPattern(property.pattern, property.vendorExtensions);
|
|
||||||
postProcessEmitDefaultValue(property.vendorExtensions);
|
|
||||||
super.postProcessModelProperty(model, property);
|
|
||||||
|
|
||||||
if (!property.isContainer && (nullableType.contains(property.dataType) || property.isEnum)) {
|
|
||||||
property.vendorExtensions.put("x-csharp-value-type", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The pattern spec follows the Perl convention and style of modifiers. .NET
|
|
||||||
* does not support this syntax directly so we need to convert the pattern to a .NET compatible
|
|
||||||
* format and apply modifiers in a compatible way.
|
|
||||||
* See https://msdn.microsoft.com/en-us/library/yd1hzczs(v=vs.110).aspx for .NET options.
|
|
||||||
*/
|
|
||||||
public void postProcessPattern(String pattern, Map<String, Object> vendorExtensions) {
|
|
||||||
if (pattern != null) {
|
|
||||||
int i = pattern.lastIndexOf('/');
|
|
||||||
|
|
||||||
//Must follow Perl /pattern/modifiers convention
|
|
||||||
if (pattern.charAt(0) != '/' || i < 2) {
|
|
||||||
throw new IllegalArgumentException("Pattern must follow the Perl "
|
|
||||||
+ "/pattern/modifiers convention. " + pattern + " is not valid.");
|
|
||||||
}
|
|
||||||
|
|
||||||
String regex = pattern.substring(1, i).replace("'", "\'");
|
|
||||||
List<String> modifiers = new ArrayList<String>();
|
|
||||||
|
|
||||||
// perl requires an explicit modifier to be culture specific and .NET is the reverse.
|
|
||||||
modifiers.add("CultureInvariant");
|
|
||||||
|
|
||||||
for (char c : pattern.substring(i).toCharArray()) {
|
|
||||||
if (regexModifiers.containsKey(c)) {
|
|
||||||
String modifier = regexModifiers.get(c);
|
|
||||||
modifiers.add(modifier);
|
|
||||||
} else if (c == 'l') {
|
|
||||||
modifiers.remove("CultureInvariant");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vendorExtensions.put("x-regex", regex);
|
|
||||||
vendorExtensions.put("x-modifiers", modifiers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void postProcessEmitDefaultValue(Map<String, Object> vendorExtensions) {
|
|
||||||
vendorExtensions.put("x-emit-default-value", optionalEmitDefaultValuesFlag);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTargetFramework(String dotnetFramework) {
|
|
||||||
if (!frameworks.containsKey(dotnetFramework)) {
|
|
||||||
LOGGER.warn("Invalid .NET framework version, defaulting to {}", this.targetFramework);
|
|
||||||
} else {
|
|
||||||
this.targetFramework = dotnetFramework;
|
|
||||||
}
|
|
||||||
switch (targetFramework) {
|
|
||||||
case NET35:
|
|
||||||
additionalProperties.put(RESTSHARP, new LibraryDependency("105.1.0", "net35"));
|
|
||||||
additionalProperties.put(JSON_SUBTYPES, new LibraryDependency("1.6.0", "net35"));
|
|
||||||
additionalProperties.put(NEWTONSOFT_JSON, new LibraryDependency("12.0.3", "net35"));
|
|
||||||
additionalProperties.put(NUNIT, new LibraryDependency("3.11.0", "net35"));
|
|
||||||
break;
|
|
||||||
case NET40:
|
|
||||||
additionalProperties.put(RESTSHARP, new LibraryDependency("105.1.0", "net4"));
|
|
||||||
additionalProperties.put(JSON_SUBTYPES, new LibraryDependency("1.6.0", "net40"));
|
|
||||||
additionalProperties.put(NEWTONSOFT_JSON, new LibraryDependency("12.0.3", "net40"));
|
|
||||||
additionalProperties.put(NUNIT, new LibraryDependency("3.11.0", "net40"));
|
|
||||||
break;
|
|
||||||
case NET45:
|
|
||||||
additionalProperties.put(RESTSHARP, new LibraryDependency("105.1.0", "net45"));
|
|
||||||
additionalProperties.put(JSON_SUBTYPES, new LibraryDependency("1.6.0", "net45"));
|
|
||||||
additionalProperties.put(NEWTONSOFT_JSON, new LibraryDependency("12.0.3", "net45"));
|
|
||||||
additionalProperties.put(NUNIT, new LibraryDependency("3.11.0", "net45"));
|
|
||||||
break;
|
|
||||||
case NET452:
|
|
||||||
additionalProperties.put(RESTSHARP, new LibraryDependency("106.10.1", "net452"));
|
|
||||||
additionalProperties.put(JSON_SUBTYPES, new LibraryDependency("1.6.0", "net45"));
|
|
||||||
additionalProperties.put(NEWTONSOFT_JSON, new LibraryDependency("12.0.3", "net45"));
|
|
||||||
additionalProperties.put(NUNIT, new LibraryDependency("3.11.0", "net45"));
|
|
||||||
additionalProperties.put("isRestSharp_106_10_1_above", true);
|
|
||||||
break;
|
|
||||||
case UWP:
|
|
||||||
additionalProperties.put(RESTSHARP, new LibraryDependency("105.1.0", "uwp"));
|
|
||||||
additionalProperties.put(JSON_SUBTYPES, new LibraryDependency("1.6.0", "uwp"));
|
|
||||||
additionalProperties.put(NEWTONSOFT_JSON, new LibraryDependency("12.0.3", "uwp"));
|
|
||||||
additionalProperties.put(NUNIT, new LibraryDependency("3.11.0", "uwp"));
|
|
||||||
break;
|
|
||||||
case NETSTANDARD:
|
|
||||||
additionalProperties.put(RESTSHARP, new LibraryDependency("105.1.0", "netstandard1.3"));
|
|
||||||
additionalProperties.put(JSON_SUBTYPES, new LibraryDependency("1.6.0", "netstandard1.3"));
|
|
||||||
additionalProperties.put(NEWTONSOFT_JSON, new LibraryDependency("12.0.3", "netstandard1.3"));
|
|
||||||
additionalProperties.put(NUNIT, new LibraryDependency("3.11.0", "netstandard1.3"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOGGER.info("Generating code for .NET Framework {}", this.targetFramework);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CodegenModel reconcileInlineEnums(CodegenModel codegenModel, CodegenModel parentCodegenModel) {
|
|
||||||
// This generator uses inline classes to define enums, which breaks when
|
|
||||||
// dealing with models that have subTypes. To clean this up, we will analyze
|
|
||||||
// the parent and child models, look for enums that match, and remove
|
|
||||||
// them from the child models and leave them in the parent.
|
|
||||||
// Because the child models extend the parents, the enums will be available via the parent.
|
|
||||||
|
|
||||||
// Only bother with reconciliation if the parent model has enums.
|
|
||||||
if (parentCodegenModel.hasEnums) {
|
|
||||||
|
|
||||||
// Get the properties for the parent and child models
|
|
||||||
final List<CodegenProperty> parentModelCodegenProperties = parentCodegenModel.vars;
|
|
||||||
List<CodegenProperty> codegenProperties = codegenModel.vars;
|
|
||||||
|
|
||||||
// Iterate over all of the parent model properties
|
|
||||||
boolean removedChildEnum = false;
|
|
||||||
for (CodegenProperty parentModelCodegenProperty : parentModelCodegenProperties) {
|
|
||||||
// Look for enums
|
|
||||||
if (parentModelCodegenProperty.isEnum) {
|
|
||||||
// Now that we have found an enum in the parent class,
|
|
||||||
// and search the child class for the same enum.
|
|
||||||
Iterator<CodegenProperty> iterator = codegenProperties.iterator();
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
CodegenProperty codegenProperty = iterator.next();
|
|
||||||
if (codegenProperty.isEnum && codegenProperty.equals(parentModelCodegenProperty)) {
|
|
||||||
// We found an enum in the child class that is
|
|
||||||
// a duplicate of the one in the parent, so remove it.
|
|
||||||
iterator.remove();
|
|
||||||
removedChildEnum = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (removedChildEnum) {
|
|
||||||
codegenModel.vars = codegenProperties;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return codegenModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toEnumVarName(String value, String datatype) {
|
|
||||||
if (value.length() == 0) {
|
|
||||||
return "Empty";
|
|
||||||
}
|
|
||||||
|
|
||||||
// for symbol, e.g. $, #
|
|
||||||
if (getSymbolName(value) != null) {
|
|
||||||
return camelize(getSymbolName(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
// number
|
|
||||||
if (datatype.startsWith("int") || datatype.startsWith("uint") ||
|
|
||||||
datatype.startsWith("ulong") || datatype.startsWith("long") ||
|
|
||||||
datatype.startsWith("double") || datatype.startsWith("float")) {
|
|
||||||
String varName = "NUMBER_" + value;
|
|
||||||
varName = varName.replaceAll("-", "MINUS_");
|
|
||||||
varName = varName.replaceAll("\\+", "PLUS_");
|
|
||||||
varName = varName.replaceAll("\\.", "_DOT_");
|
|
||||||
return varName;
|
|
||||||
}
|
|
||||||
|
|
||||||
// string
|
|
||||||
String var = value.replaceAll("_", " ");
|
|
||||||
//var = WordUtils.capitalizeFully(var);
|
|
||||||
var = camelize(var);
|
|
||||||
var = var.replaceAll("\\W+", "");
|
|
||||||
|
|
||||||
if (var.matches("\\d.*")) {
|
|
||||||
return "_" + var;
|
|
||||||
} else {
|
|
||||||
return var;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toVarName(String name) {
|
|
||||||
// sanitize name
|
|
||||||
name = sanitizeName(name);
|
|
||||||
|
|
||||||
// if it's all upper case, do nothing
|
|
||||||
if (name.matches("^[A-Z_]*$")) {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
name = getNameUsingModelPropertyNaming(name);
|
|
||||||
|
|
||||||
// for reserved word or word starting with number, append _
|
|
||||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
|
||||||
name = escapeReservedWord(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNameUsingModelPropertyNaming(String name) {
|
|
||||||
switch (CodegenConstants.MODEL_PROPERTY_NAMING_TYPE.valueOf(getModelPropertyNaming())) {
|
|
||||||
case original:
|
|
||||||
return name;
|
|
||||||
case camelCase:
|
|
||||||
return camelize(name, LOWERCASE_FIRST_LETTER);
|
|
||||||
case PascalCase:
|
|
||||||
return camelize(name);
|
|
||||||
case snake_case:
|
|
||||||
return underscore(name);
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Invalid model property naming '" +
|
|
||||||
name + "'. Must be 'original', 'camelCase', " +
|
|
||||||
"'PascalCase' or 'snake_case'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPackageName(String packageName) {
|
|
||||||
this.packageName = packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPackageVersion(String packageVersion) {
|
|
||||||
this.packageVersion = packageVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTargetFrameworkNuget(String targetFrameworkNuget) {
|
|
||||||
this.targetFrameworkNuget = targetFrameworkNuget;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSupportsAsync(Boolean supportsAsync) {
|
|
||||||
this.supportsAsync = supportsAsync;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSupportsUWP(Boolean supportsUWP) {
|
|
||||||
this.supportsUWP = supportsUWP;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNetStandard(Boolean netStandard) {
|
|
||||||
this.netStandard = netStandard;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGeneratePropertyChanged(final Boolean generatePropertyChanged) {
|
|
||||||
this.generatePropertyChanged = generatePropertyChanged;
|
|
||||||
if (this.generatePropertyChanged) {
|
|
||||||
additionalProperties.put(FODY, new LibraryDependency("1.29.4", targetFrameworkNuget));
|
|
||||||
additionalProperties.put(PROPERTYCHANGED_FODY, new LibraryDependency("1.51.3", targetFrameworkNuget));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUseCompareNetObjects(final Boolean useCompareNetObjects) {
|
|
||||||
this.useCompareNetObjects = useCompareNetObjects;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCaseInsensitiveResponseHeaders(final Boolean caseInsensitiveResponseHeaders) {
|
|
||||||
this.caseInsensitiveResponseHeaders = caseInsensitiveResponseHeaders;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isNonPublicApi() {
|
|
||||||
return nonPublicApi;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNonPublicApi(final boolean nonPublicApi) {
|
|
||||||
this.nonPublicApi = nonPublicApi;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValidatable(boolean validatable) {
|
|
||||||
this.validatable = validatable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toModelDocFilename(String name) {
|
|
||||||
return toModelFilename(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String apiDocFileFolder() {
|
|
||||||
return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String modelDocFileFolder() {
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Mustache.Compiler processCompiler(Mustache.Compiler compiler) {
|
|
||||||
// To avoid unexpected behaviors when options are passed programmatically such as { "supportsAsync": "" }
|
|
||||||
return super.processCompiler(compiler).emptyStringIsFalse(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the instantiation type of the property, especially for map and array
|
|
||||||
*
|
|
||||||
* @param schema property schema
|
|
||||||
* @return string presentation of the instantiation type of the property
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String toInstantiationType(Schema schema) {
|
|
||||||
if (ModelUtils.isMapSchema(schema)) {
|
|
||||||
Schema additionalProperties = getAdditionalProperties(schema);
|
|
||||||
String inner = getSchemaType(additionalProperties);
|
|
||||||
if (ModelUtils.isMapSchema(additionalProperties)) {
|
|
||||||
inner = toInstantiationType(additionalProperties);
|
|
||||||
}
|
|
||||||
return instantiationTypes.get("map") + "<String, " + inner + ">";
|
|
||||||
} else if (ModelUtils.isArraySchema(schema)) {
|
|
||||||
ArraySchema arraySchema = (ArraySchema) schema;
|
|
||||||
String inner = getSchemaType(arraySchema.getItems());
|
|
||||||
return instantiationTypes.get("array") + "<" + inner + ">";
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getNullableType(Schema p, String type) {
|
|
||||||
if (languageSpecificPrimitives.contains(type)) {
|
|
||||||
if (isSupportNullable() && ModelUtils.isNullable(p) && nullableType.contains(type)) {
|
|
||||||
return type + "?";
|
|
||||||
} else {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class LibraryDependency {
|
|
||||||
String version;
|
|
||||||
String targetFramework;
|
|
||||||
|
|
||||||
public LibraryDependency(String version, String targetFramework) {
|
|
||||||
this.version = version;
|
|
||||||
this.targetFramework = targetFramework;
|
|
||||||
}
|
|
||||||
}
|
|
@ -79,7 +79,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
|||||||
protected static final String NET_70_OR_LATER = "net70OrLater";
|
protected static final String NET_70_OR_LATER = "net70OrLater";
|
||||||
|
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
private final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
|
private final Logger LOGGER = LoggerFactory.getLogger(CSharpNetCoreClientCodegen.class);
|
||||||
private static final List<FrameworkStrategy> frameworkStrategies = Arrays.asList(
|
private static final List<FrameworkStrategy> frameworkStrategies = Arrays.asList(
|
||||||
FrameworkStrategy.NETSTANDARD_1_3,
|
FrameworkStrategy.NETSTANDARD_1_3,
|
||||||
FrameworkStrategy.NETSTANDARD_1_4,
|
FrameworkStrategy.NETSTANDARD_1_4,
|
||||||
@ -1309,7 +1309,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
|||||||
@SuppressWarnings("Duplicates")
|
@SuppressWarnings("Duplicates")
|
||||||
private static abstract class FrameworkStrategy {
|
private static abstract class FrameworkStrategy {
|
||||||
|
|
||||||
private final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
|
private final Logger LOGGER = LoggerFactory.getLogger(CSharpNetCoreClientCodegen.class);
|
||||||
|
|
||||||
static FrameworkStrategy NETSTANDARD_1_3 = new FrameworkStrategy("netstandard1.3", ".NET Standard 1.3", "net7.0") {
|
static FrameworkStrategy NETSTANDARD_1_3 = new FrameworkStrategy("netstandard1.3", ".NET Standard 1.3", "net7.0") {
|
||||||
};
|
};
|
||||||
|
@ -60,7 +60,7 @@ public class CSharpNetCoreReducedClientCodegen extends AbstractCSharpCodegen {
|
|||||||
protected static final String TARGET_FRAMEWORK_VERSION = "targetFrameworkVersion";
|
protected static final String TARGET_FRAMEWORK_VERSION = "targetFrameworkVersion";
|
||||||
|
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
private final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
|
private final Logger LOGGER = LoggerFactory.getLogger(CSharpNetCoreReducedClientCodegen.class);
|
||||||
private static final List<FrameworkStrategy> frameworkStrategies = Arrays.asList(
|
private static final List<FrameworkStrategy> frameworkStrategies = Arrays.asList(
|
||||||
FrameworkStrategy.NETSTANDARD_1_3,
|
FrameworkStrategy.NETSTANDARD_1_3,
|
||||||
FrameworkStrategy.NETSTANDARD_1_4,
|
FrameworkStrategy.NETSTANDARD_1_4,
|
||||||
@ -969,7 +969,7 @@ public class CSharpNetCoreReducedClientCodegen extends AbstractCSharpCodegen {
|
|||||||
@SuppressWarnings("Duplicates")
|
@SuppressWarnings("Duplicates")
|
||||||
private static abstract class FrameworkStrategy {
|
private static abstract class FrameworkStrategy {
|
||||||
|
|
||||||
private final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
|
private final Logger LOGGER = LoggerFactory.getLogger(CSharpNetCoreReducedClientCodegen.class);
|
||||||
|
|
||||||
static FrameworkStrategy NETSTANDARD_1_3 = new FrameworkStrategy("netstandard1.3", ".NET Standard 1.3 compatible", "netcoreapp2.0") {
|
static FrameworkStrategy NETSTANDARD_1_3 = new FrameworkStrategy("netstandard1.3", ".NET Standard 1.3 compatible", "netcoreapp2.0") {
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,6 @@ org.openapitools.codegen.languages.CppRestSdkClientCodegen
|
|||||||
org.openapitools.codegen.languages.CppTinyClientCodegen
|
org.openapitools.codegen.languages.CppTinyClientCodegen
|
||||||
org.openapitools.codegen.languages.CppTizenClientCodegen
|
org.openapitools.codegen.languages.CppTizenClientCodegen
|
||||||
org.openapitools.codegen.languages.CppUE4ClientCodegen
|
org.openapitools.codegen.languages.CppUE4ClientCodegen
|
||||||
org.openapitools.codegen.languages.CSharpClientCodegen
|
|
||||||
org.openapitools.codegen.languages.CSharpNetCoreClientCodegen
|
org.openapitools.codegen.languages.CSharpNetCoreClientCodegen
|
||||||
org.openapitools.codegen.languages.CsharpNetcoreFunctionsServerCodegen
|
org.openapitools.codegen.languages.CsharpNetcoreFunctionsServerCodegen
|
||||||
org.openapitools.codegen.languages.DartClientCodegen
|
org.openapitools.codegen.languages.DartClientCodegen
|
||||||
|
@ -1,314 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.IO;
|
|
||||||
using System.Web;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
|
||||||
using System.Text;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using RestSharp;
|
|
||||||
using RestSharp.Extensions;
|
|
||||||
|
|
||||||
namespace {{clientPackage}}
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// API client is mainly responsible for making the HTTP call to the API backend.
|
|
||||||
/// </summary>
|
|
||||||
public class ApiClient
|
|
||||||
{
|
|
||||||
private readonly Dictionary<String, String> _defaultHeaderMap = new Dictionary<String, String>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ApiClient" /> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="basePath">The base path.</param>
|
|
||||||
public ApiClient(String basePath="{{{basePath}}}")
|
|
||||||
{
|
|
||||||
BasePath = basePath;
|
|
||||||
RestClient = new RestClient(BasePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the base path.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The base path</value>
|
|
||||||
public string BasePath { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the RestClient.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>An instance of the RestClient</value>
|
|
||||||
public RestClient RestClient { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the default header.
|
|
||||||
/// </summary>
|
|
||||||
public Dictionary<String, String> DefaultHeader
|
|
||||||
{
|
|
||||||
get { return _defaultHeaderMap; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Makes the HTTP request (Sync).
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="path">URL path.</param>
|
|
||||||
/// <param name="method">HTTP method.</param>
|
|
||||||
/// <param name="queryParams">Query parameters.</param>
|
|
||||||
/// <param name="postBody">HTTP body (POST request).</param>
|
|
||||||
/// <param name="headerParams">Header parameters.</param>
|
|
||||||
/// <param name="formParams">Form parameters.</param>
|
|
||||||
/// <param name="fileParams">File parameters.</param>
|
|
||||||
/// <param name="authSettings">Authentication settings.</param>
|
|
||||||
/// <returns>Object</returns>
|
|
||||||
public Object CallApi(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody,
|
|
||||||
Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
|
|
||||||
Dictionary<String, FileParameter> fileParams, String[] authSettings)
|
|
||||||
{
|
|
||||||
|
|
||||||
var request = new RestRequest(path, method);
|
|
||||||
|
|
||||||
UpdateParamsForAuth(queryParams, headerParams, authSettings);
|
|
||||||
|
|
||||||
// add default header, if any
|
|
||||||
foreach(var defaultHeader in _defaultHeaderMap)
|
|
||||||
request.AddHeader(defaultHeader.Key, defaultHeader.Value);
|
|
||||||
|
|
||||||
// add header parameter, if any
|
|
||||||
foreach(var param in headerParams)
|
|
||||||
request.AddHeader(param.Key, param.Value);
|
|
||||||
|
|
||||||
// add query parameter, if any
|
|
||||||
foreach(var param in queryParams)
|
|
||||||
request.AddParameter(param.Key, param.Value, ParameterType.GetOrPost);
|
|
||||||
|
|
||||||
// add form parameter, if any
|
|
||||||
foreach(var param in formParams)
|
|
||||||
request.AddParameter(param.Key, param.Value, ParameterType.GetOrPost);
|
|
||||||
|
|
||||||
// add file parameter, if any
|
|
||||||
foreach(var param in fileParams)
|
|
||||||
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
|
|
||||||
|
|
||||||
if (postBody != null) // http body (model) parameter
|
|
||||||
request.AddParameter("application/json", postBody, ParameterType.RequestBody);
|
|
||||||
|
|
||||||
return (Object)RestClient.Execute(request);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add default header.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key">Header field name.</param>
|
|
||||||
/// <param name="value">Header field value.</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public void AddDefaultHeader(string key, string value)
|
|
||||||
{
|
|
||||||
_defaultHeaderMap.Add(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Escape string (url-encoded).
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="str">String to be escaped.</param>
|
|
||||||
/// <returns>Escaped string.</returns>
|
|
||||||
public string EscapeString(string str)
|
|
||||||
{
|
|
||||||
return RestSharp.Contrib.HttpUtility.UrlEncode(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create FileParameter based on Stream.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">Parameter name.</param>
|
|
||||||
/// <param name="stream">Input stream.</param>
|
|
||||||
/// <returns>FileParameter.</returns>
|
|
||||||
public FileParameter ParameterToFile(string name, Stream stream)
|
|
||||||
{
|
|
||||||
if (stream is FileStream)
|
|
||||||
return FileParameter.Create(name, stream.ReadAsBytes(), Path.GetFileName(((FileStream)stream).Name));
|
|
||||||
else
|
|
||||||
return FileParameter.Create(name, stream.ReadAsBytes(), "no_file_name_provided");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime.
|
|
||||||
/// If parameter is a list of string, join the list with ",".
|
|
||||||
/// Otherwise just return the string.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="obj">The parameter (header, path, query, form).</param>
|
|
||||||
/// <returns>Formatted string.</returns>
|
|
||||||
public string ParameterToString(object obj)
|
|
||||||
{
|
|
||||||
if (obj is DateTime)
|
|
||||||
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
|
|
||||||
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
|
|
||||||
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
|
|
||||||
// For example: 2009-06-15T13:45:30.0000000
|
|
||||||
return ((DateTime)obj).ToString (Configuration.DateTimeFormat);
|
|
||||||
else if (obj is bool)
|
|
||||||
return (bool)obj ? "true" : "false";
|
|
||||||
else if (obj is List<string>)
|
|
||||||
return String.Join(",", (obj as List<string>).ToArray());
|
|
||||||
else
|
|
||||||
return Convert.ToString (obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deserialize the JSON string into a proper object.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="content">HTTP body (e.g. string, JSON).</param>
|
|
||||||
/// <param name="type">Object type.</param>
|
|
||||||
/// <param name="headers">HTTP headers.</param>
|
|
||||||
/// <returns>Object representation of the JSON string.</returns>
|
|
||||||
public object Deserialize(string content, Type type, IList<Parameter> headers=null)
|
|
||||||
{
|
|
||||||
if (type == typeof(Object)) // return an object
|
|
||||||
{
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == typeof(Stream))
|
|
||||||
{
|
|
||||||
var filePath = String.IsNullOrEmpty(Configuration.TempFolderPath)
|
|
||||||
? Path.GetTempPath()
|
|
||||||
: Configuration.TempFolderPath;
|
|
||||||
|
|
||||||
var fileName = filePath + Guid.NewGuid();
|
|
||||||
if (headers != null)
|
|
||||||
{
|
|
||||||
var regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$");
|
|
||||||
var match = regex.Match(headers.ToString());
|
|
||||||
if (match.Success)
|
|
||||||
fileName = filePath + match.Value.Replace("\"", "").Replace("'", "");
|
|
||||||
}
|
|
||||||
File.WriteAllText(fileName, content);
|
|
||||||
return new FileStream(fileName, FileMode.Open);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object
|
|
||||||
{
|
|
||||||
return DateTime.Parse(content, null, System.Globalization.DateTimeStyles.RoundtripKind);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == typeof(String) || type.Name.StartsWith("System.Nullable")) // return primitive type
|
|
||||||
{
|
|
||||||
return ConvertType(content, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
// at this point, it must be a model (json)
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return JsonConvert.DeserializeObject(content, type);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
throw new ApiException(500, e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Serialize an object into JSON string.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="obj">Object.</param>
|
|
||||||
/// <returns>JSON string.</returns>
|
|
||||||
public string Serialize(object obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return obj != null ? JsonConvert.SerializeObject(obj) : null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new ApiException(500, e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get the API key with prefix.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
|
|
||||||
/// <returns>API key with prefix.</returns>
|
|
||||||
public string GetApiKeyWithPrefix (string apiKeyIdentifier)
|
|
||||||
{
|
|
||||||
var apiKeyValue = "";
|
|
||||||
Configuration.ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue);
|
|
||||||
var apiKeyPrefix = "";
|
|
||||||
if (Configuration.ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix))
|
|
||||||
return apiKeyPrefix + " " + apiKeyValue;
|
|
||||||
else
|
|
||||||
return apiKeyValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Update parameters based on authentication.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="queryParams">Query parameters.</param>
|
|
||||||
/// <param name="headerParams">Header parameters.</param>
|
|
||||||
/// <param name="authSettings">Authentication settings.</param>
|
|
||||||
public void UpdateParamsForAuth(Dictionary<String, String> queryParams, Dictionary<String, String> headerParams, string[] authSettings)
|
|
||||||
{
|
|
||||||
if (authSettings == null || authSettings.Length == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach (string auth in authSettings)
|
|
||||||
{
|
|
||||||
// determine which one to use
|
|
||||||
switch(auth)
|
|
||||||
{
|
|
||||||
{{#authMethods}}
|
|
||||||
case "{{name}}":
|
|
||||||
{{#isApiKey}}
|
|
||||||
{{#isKeyInHeader}}
|
|
||||||
headerParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");
|
|
||||||
{{/isKeyInHeader}}
|
|
||||||
{{#isKeyInQuery}}
|
|
||||||
queryParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");
|
|
||||||
{{/isKeyInQuery}}
|
|
||||||
{{/isApiKey}}
|
|
||||||
{{#isBasic}}
|
|
||||||
{{#isBasicBasic}}
|
|
||||||
headerParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password);
|
|
||||||
{{/isBasicBasic}}
|
|
||||||
{{#isBasicBearer}}
|
|
||||||
headerParams["Authorization"] = "Bearer " + Configuration.AccessToken;
|
|
||||||
{{/isBasicBearer}}
|
|
||||||
{{/isBasic}}
|
|
||||||
{{#isOAuth}}
|
|
||||||
headerParams["Authorization"] = "Bearer " + Configuration.AccessToken;
|
|
||||||
{{/isOAuth}}
|
|
||||||
break;
|
|
||||||
{{/authMethods}}
|
|
||||||
default:
|
|
||||||
//TODO show warning about security definition not found
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Encode string in base64 format.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="text">String to be encoded.</param>
|
|
||||||
/// <returns>Encoded string.</returns>
|
|
||||||
public static string Base64Encode(string text)
|
|
||||||
{
|
|
||||||
var textByte = System.Text.Encoding.UTF8.GetBytes(text);
|
|
||||||
return System.Convert.ToBase64String(textByte);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Dynamically cast the object into target type.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fromObject">Object to be casted</param>
|
|
||||||
/// <param name="toObject">Target type</param>
|
|
||||||
/// <returns>Casted object</returns>
|
|
||||||
public static Object ConvertType(Object fromObject, Type toObject) {
|
|
||||||
return Convert.ChangeType(fromObject, toObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace {{clientPackage}} {
|
|
||||||
/// <summary>
|
|
||||||
/// API Exception
|
|
||||||
/// </summary>
|
|
||||||
public class ApiException : Exception {
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the error code (HTTP status code)
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The error code (HTTP status code).</value>
|
|
||||||
public int ErrorCode { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the error content (body json object)
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The error content (Http response body).</value>
|
|
||||||
public Object ErrorContent { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
|
||||||
/// </summary>
|
|
||||||
public ApiException() {}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="errorCode">HTTP status code.</param>
|
|
||||||
/// <param name="message">Error message.</param>
|
|
||||||
public ApiException(int errorCode, string message) : base(message) {
|
|
||||||
this.ErrorCode = errorCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="errorCode">HTTP status code.</param>
|
|
||||||
/// <param name="message">Error message.</param>
|
|
||||||
/// <param name="errorContent">Error content.</param>
|
|
||||||
public ApiException(int errorCode, string message, Object errorContent = null) : base(message) {
|
|
||||||
this.ErrorCode = errorCode;
|
|
||||||
this.ErrorContent = errorContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,138 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace {{clientPackage}}
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a set of configuration settings
|
|
||||||
/// </summary>
|
|
||||||
public class Configuration
|
|
||||||
{
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Version of the package.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>Version of the package.</value>
|
|
||||||
public const string Version = "{{packageVersion}}";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the default API client for making HTTP calls.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The API client.</value>
|
|
||||||
public static ApiClient DefaultApiClient = new ApiClient();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the username (HTTP basic authentication).
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The username.</value>
|
|
||||||
public static String Username { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the password (HTTP basic authentication).
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The password.</value>
|
|
||||||
public static String Password { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the access token (Bearer/OAuth authentication).
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The access token.</value>
|
|
||||||
public static String AccessToken { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the API key based on the authentication name.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The API key.</value>
|
|
||||||
public static Dictionary<String, String> ApiKey = new Dictionary<String, String>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The prefix of the API key.</value>
|
|
||||||
public static Dictionary<String, String> ApiKeyPrefix = new Dictionary<String, String>();
|
|
||||||
|
|
||||||
private static string _tempFolderPath = Path.GetTempPath();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the temporary folder path to store the files downloaded from the server.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>Folder path.</value>
|
|
||||||
public static String TempFolderPath
|
|
||||||
{
|
|
||||||
get { return _tempFolderPath; }
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (String.IsNullOrEmpty(value))
|
|
||||||
{
|
|
||||||
_tempFolderPath = value;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// create the directory if it does not exist
|
|
||||||
if (!Directory.Exists(value))
|
|
||||||
Directory.CreateDirectory(value);
|
|
||||||
|
|
||||||
// check if the path contains directory separator at the end
|
|
||||||
if (value[value.Length - 1] == Path.DirectorySeparatorChar)
|
|
||||||
_tempFolderPath = value;
|
|
||||||
else
|
|
||||||
_tempFolderPath = value + Path.DirectorySeparatorChar;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private const string ISO8601_DATETIME_FORMAT = "o";
|
|
||||||
|
|
||||||
private static string _dateTimeFormat = ISO8601_DATETIME_FORMAT;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the date time format used when serializing in the ApiClient
|
|
||||||
/// By default, it's set to ISO 8601 - "o", for others see:
|
|
||||||
/// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx
|
|
||||||
/// and https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
|
|
||||||
/// No validation is done to ensure that the string you're providing is valid
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The DateTimeFormat string</value>
|
|
||||||
public static String DateTimeFormat
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _dateTimeFormat;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(value))
|
|
||||||
{
|
|
||||||
// Never allow a blank or null string, go back to the default
|
|
||||||
_dateTimeFormat = ISO8601_DATETIME_FORMAT;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Caution, no validation when you choose date time format other than ISO 8601
|
|
||||||
// Take a look at the above links
|
|
||||||
_dateTimeFormat = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a string with essential information for debugging.
|
|
||||||
/// </summary>
|
|
||||||
public static String ToDebugReport()
|
|
||||||
{
|
|
||||||
String report = "C# SDK ({{packageName}}) Debug Report:\n";
|
|
||||||
report += " OS: " + Environment.OSVersion + "\n";
|
|
||||||
report += " .NET Framework Version: " + Assembly
|
|
||||||
.GetExecutingAssembly()
|
|
||||||
.GetReferencedAssemblies()
|
|
||||||
.Where(x => x.Name == "System.Core").First().Version.ToString() + "\n";
|
|
||||||
report += " Version of the API: {{version}}\n";
|
|
||||||
report += " SDK Package Version: {{packageVersion}}\n";
|
|
||||||
|
|
||||||
return report;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,168 +0,0 @@
|
|||||||
# {{packageName}} - the C# library for the {{appName}}
|
|
||||||
|
|
||||||
{{#appDescriptionWithNewLines}}
|
|
||||||
{{{.}}}
|
|
||||||
{{/appDescriptionWithNewLines}}
|
|
||||||
|
|
||||||
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
|
||||||
|
|
||||||
- API version: {{appVersion}}
|
|
||||||
- SDK version: {{packageVersion}}
|
|
||||||
{{^hideGenerationTimestamp}}
|
|
||||||
- Build date: {{generatedDate}}
|
|
||||||
{{/hideGenerationTimestamp}}
|
|
||||||
- Build package: {{generatorClass}}
|
|
||||||
{{#infoUrl}}
|
|
||||||
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
|
||||||
{{/infoUrl}}
|
|
||||||
|
|
||||||
<a id="frameworks-supported"></a>
|
|
||||||
## Frameworks supported
|
|
||||||
- .NET 2.0
|
|
||||||
|
|
||||||
<a id="dependencies"></a>
|
|
||||||
## Dependencies
|
|
||||||
- Mono compiler
|
|
||||||
- Newtonsoft.Json.7.0.1
|
|
||||||
- RestSharp.Net2.1.1.11
|
|
||||||
|
|
||||||
Note: NuGet is downloaded by the mono compilation script and packages are installed with it. No dependency DLLs are bundled with this generator
|
|
||||||
|
|
||||||
<a id="installation"></a>
|
|
||||||
## Installation
|
|
||||||
Run the following command to generate the DLL
|
|
||||||
- [Mac/Linux] `/bin/sh compile-mono.sh`
|
|
||||||
- [Windows] TODO
|
|
||||||
|
|
||||||
Then include the DLL (under the `bin` folder) in the C# project, and use the namespaces:
|
|
||||||
```csharp
|
|
||||||
using {{apiPackage}};
|
|
||||||
using {{clientPackage}};
|
|
||||||
using {{modelPackage}};
|
|
||||||
```
|
|
||||||
<a id="getting-started"></a>
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using {{apiPackage}};
|
|
||||||
using {{clientPackage}};
|
|
||||||
using {{modelPackage}};
|
|
||||||
|
|
||||||
namespace Example
|
|
||||||
{
|
|
||||||
public class {{operationId}}Example
|
|
||||||
{
|
|
||||||
public void main()
|
|
||||||
{
|
|
||||||
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
|
|
||||||
{{#hasAuthMethods}}
|
|
||||||
{{#authMethods}}
|
|
||||||
{{#isBasic}}
|
|
||||||
{{#isBasicBasic}}
|
|
||||||
// Configure HTTP basic authorization: {{{name}}}
|
|
||||||
Configuration.Default.Username = "YOUR_USERNAME";
|
|
||||||
Configuration.Default.Password = "YOUR_PASSWORD";
|
|
||||||
{{/isBasicBasic}}
|
|
||||||
{{#isBasicBearer}}
|
|
||||||
// Configure Bearer access token for authorization: {{{name}}}
|
|
||||||
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
|
|
||||||
{{/isBasicBearer}}
|
|
||||||
{{/isBasic}}
|
|
||||||
{{#isApiKey}}
|
|
||||||
// Configure API key authorization: {{{name}}}
|
|
||||||
Configuration.Default.ApiKey.Add("{{{keyParamName}}}", "YOUR_API_KEY");
|
|
||||||
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
|
||||||
// Configuration.Default.ApiKeyPrefix.Add("{{{keyParamName}}}", "Bearer");
|
|
||||||
{{/isApiKey}}
|
|
||||||
{{#isOAuth}}
|
|
||||||
// Configure OAuth2 access token for authorization: {{{name}}}
|
|
||||||
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
|
|
||||||
{{/isOAuth}}
|
|
||||||
{{/authMethods}}
|
|
||||||
{{/hasAuthMethods}}
|
|
||||||
|
|
||||||
var apiInstance = new {{classname}}();
|
|
||||||
{{#allParams}}
|
|
||||||
{{#isPrimitiveType}}
|
|
||||||
var {{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
{{^isPrimitiveType}}
|
|
||||||
var {{paramName}} = new {{{dataType}}}(); // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
{{/allParams}}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
{{#summary}}
|
|
||||||
// {{{.}}}
|
|
||||||
{{/summary}}
|
|
||||||
{{#returnType}}{{{.}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}}
|
|
||||||
Debug.WriteLine(result);{{/returnType}}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
|
|
||||||
```
|
|
||||||
|
|
||||||
<a id="documentation-for-api-endpoints"></a>
|
|
||||||
## Documentation for API Endpoints
|
|
||||||
|
|
||||||
All URIs are relative to *{{{basePath}}}*
|
|
||||||
|
|
||||||
Class | Method | HTTP request | Description
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{{summary}}}
|
|
||||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
|
||||||
|
|
||||||
<a id="documentation-for-models"></a>
|
|
||||||
## Documentation for Models
|
|
||||||
|
|
||||||
{{#modelPackage}}
|
|
||||||
{{#models}}{{#model}} - [{{{modelPackage}}}.{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
|
|
||||||
{{/model}}{{/models}}
|
|
||||||
{{/modelPackage}}
|
|
||||||
{{^modelPackage}}
|
|
||||||
No model defined in this package
|
|
||||||
{{/modelPackage}}
|
|
||||||
|
|
||||||
<a id="documentation-for-authorization"></a>
|
|
||||||
## Documentation for Authorization
|
|
||||||
|
|
||||||
{{^authMethods}}Endpoints do not require authorization.{{/authMethods}}
|
|
||||||
{{#hasAuthMethods}}Authentication schemes defined for the API:{{/hasAuthMethods}}
|
|
||||||
{{#authMethods}}
|
|
||||||
<a id="{{name}}"></a>
|
|
||||||
### {{name}}
|
|
||||||
|
|
||||||
{{#isApiKey}}
|
|
||||||
- **Type**: API key
|
|
||||||
- **API key parameter name**: {{keyParamName}}
|
|
||||||
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
|
|
||||||
{{/isApiKey}}
|
|
||||||
{{#isBasic}}
|
|
||||||
{{#isBasicBasic}}
|
|
||||||
- **Type**: HTTP basic authentication
|
|
||||||
{{/isBasicBasic}}
|
|
||||||
{{#isBasicBearer}}
|
|
||||||
- **Type**: HTTP bearer authentication
|
|
||||||
{{/isBasicBearer}}
|
|
||||||
{{#isHttpSignature}}
|
|
||||||
- **Type**: HTTP signature authentication
|
|
||||||
{{/isHttpSignature}}
|
|
||||||
{{/isBasic}}
|
|
||||||
{{#isOAuth}}
|
|
||||||
- **Type**: OAuth
|
|
||||||
- **Flow**: {{flow}}
|
|
||||||
- **Authorization URL**: {{authorizationUrl}}
|
|
||||||
- **Scopes**: {{^scopes}}N/A{{/scopes}}
|
|
||||||
{{#scopes}} - {{scope}}: {{description}}
|
|
||||||
{{/scopes}}
|
|
||||||
{{/isOAuth}}
|
|
||||||
|
|
||||||
{{/authMethods}}
|
|
@ -1,135 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using RestSharp;
|
|
||||||
using {{clientPackage}};
|
|
||||||
{{#hasImport}}using {{modelPackage}};
|
|
||||||
{{/hasImport}}
|
|
||||||
|
|
||||||
namespace {{apiPackage}}
|
|
||||||
{
|
|
||||||
{{#operations}}
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a collection of functions to interact with the API endpoints
|
|
||||||
/// </summary>
|
|
||||||
public interface I{{classname}}
|
|
||||||
{
|
|
||||||
{{#operation}}
|
|
||||||
/// <summary>
|
|
||||||
/// {{summary}} {{notes}}
|
|
||||||
/// </summary>
|
|
||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
|
||||||
{{/allParams}}/// <returns>{{returnType}}</returns>
|
|
||||||
{{#isDeprecated}}
|
|
||||||
[Obsolete]
|
|
||||||
{{/isDeprecated}}
|
|
||||||
{{{returnType}}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
|
|
||||||
{{/operation}}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a collection of functions to interact with the API endpoints
|
|
||||||
/// </summary>
|
|
||||||
public class {{classname}} : I{{classname}}
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="{{classname}}"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="apiClient"> an instance of ApiClient (optional)</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public {{classname}}(ApiClient apiClient = null)
|
|
||||||
{
|
|
||||||
if (apiClient == null) // use the default one in Configuration
|
|
||||||
this.ApiClient = Configuration.DefaultApiClient;
|
|
||||||
else
|
|
||||||
this.ApiClient = apiClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="{{classname}}"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public {{classname}}(String basePath)
|
|
||||||
{
|
|
||||||
this.ApiClient = new ApiClient(basePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the base path of the API client.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="basePath">The base path</param>
|
|
||||||
/// <value>The base path</value>
|
|
||||||
public void SetBasePath(String basePath)
|
|
||||||
{
|
|
||||||
this.ApiClient.BasePath = basePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the base path of the API client.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="basePath">The base path</param>
|
|
||||||
/// <value>The base path</value>
|
|
||||||
public String GetBasePath(String basePath)
|
|
||||||
{
|
|
||||||
return this.ApiClient.BasePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the API client.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>An instance of the ApiClient</value>
|
|
||||||
public ApiClient ApiClient {get; set;}
|
|
||||||
|
|
||||||
{{#operation}}
|
|
||||||
/// <summary>
|
|
||||||
/// {{summary}} {{notes}}
|
|
||||||
/// </summary>
|
|
||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
|
||||||
{{/allParams}}/// <returns>{{returnType}}</returns>
|
|
||||||
{{#isDeprecated}}
|
|
||||||
[Obsolete]
|
|
||||||
{{/isDeprecated}}
|
|
||||||
public {{{returnType}}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}})
|
|
||||||
{
|
|
||||||
{{#allParams}}{{#required}}
|
|
||||||
// verify the required parameter '{{paramName}}' is set
|
|
||||||
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
|
|
||||||
{{/required}}{{/allParams}}
|
|
||||||
|
|
||||||
var path = "{{{path}}}";
|
|
||||||
path = path.Replace("{format}", "json");
|
|
||||||
{{#pathParams}}path = path.Replace("{" + "{{baseName}}" + "}", ApiClient.ParameterToString({{{paramName}}}));
|
|
||||||
{{/pathParams}}
|
|
||||||
|
|
||||||
var queryParams = new Dictionary<String, String>();
|
|
||||||
var headerParams = new Dictionary<String, String>();
|
|
||||||
var formParams = new Dictionary<String, String>();
|
|
||||||
var fileParams = new Dictionary<String, FileParameter>();
|
|
||||||
String postBody = null;
|
|
||||||
|
|
||||||
{{#queryParams}} if ({{paramName}} != null) queryParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // query parameter
|
|
||||||
{{/queryParams}}
|
|
||||||
{{#headerParams}} if ({{paramName}} != null) headerParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // header parameter
|
|
||||||
{{/headerParams}}
|
|
||||||
{{#formParams}}if ({{paramName}} != null) {{#isFile}}fileParams.Add("{{baseName}}", ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isFile}}{{^isFile}}formParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}}
|
|
||||||
{{/formParams}}
|
|
||||||
{{#bodyParam}}postBody = ApiClient.Serialize({{paramName}}); // http body (model) parameter
|
|
||||||
{{/bodyParam}}
|
|
||||||
|
|
||||||
// authentication setting, if any
|
|
||||||
String[] authSettings = new String[] { {{#authMethods}}"{{name}}"{{^-last}}, {{/-last}}{{/authMethods}} };
|
|
||||||
|
|
||||||
// make the HTTP request
|
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400)
|
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
|
|
||||||
else if (((int)response.StatusCode) == 0)
|
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.ErrorMessage, response.ErrorMessage);
|
|
||||||
|
|
||||||
{{#returnType}}return ({{{returnType}}}) ApiClient.Deserialize(response.Content, typeof({{{returnType}}}), response.Headers);{{/returnType}}{{^returnType}}return;{{/returnType}}
|
|
||||||
}
|
|
||||||
|
|
||||||
{{/operation}}
|
|
||||||
}
|
|
||||||
{{/operations}}
|
|
||||||
}
|
|
@ -1,116 +0,0 @@
|
|||||||
# {{apiPackage}}.{{classname}}{{#description}}
|
|
||||||
{{.}}{{/description}}
|
|
||||||
|
|
||||||
All URIs are relative to *{{{basePath}}}*
|
|
||||||
|
|
||||||
Method | HTTP request | Description
|
|
||||||
------------- | ------------- | -------------
|
|
||||||
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{summary}}
|
|
||||||
{{/operation}}{{/operations}}
|
|
||||||
|
|
||||||
{{#operations}}
|
|
||||||
{{#operation}}
|
|
||||||
<a id="{{{operationIdLowerCase}}}"></a>
|
|
||||||
# **{{{operationId}}}**
|
|
||||||
> {{{returnType}}}{{^returnType}}void{{/returnType}} {{operationId}} ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}})
|
|
||||||
|
|
||||||
{{{summary}}}{{#notes}}
|
|
||||||
|
|
||||||
{{{.}}}{{/notes}}
|
|
||||||
|
|
||||||
### Example
|
|
||||||
```csharp
|
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using {{apiPackage}};
|
|
||||||
using {{clientPackage}};
|
|
||||||
using {{modelPackage}};
|
|
||||||
|
|
||||||
namespace Example
|
|
||||||
{
|
|
||||||
public class {{operationId}}Example
|
|
||||||
{
|
|
||||||
public void main()
|
|
||||||
{
|
|
||||||
{{#hasAuthMethods}}
|
|
||||||
{{#authMethods}}
|
|
||||||
{{#isBasic}}
|
|
||||||
{{#isBasicBasic}}
|
|
||||||
// Configure HTTP basic authorization: {{{name}}}
|
|
||||||
Configuration.Default.Username = "YOUR_USERNAME";
|
|
||||||
Configuration.Default.Password = "YOUR_PASSWORD";
|
|
||||||
{{/isBasicBasic}}
|
|
||||||
{{#isBasicBearer}}
|
|
||||||
// Configure Bearer access token: {{{name}}}
|
|
||||||
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
|
|
||||||
{{/isBasicBearer}}
|
|
||||||
{{/isBasic}}
|
|
||||||
{{#isApiKey}}
|
|
||||||
// Configure API key authorization: {{{name}}}
|
|
||||||
Configuration.Default.ApiKey.Add("{{{keyParamName}}}", "YOUR_API_KEY");
|
|
||||||
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
|
||||||
// Configuration.Default.ApiKeyPrefix.Add("{{{keyParamName}}}", "Bearer");
|
|
||||||
{{/isApiKey}}
|
|
||||||
{{#isOAuth}}
|
|
||||||
// Configure OAuth2 access token for authorization: {{{name}}}
|
|
||||||
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
|
|
||||||
{{/isOAuth}}
|
|
||||||
{{/authMethods}}
|
|
||||||
|
|
||||||
{{/hasAuthMethods}}
|
|
||||||
var apiInstance = new {{classname}}();
|
|
||||||
{{#allParams}}
|
|
||||||
{{#isPrimitiveType}}
|
|
||||||
{{^isBinary}}
|
|
||||||
var {{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
|
||||||
{{/isBinary}}
|
|
||||||
{{#isBinary}}
|
|
||||||
var {{paramName}} = new {{{dataType}}}(); // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
|
||||||
{{/isBinary}}
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
{{^isPrimitiveType}}
|
|
||||||
var {{paramName}} = new {{{dataType}}}(); // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
{{/allParams}}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
{{#summary}}
|
|
||||||
// {{{.}}}
|
|
||||||
{{/summary}}
|
|
||||||
{{#returnType}}{{.}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}}
|
|
||||||
Debug.WriteLine(result);{{/returnType}}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Parameters
|
|
||||||
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
|
|
||||||
{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{baseType}}.md){{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{.}}]{{/defaultValue}}
|
|
||||||
{{/allParams}}
|
|
||||||
|
|
||||||
### Return type
|
|
||||||
|
|
||||||
{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}}
|
|
||||||
|
|
||||||
### Authorization
|
|
||||||
|
|
||||||
{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}}
|
|
||||||
|
|
||||||
### HTTP request headers
|
|
||||||
|
|
||||||
- **Content-Type**: {{#consumes}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
|
|
||||||
- **Accept**: {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}}
|
|
||||||
|
|
||||||
[[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)
|
|
||||||
|
|
||||||
{{/operation}}
|
|
||||||
{{/operations}}
|
|
@ -1,12 +0,0 @@
|
|||||||
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe;
|
|
||||||
mozroots --import --sync
|
|
||||||
mono nuget.exe install vendor/packages.config -o vendor;
|
|
||||||
mkdir -p bin;
|
|
||||||
mcs -sdk:2 -r:vendor/Newtonsoft.Json.7.0.1/lib/net20/Newtonsoft.Json.dll,\
|
|
||||||
vendor/RestSharp.Net2.1.1.11/lib/net20/RestSharp.Net2.dll,\
|
|
||||||
System.Runtime.Serialization.dll \
|
|
||||||
-target:library \
|
|
||||||
-out:bin/{{packageName}}.dll \
|
|
||||||
-recurse:'src/*.cs' \
|
|
||||||
-doc:bin/{{packageName}}.xml \
|
|
||||||
-platform:anycpu
|
|
@ -1,362 +0,0 @@
|
|||||||
## Ignore Visual Studio temporary files, build results, and
|
|
||||||
## files generated by popular Visual Studio add-ons.
|
|
||||||
##
|
|
||||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
|
||||||
|
|
||||||
# User-specific files
|
|
||||||
*.rsuser
|
|
||||||
*.suo
|
|
||||||
*.user
|
|
||||||
*.userosscache
|
|
||||||
*.sln.docstates
|
|
||||||
|
|
||||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
|
||||||
*.userprefs
|
|
||||||
|
|
||||||
# Mono auto generated files
|
|
||||||
mono_crash.*
|
|
||||||
|
|
||||||
# Build results
|
|
||||||
[Dd]ebug/
|
|
||||||
[Dd]ebugPublic/
|
|
||||||
[Rr]elease/
|
|
||||||
[Rr]eleases/
|
|
||||||
x64/
|
|
||||||
x86/
|
|
||||||
[Ww][Ii][Nn]32/
|
|
||||||
[Aa][Rr][Mm]/
|
|
||||||
[Aa][Rr][Mm]64/
|
|
||||||
bld/
|
|
||||||
[Bb]in/
|
|
||||||
[Oo]bj/
|
|
||||||
[Ll]og/
|
|
||||||
[Ll]ogs/
|
|
||||||
|
|
||||||
# Visual Studio 2015/2017 cache/options directory
|
|
||||||
.vs/
|
|
||||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
|
||||||
#wwwroot/
|
|
||||||
|
|
||||||
# Visual Studio 2017 auto generated files
|
|
||||||
Generated\ Files/
|
|
||||||
|
|
||||||
# MSTest test Results
|
|
||||||
[Tt]est[Rr]esult*/
|
|
||||||
[Bb]uild[Ll]og.*
|
|
||||||
|
|
||||||
# NUnit
|
|
||||||
*.VisualState.xml
|
|
||||||
TestResult.xml
|
|
||||||
nunit-*.xml
|
|
||||||
|
|
||||||
# Build Results of an ATL Project
|
|
||||||
[Dd]ebugPS/
|
|
||||||
[Rr]eleasePS/
|
|
||||||
dlldata.c
|
|
||||||
|
|
||||||
# Benchmark Results
|
|
||||||
BenchmarkDotNet.Artifacts/
|
|
||||||
|
|
||||||
# .NET Core
|
|
||||||
project.lock.json
|
|
||||||
project.fragment.lock.json
|
|
||||||
artifacts/
|
|
||||||
|
|
||||||
# ASP.NET Scaffolding
|
|
||||||
ScaffoldingReadMe.txt
|
|
||||||
|
|
||||||
# StyleCop
|
|
||||||
StyleCopReport.xml
|
|
||||||
|
|
||||||
# Files built by Visual Studio
|
|
||||||
*_i.c
|
|
||||||
*_p.c
|
|
||||||
*_h.h
|
|
||||||
*.ilk
|
|
||||||
*.meta
|
|
||||||
*.obj
|
|
||||||
*.iobj
|
|
||||||
*.pch
|
|
||||||
*.pdb
|
|
||||||
*.ipdb
|
|
||||||
*.pgc
|
|
||||||
*.pgd
|
|
||||||
*.rsp
|
|
||||||
*.sbr
|
|
||||||
*.tlb
|
|
||||||
*.tli
|
|
||||||
*.tlh
|
|
||||||
*.tmp
|
|
||||||
*.tmp_proj
|
|
||||||
*_wpftmp.csproj
|
|
||||||
*.log
|
|
||||||
*.vspscc
|
|
||||||
*.vssscc
|
|
||||||
.builds
|
|
||||||
*.pidb
|
|
||||||
*.svclog
|
|
||||||
*.scc
|
|
||||||
|
|
||||||
# Chutzpah Test files
|
|
||||||
_Chutzpah*
|
|
||||||
|
|
||||||
# Visual C++ cache files
|
|
||||||
ipch/
|
|
||||||
*.aps
|
|
||||||
*.ncb
|
|
||||||
*.opendb
|
|
||||||
*.opensdf
|
|
||||||
*.sdf
|
|
||||||
*.cachefile
|
|
||||||
*.VC.db
|
|
||||||
*.VC.VC.opendb
|
|
||||||
|
|
||||||
# Visual Studio profiler
|
|
||||||
*.psess
|
|
||||||
*.vsp
|
|
||||||
*.vspx
|
|
||||||
*.sap
|
|
||||||
|
|
||||||
# Visual Studio Trace Files
|
|
||||||
*.e2e
|
|
||||||
|
|
||||||
# TFS 2012 Local Workspace
|
|
||||||
$tf/
|
|
||||||
|
|
||||||
# Guidance Automation Toolkit
|
|
||||||
*.gpState
|
|
||||||
|
|
||||||
# ReSharper is a .NET coding add-in
|
|
||||||
_ReSharper*/
|
|
||||||
*.[Rr]e[Ss]harper
|
|
||||||
*.DotSettings.user
|
|
||||||
|
|
||||||
# TeamCity is a build add-in
|
|
||||||
_TeamCity*
|
|
||||||
|
|
||||||
# DotCover is a Code Coverage Tool
|
|
||||||
*.dotCover
|
|
||||||
|
|
||||||
# AxoCover is a Code Coverage Tool
|
|
||||||
.axoCover/*
|
|
||||||
!.axoCover/settings.json
|
|
||||||
|
|
||||||
# Coverlet is a free, cross platform Code Coverage Tool
|
|
||||||
coverage*.json
|
|
||||||
coverage*.xml
|
|
||||||
coverage*.info
|
|
||||||
|
|
||||||
# Visual Studio code coverage results
|
|
||||||
*.coverage
|
|
||||||
*.coveragexml
|
|
||||||
|
|
||||||
# NCrunch
|
|
||||||
_NCrunch_*
|
|
||||||
.*crunch*.local.xml
|
|
||||||
nCrunchTemp_*
|
|
||||||
|
|
||||||
# MightyMoose
|
|
||||||
*.mm.*
|
|
||||||
AutoTest.Net/
|
|
||||||
|
|
||||||
# Web workbench (sass)
|
|
||||||
.sass-cache/
|
|
||||||
|
|
||||||
# Installshield output folder
|
|
||||||
[Ee]xpress/
|
|
||||||
|
|
||||||
# DocProject is a documentation generator add-in
|
|
||||||
DocProject/buildhelp/
|
|
||||||
DocProject/Help/*.HxT
|
|
||||||
DocProject/Help/*.HxC
|
|
||||||
DocProject/Help/*.hhc
|
|
||||||
DocProject/Help/*.hhk
|
|
||||||
DocProject/Help/*.hhp
|
|
||||||
DocProject/Help/Html2
|
|
||||||
DocProject/Help/html
|
|
||||||
|
|
||||||
# Click-Once directory
|
|
||||||
publish/
|
|
||||||
|
|
||||||
# Publish Web Output
|
|
||||||
*.[Pp]ublish.xml
|
|
||||||
*.azurePubxml
|
|
||||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
|
||||||
# but database connection strings (with potential passwords) will be unencrypted
|
|
||||||
*.pubxml
|
|
||||||
*.publishproj
|
|
||||||
|
|
||||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
|
||||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
|
||||||
# in these scripts will be unencrypted
|
|
||||||
PublishScripts/
|
|
||||||
|
|
||||||
# NuGet Packages
|
|
||||||
*.nupkg
|
|
||||||
# NuGet Symbol Packages
|
|
||||||
*.snupkg
|
|
||||||
# The packages folder can be ignored because of Package Restore
|
|
||||||
**/[Pp]ackages/*
|
|
||||||
# except build/, which is used as an MSBuild target.
|
|
||||||
!**/[Pp]ackages/build/
|
|
||||||
# Uncomment if necessary however generally it will be regenerated when needed
|
|
||||||
#!**/[Pp]ackages/repositories.config
|
|
||||||
# NuGet v3's project.json files produces more ignorable files
|
|
||||||
*.nuget.props
|
|
||||||
*.nuget.targets
|
|
||||||
|
|
||||||
# Microsoft Azure Build Output
|
|
||||||
csx/
|
|
||||||
*.build.csdef
|
|
||||||
|
|
||||||
# Microsoft Azure Emulator
|
|
||||||
ecf/
|
|
||||||
rcf/
|
|
||||||
|
|
||||||
# Windows Store app package directories and files
|
|
||||||
AppPackages/
|
|
||||||
BundleArtifacts/
|
|
||||||
Package.StoreAssociation.xml
|
|
||||||
_pkginfo.txt
|
|
||||||
*.appx
|
|
||||||
*.appxbundle
|
|
||||||
*.appxupload
|
|
||||||
|
|
||||||
# Visual Studio cache files
|
|
||||||
# files ending in .cache can be ignored
|
|
||||||
*.[Cc]ache
|
|
||||||
# but keep track of directories ending in .cache
|
|
||||||
!?*.[Cc]ache/
|
|
||||||
|
|
||||||
# Others
|
|
||||||
ClientBin/
|
|
||||||
~$*
|
|
||||||
*~
|
|
||||||
*.dbmdl
|
|
||||||
*.dbproj.schemaview
|
|
||||||
*.jfm
|
|
||||||
*.pfx
|
|
||||||
*.publishsettings
|
|
||||||
orleans.codegen.cs
|
|
||||||
|
|
||||||
# Including strong name files can present a security risk
|
|
||||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
|
||||||
#*.snk
|
|
||||||
|
|
||||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
|
||||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
|
||||||
#bower_components/
|
|
||||||
|
|
||||||
# RIA/Silverlight projects
|
|
||||||
Generated_Code/
|
|
||||||
|
|
||||||
# Backup & report files from converting an old project file
|
|
||||||
# to a newer Visual Studio version. Backup files are not needed,
|
|
||||||
# because we have git ;-)
|
|
||||||
_UpgradeReport_Files/
|
|
||||||
Backup*/
|
|
||||||
UpgradeLog*.XML
|
|
||||||
UpgradeLog*.htm
|
|
||||||
ServiceFabricBackup/
|
|
||||||
*.rptproj.bak
|
|
||||||
|
|
||||||
# SQL Server files
|
|
||||||
*.mdf
|
|
||||||
*.ldf
|
|
||||||
*.ndf
|
|
||||||
|
|
||||||
# Business Intelligence projects
|
|
||||||
*.rdl.data
|
|
||||||
*.bim.layout
|
|
||||||
*.bim_*.settings
|
|
||||||
*.rptproj.rsuser
|
|
||||||
*- [Bb]ackup.rdl
|
|
||||||
*- [Bb]ackup ([0-9]).rdl
|
|
||||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
|
||||||
|
|
||||||
# Microsoft Fakes
|
|
||||||
FakesAssemblies/
|
|
||||||
|
|
||||||
# GhostDoc plugin setting file
|
|
||||||
*.GhostDoc.xml
|
|
||||||
|
|
||||||
# Node.js Tools for Visual Studio
|
|
||||||
.ntvs_analysis.dat
|
|
||||||
node_modules/
|
|
||||||
|
|
||||||
# Visual Studio 6 build log
|
|
||||||
*.plg
|
|
||||||
|
|
||||||
# Visual Studio 6 workspace options file
|
|
||||||
*.opt
|
|
||||||
|
|
||||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
|
||||||
*.vbw
|
|
||||||
|
|
||||||
# Visual Studio LightSwitch build output
|
|
||||||
**/*.HTMLClient/GeneratedArtifacts
|
|
||||||
**/*.DesktopClient/GeneratedArtifacts
|
|
||||||
**/*.DesktopClient/ModelManifest.xml
|
|
||||||
**/*.Server/GeneratedArtifacts
|
|
||||||
**/*.Server/ModelManifest.xml
|
|
||||||
_Pvt_Extensions
|
|
||||||
|
|
||||||
# Paket dependency manager
|
|
||||||
.paket/paket.exe
|
|
||||||
paket-files/
|
|
||||||
|
|
||||||
# FAKE - F# Make
|
|
||||||
.fake/
|
|
||||||
|
|
||||||
# CodeRush personal settings
|
|
||||||
.cr/personal
|
|
||||||
|
|
||||||
# Python Tools for Visual Studio (PTVS)
|
|
||||||
__pycache__/
|
|
||||||
*.pyc
|
|
||||||
|
|
||||||
# Cake - Uncomment if you are using it
|
|
||||||
# tools/**
|
|
||||||
# !tools/packages.config
|
|
||||||
|
|
||||||
# Tabs Studio
|
|
||||||
*.tss
|
|
||||||
|
|
||||||
# Telerik's JustMock configuration file
|
|
||||||
*.jmconfig
|
|
||||||
|
|
||||||
# BizTalk build output
|
|
||||||
*.btp.cs
|
|
||||||
*.btm.cs
|
|
||||||
*.odx.cs
|
|
||||||
*.xsd.cs
|
|
||||||
|
|
||||||
# OpenCover UI analysis results
|
|
||||||
OpenCover/
|
|
||||||
|
|
||||||
# Azure Stream Analytics local run output
|
|
||||||
ASALocalRun/
|
|
||||||
|
|
||||||
# MSBuild Binary and Structured Log
|
|
||||||
*.binlog
|
|
||||||
|
|
||||||
# NVidia Nsight GPU debugger configuration file
|
|
||||||
*.nvuser
|
|
||||||
|
|
||||||
# MFractors (Xamarin productivity tool) working folder
|
|
||||||
.mfractor/
|
|
||||||
|
|
||||||
# Local History for Visual Studio
|
|
||||||
.localhistory/
|
|
||||||
|
|
||||||
# BeatPulse healthcheck temp database
|
|
||||||
healthchecksdb
|
|
||||||
|
|
||||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
|
||||||
MigrationBackup/
|
|
||||||
|
|
||||||
# Ionide (cross platform F# VS Code tools) working folder
|
|
||||||
.ionide/
|
|
||||||
|
|
||||||
# Fody - auto-generated XML schema
|
|
||||||
FodyWeavers.xsd
|
|
@ -1,56 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Text;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
{{#models}}
|
|
||||||
{{#model}}
|
|
||||||
namespace {{modelPackage}} {
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// {{description}}
|
|
||||||
/// </summary>
|
|
||||||
[DataContract]
|
|
||||||
public class {{classname}}{{#parent}} : {{{.}}}{{/parent}} {
|
|
||||||
{{#vars}}
|
|
||||||
/// <summary>
|
|
||||||
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{{description}}}
|
|
||||||
/// </summary>{{#description}}
|
|
||||||
/// <value>{{{.}}}</value>{{/description}}
|
|
||||||
[DataMember(Name="{{baseName}}", EmitDefaultValue=false)]
|
|
||||||
[JsonProperty(PropertyName = "{{baseName}}")]
|
|
||||||
{{#deprecated}}
|
|
||||||
[Obsolete]
|
|
||||||
{{/deprecated}}
|
|
||||||
public {{{dataType}}} {{name}} { get; set; }
|
|
||||||
|
|
||||||
{{/vars}}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get 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 {{classname}} {\n");
|
|
||||||
{{#vars}}
|
|
||||||
sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
|
|
||||||
{{/vars}}
|
|
||||||
sb.Append("}\n");
|
|
||||||
return sb.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get the JSON string presentation of the object
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>JSON string presentation of the object</returns>
|
|
||||||
public {{#parent}} new {{/parent}}string ToJson() {
|
|
||||||
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
{{/model}}
|
|
||||||
{{/models}}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
{{#models}}
|
|
||||||
{{#model}}
|
|
||||||
# {{{modelPackage}}}.{{{classname}}}
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
|
||||||
{{/vars}}
|
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
|
||||||
|
|
||||||
{{/model}}
|
|
||||||
{{/models}}
|
|
@ -1,5 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<packages>
|
|
||||||
<package id="RestSharp.Net2" version="1.1.11" targetFramework="net20" developmentDependency="true" />
|
|
||||||
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net20" developmentDependency="true" />
|
|
||||||
</packages>
|
|
@ -1,601 +0,0 @@
|
|||||||
{{>partial_header}}
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.IO;
|
|
||||||
using System.Threading;
|
|
||||||
{{^netStandard}}
|
|
||||||
{{^supportsUWP}}
|
|
||||||
using System.Web;
|
|
||||||
{{/supportsUWP}}
|
|
||||||
{{/netStandard}}
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
|
||||||
using System.Text;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
{{#netStandard}}
|
|
||||||
using RestSharp.Portable;
|
|
||||||
using RestSharp.Portable.HttpClient;
|
|
||||||
{{/netStandard}}
|
|
||||||
{{^netStandard}}
|
|
||||||
using RestSharp;
|
|
||||||
{{/netStandard}}
|
|
||||||
|
|
||||||
namespace {{packageName}}.Client
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// API client is mainly responsible for making the HTTP call to the API backend.
|
|
||||||
/// </summary>
|
|
||||||
{{>visibility}} partial class ApiClient
|
|
||||||
{
|
|
||||||
public JsonSerializerSettings serializerSettings = new JsonSerializerSettings
|
|
||||||
{
|
|
||||||
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor
|
|
||||||
};
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Allows for extending request processing for <see cref="ApiClient"/> generated code.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request">The RestSharp request object</param>
|
|
||||||
partial void InterceptRequest(IRestRequest request);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Allows for extending response processing for <see cref="ApiClient"/> generated code.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request">The RestSharp request object</param>
|
|
||||||
/// <param name="response">The RestSharp response object</param>
|
|
||||||
partial void InterceptResponse(IRestRequest request, IRestResponse response);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ApiClient" /> class
|
|
||||||
/// with default configuration.
|
|
||||||
/// </summary>
|
|
||||||
public ApiClient()
|
|
||||||
{
|
|
||||||
Configuration = {{packageName}}.Client.Configuration.Default;
|
|
||||||
RestClient = new RestClient("{{{basePath}}}");
|
|
||||||
{{#netStandard}}
|
|
||||||
RestClient.IgnoreResponseStatusCode = true;
|
|
||||||
{{/netStandard}}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ApiClient" /> class
|
|
||||||
/// with default base path ({{{basePath}}}).
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="config">An instance of Configuration.</param>
|
|
||||||
public ApiClient(Configuration config)
|
|
||||||
{
|
|
||||||
Configuration = config ?? {{packageName}}.Client.Configuration.Default;
|
|
||||||
|
|
||||||
RestClient = new RestClient(Configuration.BasePath);
|
|
||||||
{{#netStandard}}
|
|
||||||
RestClient.IgnoreResponseStatusCode = true;
|
|
||||||
{{/netStandard}}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ApiClient" /> class
|
|
||||||
/// with default configuration.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="basePath">The base path.</param>
|
|
||||||
public ApiClient(String basePath = "{{{basePath}}}")
|
|
||||||
{
|
|
||||||
if (String.IsNullOrEmpty(basePath))
|
|
||||||
throw new ArgumentException("basePath cannot be empty");
|
|
||||||
|
|
||||||
RestClient = new RestClient(basePath);
|
|
||||||
{{#netStandard}}
|
|
||||||
RestClient.IgnoreResponseStatusCode = true;
|
|
||||||
{{/netStandard}}
|
|
||||||
Configuration = Client.Configuration.Default;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the default API client for making HTTP calls.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The default API client.</value>
|
|
||||||
[Obsolete("ApiClient.Default is deprecated, please use 'Configuration.Default.ApiClient' instead.")]
|
|
||||||
public static ApiClient Default;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets an instance of the IReadableConfiguration.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>An instance of the IReadableConfiguration.</value>
|
|
||||||
/// <remarks>
|
|
||||||
/// <see cref="IReadableConfiguration"/> helps us to avoid modifying possibly global
|
|
||||||
/// configuration values from within a given client. It does not guarantee thread-safety
|
|
||||||
/// of the <see cref="Configuration"/> instance in any way.
|
|
||||||
/// </remarks>
|
|
||||||
public IReadableConfiguration Configuration { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the RestClient.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>An instance of the RestClient</value>
|
|
||||||
public RestClient RestClient { get; set; }
|
|
||||||
|
|
||||||
// Creates and sets up a RestRequest prior to a call.
|
|
||||||
private RestRequest PrepareRequest(
|
|
||||||
String path, {{^netStandard}}RestSharp.{{/netStandard}}Method method, List<KeyValuePair<String, String>> queryParams, Object postBody,
|
|
||||||
Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
|
|
||||||
Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams,
|
|
||||||
String contentType)
|
|
||||||
{
|
|
||||||
var request = new RestRequest(path, method);
|
|
||||||
{{#netStandard}}
|
|
||||||
// disable ResetSharp.Portable built-in serialization
|
|
||||||
request.Serializer = null;
|
|
||||||
{{/netStandard}}
|
|
||||||
|
|
||||||
// add path parameter, if any
|
|
||||||
foreach(var param in pathParams)
|
|
||||||
request.AddParameter(param.Key, param.Value, ParameterType.UrlSegment);
|
|
||||||
|
|
||||||
// add header parameter, if any
|
|
||||||
foreach(var param in headerParams)
|
|
||||||
request.AddHeader(param.Key, param.Value);
|
|
||||||
|
|
||||||
// add query parameter, if any
|
|
||||||
foreach(var param in queryParams)
|
|
||||||
request.AddQueryParameter(param.Key, param.Value);
|
|
||||||
|
|
||||||
// add form parameter, if any
|
|
||||||
foreach(var param in formParams)
|
|
||||||
request.AddParameter(param.Key, param.Value);
|
|
||||||
|
|
||||||
// add file parameter, if any
|
|
||||||
foreach(var param in fileParams)
|
|
||||||
{
|
|
||||||
{{#netStandard}}
|
|
||||||
request.AddFile(param.Value);
|
|
||||||
{{/netStandard}}
|
|
||||||
{{^netStandard}}
|
|
||||||
{{^supportsUWP}}
|
|
||||||
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName{{#isRestSharp_106_10_1_above}}, param.Value.ContentLength{{/isRestSharp_106_10_1_above}}, param.Value.ContentType);
|
|
||||||
{{/supportsUWP}}
|
|
||||||
{{#supportsUWP}}
|
|
||||||
byte[] paramWriter = null;
|
|
||||||
param.Value.Writer = delegate (Stream stream) { paramWriter = ToByteArray(stream); };
|
|
||||||
request.AddFile(param.Value.Name, paramWriter, param.Value.FileName, param.Value.ContentType);
|
|
||||||
{{/supportsUWP}}
|
|
||||||
{{/netStandard}}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (postBody != null) // http body (model or byte[]) parameter
|
|
||||||
{
|
|
||||||
{{#netStandard}}
|
|
||||||
request.AddParameter(new Parameter { Value = postBody, Type = ParameterType.RequestBody, ContentType = contentType });
|
|
||||||
{{/netStandard}}
|
|
||||||
{{^netStandard}}
|
|
||||||
request.AddParameter(contentType, postBody, ParameterType.RequestBody);
|
|
||||||
{{/netStandard}}
|
|
||||||
}
|
|
||||||
|
|
||||||
return request;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Makes the HTTP request (Sync).
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="path">URL path.</param>
|
|
||||||
/// <param name="method">HTTP method.</param>
|
|
||||||
/// <param name="queryParams">Query parameters.</param>
|
|
||||||
/// <param name="postBody">HTTP body (POST request).</param>
|
|
||||||
/// <param name="headerParams">Header parameters.</param>
|
|
||||||
/// <param name="formParams">Form parameters.</param>
|
|
||||||
/// <param name="fileParams">File parameters.</param>
|
|
||||||
/// <param name="pathParams">Path parameters.</param>
|
|
||||||
/// <param name="contentType">Content Type of the request</param>
|
|
||||||
/// <returns>Object</returns>
|
|
||||||
public Object CallApi(
|
|
||||||
String path, {{^netStandard}}RestSharp.{{/netStandard}}Method method, List<KeyValuePair<String, String>> queryParams, Object postBody,
|
|
||||||
Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
|
|
||||||
Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams,
|
|
||||||
String contentType)
|
|
||||||
{
|
|
||||||
var request = PrepareRequest(
|
|
||||||
path, method, queryParams, postBody, headerParams, formParams, fileParams,
|
|
||||||
pathParams, contentType);
|
|
||||||
|
|
||||||
// set timeout
|
|
||||||
{{#netStandard}}RestClient.Timeout = TimeSpan.FromMilliseconds(Configuration.Timeout);{{/netStandard}}
|
|
||||||
{{^netStandard}}RestClient.Timeout = Configuration.Timeout;{{/netStandard}}
|
|
||||||
// set user agent
|
|
||||||
RestClient.UserAgent = Configuration.UserAgent;
|
|
||||||
|
|
||||||
InterceptRequest(request);
|
|
||||||
{{#netStandard}}
|
|
||||||
var response = RestClient.Execute(request).Result;
|
|
||||||
{{/netStandard}}
|
|
||||||
{{^netStandard}}
|
|
||||||
{{^supportsUWP}}
|
|
||||||
var response = RestClient.Execute(request);
|
|
||||||
{{/supportsUWP}}
|
|
||||||
{{#supportsUWP}}
|
|
||||||
// Using async method to perform sync call (uwp-only)
|
|
||||||
var response = RestClient.ExecuteTaskAsync(request).Result;
|
|
||||||
{{/supportsUWP}}
|
|
||||||
{{/netStandard}}
|
|
||||||
InterceptResponse(request, response);
|
|
||||||
|
|
||||||
return (Object) response;
|
|
||||||
}
|
|
||||||
{{#supportsAsync}}
|
|
||||||
/// <summary>
|
|
||||||
/// Makes the asynchronous HTTP request.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="path">URL path.</param>
|
|
||||||
/// <param name="method">HTTP method.</param>
|
|
||||||
/// <param name="queryParams">Query parameters.</param>
|
|
||||||
/// <param name="postBody">HTTP body (POST request).</param>
|
|
||||||
/// <param name="headerParams">Header parameters.</param>
|
|
||||||
/// <param name="formParams">Form parameters.</param>
|
|
||||||
/// <param name="fileParams">File parameters.</param>
|
|
||||||
/// <param name="pathParams">Path parameters.</param>
|
|
||||||
/// <param name="contentType">Content type.</param>
|
|
||||||
/// <param name="cancellationToken">Cancellation Token.</param>
|
|
||||||
/// <returns>The Task instance.</returns>
|
|
||||||
public async System.Threading.Tasks.Task<Object> CallApiAsync(
|
|
||||||
String path, {{^netStandard}}RestSharp.{{/netStandard}}Method method, List<KeyValuePair<String, String>> queryParams, Object postBody,
|
|
||||||
Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
|
|
||||||
Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams,
|
|
||||||
String contentType, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var request = PrepareRequest(
|
|
||||||
path, method, queryParams, postBody, headerParams, formParams, fileParams,
|
|
||||||
pathParams, contentType);
|
|
||||||
RestClient.UserAgent = Configuration.UserAgent;
|
|
||||||
InterceptRequest(request);
|
|
||||||
var response = await RestClient.Execute{{^netStandard}}TaskAsync{{/netStandard}}(request, cancellationToken);
|
|
||||||
InterceptResponse(request, response);
|
|
||||||
return (Object)response;
|
|
||||||
}{{/supportsAsync}}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Escape string (url-encoded).
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="str">String to be escaped.</param>
|
|
||||||
/// <returns>Escaped string.</returns>
|
|
||||||
public string EscapeString(string str)
|
|
||||||
{
|
|
||||||
return UrlEncode(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create FileParameter based on Stream.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">Parameter name.</param>
|
|
||||||
/// <param name="stream">Input stream.</param>
|
|
||||||
/// <returns>FileParameter.</returns>
|
|
||||||
public FileParameter ParameterToFile(string name, Stream stream)
|
|
||||||
{
|
|
||||||
if (stream is FileStream)
|
|
||||||
return FileParameter.Create(name, ReadAsBytes(stream), Path.GetFileName(((FileStream)stream).Name));
|
|
||||||
else
|
|
||||||
return FileParameter.Create(name, ReadAsBytes(stream), "no_file_name_provided");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime.
|
|
||||||
/// If parameter is a list, join the list with ",".
|
|
||||||
/// Otherwise just return the string.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="obj">The parameter (header, path, query, form).</param>
|
|
||||||
/// <returns>Formatted string.</returns>
|
|
||||||
public string ParameterToString(object obj)
|
|
||||||
{
|
|
||||||
if (obj is DateTime)
|
|
||||||
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
|
|
||||||
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
|
|
||||||
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
|
|
||||||
// For example: 2009-06-15T13:45:30.0000000
|
|
||||||
return ((DateTime)obj).ToString (Configuration.DateTimeFormat);
|
|
||||||
else if (obj is DateTimeOffset)
|
|
||||||
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
|
|
||||||
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
|
|
||||||
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
|
|
||||||
// For example: 2009-06-15T13:45:30.0000000
|
|
||||||
return ((DateTimeOffset)obj).ToString (Configuration.DateTimeFormat);
|
|
||||||
else if (obj is bool)
|
|
||||||
return (bool)obj ? "true" : "false";
|
|
||||||
else if (obj is IList)
|
|
||||||
{
|
|
||||||
var flattenedString = new StringBuilder();
|
|
||||||
foreach (var param in (IList)obj)
|
|
||||||
{
|
|
||||||
if (flattenedString.Length > 0)
|
|
||||||
flattenedString.Append(",");
|
|
||||||
flattenedString.Append(param);
|
|
||||||
}
|
|
||||||
return flattenedString.ToString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return Convert.ToString (obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deserialize the JSON string into a proper object.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="response">The HTTP response.</param>
|
|
||||||
/// <param name="type">Object type.</param>
|
|
||||||
/// <returns>Object representation of the JSON string.</returns>
|
|
||||||
public object Deserialize(IRestResponse response, Type type)
|
|
||||||
{
|
|
||||||
{{^netStandard}}IList<Parameter>{{/netStandard}}{{#netStandard}}IHttpHeaders{{/netStandard}} headers = response.Headers;
|
|
||||||
if (type == typeof(byte[])) // return byte array
|
|
||||||
{
|
|
||||||
return response.RawBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: ? if (type.IsAssignableFrom(typeof(Stream)))
|
|
||||||
if (type == typeof(Stream))
|
|
||||||
{
|
|
||||||
if (headers != null)
|
|
||||||
{
|
|
||||||
var filePath = String.IsNullOrEmpty(Configuration.TempFolderPath)
|
|
||||||
? Path.GetTempPath()
|
|
||||||
: Configuration.TempFolderPath;
|
|
||||||
var regex = new Regex(@"Content-Disposition=.*filename=['""]?([^'""\s]+)['""]?$");
|
|
||||||
foreach (var header in headers)
|
|
||||||
{
|
|
||||||
var match = regex.Match(header.ToString());
|
|
||||||
if (match.Success)
|
|
||||||
{
|
|
||||||
string fileName = filePath + SanitizeFilename(match.Groups[1].Value.Replace("\"", "").Replace("'", ""));
|
|
||||||
File.WriteAllBytes(fileName, response.RawBytes);
|
|
||||||
return new FileStream(fileName, FileMode.Open);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var stream = new MemoryStream(response.RawBytes);
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object
|
|
||||||
{
|
|
||||||
return DateTime.Parse(response.Content, null, System.Globalization.DateTimeStyles.RoundtripKind);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == typeof(String) || type.Name.StartsWith("System.Nullable")) // return primitive type
|
|
||||||
{
|
|
||||||
return ConvertType(response.Content, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
// at this point, it must be a model (json)
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return JsonConvert.DeserializeObject(response.Content, type, serializerSettings);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new ApiException(500, e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Serialize an input (model) into JSON string
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="obj">Object.</param>
|
|
||||||
/// <returns>JSON string.</returns>
|
|
||||||
public String Serialize(object obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return obj != null ? JsonConvert.SerializeObject(obj) : null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new ApiException(500, e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///Check if the given MIME is a JSON MIME.
|
|
||||||
///JSON MIME examples:
|
|
||||||
/// application/json
|
|
||||||
/// application/json; charset=UTF8
|
|
||||||
/// APPLICATION/JSON
|
|
||||||
/// application/vnd.company+json
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="mime">MIME</param>
|
|
||||||
/// <returns>Returns True if MIME type is json.</returns>
|
|
||||||
public bool IsJsonMime(String mime)
|
|
||||||
{
|
|
||||||
var jsonRegex = new Regex("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$");
|
|
||||||
return mime != null && (jsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Select the Content-Type header's value from the given content-type array:
|
|
||||||
/// if JSON type exists in the given array, use it;
|
|
||||||
/// otherwise use the first one defined in 'consumes'
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="contentTypes">The Content-Type array to select from.</param>
|
|
||||||
/// <returns>The Content-Type header to use.</returns>
|
|
||||||
public String SelectHeaderContentType(String[] contentTypes)
|
|
||||||
{
|
|
||||||
if (contentTypes.Length == 0)
|
|
||||||
return "application/json";
|
|
||||||
|
|
||||||
foreach (var contentType in contentTypes)
|
|
||||||
{
|
|
||||||
if (IsJsonMime(contentType.ToLower()))
|
|
||||||
return contentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
return contentTypes[0]; // use the first content type specified in 'consumes'
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Select the Accept header's value from the given accepts array:
|
|
||||||
/// if JSON exists in the given array, use it;
|
|
||||||
/// otherwise use all of them (joining into a string)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="accepts">The accepts array to select from.</param>
|
|
||||||
/// <returns>The Accept header to use.</returns>
|
|
||||||
public String SelectHeaderAccept(String[] accepts)
|
|
||||||
{
|
|
||||||
if (accepts.Length == 0)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase))
|
|
||||||
return "application/json";
|
|
||||||
|
|
||||||
return String.Join(",", accepts);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Encode string in base64 format.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="text">String to be encoded.</param>
|
|
||||||
/// <returns>Encoded string.</returns>
|
|
||||||
public static string Base64Encode(string text)
|
|
||||||
{
|
|
||||||
return System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Dynamically cast the object into target type.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fromObject">Object to be casted</param>
|
|
||||||
/// <param name="toObject">Target type</param>
|
|
||||||
/// <returns>Casted object</returns>
|
|
||||||
{{#supportsAsync}}
|
|
||||||
public static dynamic ConvertType(dynamic fromObject, Type toObject)
|
|
||||||
{{/supportsAsync}}
|
|
||||||
{{^supportsAsync}}
|
|
||||||
public static object ConvertType<T>(T fromObject, Type toObject) where T : class
|
|
||||||
{{/supportsAsync}}
|
|
||||||
{
|
|
||||||
return Convert.ChangeType(fromObject, toObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Convert stream to byte array
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="inputStream">Input stream to be converted</param>
|
|
||||||
/// <returns>Byte array</returns>
|
|
||||||
public static byte[] ReadAsBytes(Stream inputStream)
|
|
||||||
{
|
|
||||||
byte[] buf = new byte[16*1024];
|
|
||||||
using (MemoryStream ms = new MemoryStream())
|
|
||||||
{
|
|
||||||
int count;
|
|
||||||
while ((count = inputStream.Read(buf, 0, buf.Length)) > 0)
|
|
||||||
{
|
|
||||||
ms.Write(buf, 0, count);
|
|
||||||
}
|
|
||||||
return ms.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// URL encode a string
|
|
||||||
/// Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input">String to be URL encoded</param>
|
|
||||||
/// <returns>Byte array</returns>
|
|
||||||
public static string UrlEncode(string input)
|
|
||||||
{
|
|
||||||
const int maxLength = 32766;
|
|
||||||
|
|
||||||
if (input == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("input");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (input.Length <= maxLength)
|
|
||||||
{
|
|
||||||
return Uri.EscapeDataString(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder(input.Length * 2);
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
while (index < input.Length)
|
|
||||||
{
|
|
||||||
int length = Math.Min(input.Length - index, maxLength);
|
|
||||||
string subString = input.Substring(index, length);
|
|
||||||
|
|
||||||
sb.Append(Uri.EscapeDataString(subString));
|
|
||||||
index += subString.Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sanitize filename by removing the path
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="filename">Filename</param>
|
|
||||||
/// <returns>Filename</returns>
|
|
||||||
public static string SanitizeFilename(string filename)
|
|
||||||
{
|
|
||||||
Match match = Regex.Match(filename, @".*[/\\](.*)$");
|
|
||||||
|
|
||||||
if (match.Success)
|
|
||||||
{
|
|
||||||
return match.Groups[1].Value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{{^netStandard}}
|
|
||||||
{{#supportsUWP}}
|
|
||||||
/// <summary>
|
|
||||||
/// Convert stream to byte array
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="stream">IO stream</param>
|
|
||||||
/// <returns>Byte array</returns>
|
|
||||||
public static byte[] ToByteArray(Stream stream)
|
|
||||||
{
|
|
||||||
stream.Position = 0;
|
|
||||||
byte[] buffer = new byte[stream.Length];
|
|
||||||
for (int totalBytesCopied = 0; totalBytesCopied < stream.Length;)
|
|
||||||
totalBytesCopied += stream.Read(buffer, totalBytesCopied, Convert.ToInt32(stream.Length) - totalBytesCopied);
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
{{/supportsUWP}}
|
|
||||||
{{/netStandard}}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Convert params to key/value pairs.
|
|
||||||
/// Use collectionFormat to properly format lists and collections.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="collectionFormat">Collection format.</param>
|
|
||||||
/// <param name="name">Key name.</param>
|
|
||||||
/// <param name="value">Value object.</param>
|
|
||||||
/// <returns>A list of KeyValuePairs</returns>
|
|
||||||
public IEnumerable<KeyValuePair<string, string>> ParameterToKeyValuePairs(string collectionFormat, string name, object value)
|
|
||||||
{
|
|
||||||
var parameters = new List<KeyValuePair<string, string>>();
|
|
||||||
|
|
||||||
if (IsCollection(value) && collectionFormat == "multi")
|
|
||||||
{
|
|
||||||
var valueCollection = value as IEnumerable;
|
|
||||||
parameters.AddRange(from object item in valueCollection select new KeyValuePair<string, string>(name, ParameterToString(item)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
parameters.Add(new KeyValuePair<string, string>(name, ParameterToString(value)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Check if generic object is a collection.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value"></param>
|
|
||||||
/// <returns>True if object is a collection type</returns>
|
|
||||||
private static bool IsCollection(object value)
|
|
||||||
{
|
|
||||||
return value is IList || value is ICollection;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
{{>partial_header}}
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace {{packageName}}.Client
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// API Exception
|
|
||||||
/// </summary>
|
|
||||||
{{>visibility}} class ApiException : Exception
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the error code (HTTP status code)
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The error code (HTTP status code).</value>
|
|
||||||
public int ErrorCode { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the error content (body json object)
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The error content (Http response body).</value>
|
|
||||||
public {{#supportsAsync}}dynamic{{/supportsAsync}}{{^supportsAsync}}object{{/supportsAsync}} ErrorContent { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
|
||||||
/// </summary>
|
|
||||||
public ApiException() {}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="errorCode">HTTP status code.</param>
|
|
||||||
/// <param name="message">Error message.</param>
|
|
||||||
public ApiException(int errorCode, string message) : base(message)
|
|
||||||
{
|
|
||||||
this.ErrorCode = errorCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="errorCode">HTTP status code.</param>
|
|
||||||
/// <param name="message">Error message.</param>
|
|
||||||
/// <param name="errorContent">Error content.</param>
|
|
||||||
public ApiException(int errorCode, string message, {{#supportsAsync}}dynamic{{/supportsAsync}}{{^supportsAsync}}object{{/supportsAsync}} errorContent = null) : base(message)
|
|
||||||
{
|
|
||||||
this.ErrorCode = errorCode;
|
|
||||||
this.ErrorContent = errorContent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
{{>partial_header}}
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace {{packageName}}.Client
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// API Response
|
|
||||||
/// </summary>
|
|
||||||
{{>visibility}} class ApiResponse<T>
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the status code (HTTP status code)
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The status code.</value>
|
|
||||||
public int StatusCode { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the HTTP headers
|
|
||||||
/// </summary>
|
|
||||||
/// <value>HTTP headers</value>
|
|
||||||
public IDictionary<string, string> Headers { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the data (parsed HTTP body)
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The data.</value>
|
|
||||||
public T Data { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ApiResponse<T>" /> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="statusCode">HTTP status code.</param>
|
|
||||||
/// <param name="headers">HTTP headers.</param>
|
|
||||||
/// <param name="data">Data (parsed HTTP body)</param>
|
|
||||||
public ApiResponse(int statusCode, IDictionary<string, string> headers, T data)
|
|
||||||
{
|
|
||||||
this.StatusCode= statusCode;
|
|
||||||
this.Headers = headers;
|
|
||||||
this.Data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
[assembly: AssemblyTitle("{{packageTitle}}")]
|
|
||||||
[assembly: AssemblyDescription("{{packageDescription}}")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("{{packageCompany}}")]
|
|
||||||
[assembly: AssemblyProduct("{{packageProductName}}")]
|
|
||||||
[assembly: AssemblyCopyright("{{packageCopyright}}")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||||
// to COM components. If you need to access a type in this assembly from
|
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
|
||||||
[assembly: AssemblyVersion("{{packageVersion}}")]
|
|
||||||
[assembly: AssemblyFileVersion("{{packageVersion}}")]
|
|
@ -1,453 +0,0 @@
|
|||||||
{{>partial_header}}
|
|
||||||
using System;
|
|
||||||
using System.Reflection;
|
|
||||||
{{^net35}}
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
{{/net35}}
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace {{packageName}}.Client
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a set of configuration settings
|
|
||||||
/// </summary>
|
|
||||||
{{>visibility}} class Configuration : IReadableConfiguration
|
|
||||||
{
|
|
||||||
#region Constants
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Version of the package.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>Version of the package.</value>
|
|
||||||
public const string Version = "{{packageVersion}}";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Identifier for ISO 8601 DateTime Format
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>See https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 for more information.</remarks>
|
|
||||||
// ReSharper disable once InconsistentNaming
|
|
||||||
public const string ISO8601_DATETIME_FORMAT = "o";
|
|
||||||
|
|
||||||
#endregion Constants
|
|
||||||
|
|
||||||
#region Static Members
|
|
||||||
|
|
||||||
private static readonly object GlobalConfigSync = new { };
|
|
||||||
private static Configuration _globalConfiguration;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Default creation of exceptions for a given method name and response object
|
|
||||||
/// </summary>
|
|
||||||
public static readonly ExceptionFactory DefaultExceptionFactory = (methodName, response) =>
|
|
||||||
{
|
|
||||||
var status = (int)response.StatusCode;
|
|
||||||
if (status >= 400)
|
|
||||||
{
|
|
||||||
return new ApiException(status,
|
|
||||||
string.Format("Error calling {0}: {1}", methodName, response.Content),
|
|
||||||
response.Content);
|
|
||||||
}
|
|
||||||
{{^netStandard}}if (status == 0)
|
|
||||||
{
|
|
||||||
return new ApiException(status,
|
|
||||||
string.Format("Error calling {0}: {1}", methodName, response.ErrorMessage), response.ErrorMessage);
|
|
||||||
}{{/netStandard}}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the default Configuration.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>Configuration.</value>
|
|
||||||
public static Configuration Default
|
|
||||||
{
|
|
||||||
get { return _globalConfiguration; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
lock (GlobalConfigSync)
|
|
||||||
{
|
|
||||||
_globalConfiguration = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Static Members
|
|
||||||
|
|
||||||
#region Private Members
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the API key based on the authentication name.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The API key.</value>
|
|
||||||
private IDictionary<string, string> _apiKey = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The prefix of the API key.</value>
|
|
||||||
private IDictionary<string, string> _apiKeyPrefix = null;
|
|
||||||
|
|
||||||
private string _dateTimeFormat = ISO8601_DATETIME_FORMAT;
|
|
||||||
private string _tempFolderPath = Path.GetTempPath();
|
|
||||||
|
|
||||||
#endregion Private Members
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
static Configuration()
|
|
||||||
{
|
|
||||||
_globalConfiguration = new GlobalConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="Configuration" /> class
|
|
||||||
/// </summary>
|
|
||||||
public Configuration()
|
|
||||||
{
|
|
||||||
UserAgent = "{{httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{packageVersion}}/csharp{{/httpUserAgent}}";
|
|
||||||
BasePath = "{{{basePath}}}";
|
|
||||||
DefaultHeader = new {{^net35}}Concurrent{{/net35}}Dictionary<string, string>();
|
|
||||||
ApiKey = new {{^net35}}Concurrent{{/net35}}Dictionary<string, string>();
|
|
||||||
ApiKeyPrefix = new {{^net35}}Concurrent{{/net35}}Dictionary<string, string>();
|
|
||||||
|
|
||||||
// Setting Timeout has side effects (forces ApiClient creation).
|
|
||||||
Timeout = 100000;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="Configuration" /> class
|
|
||||||
/// </summary>
|
|
||||||
public Configuration(
|
|
||||||
IDictionary<string, string> defaultHeader,
|
|
||||||
IDictionary<string, string> apiKey,
|
|
||||||
IDictionary<string, string> apiKeyPrefix,
|
|
||||||
string basePath = "{{{basePath}}}") : this()
|
|
||||||
{
|
|
||||||
if (string.{{^net35}}IsNullOrWhiteSpace{{/net35}}{{#net35}}IsNullOrEmpty{{/net35}}(basePath))
|
|
||||||
throw new ArgumentException("The provided basePath is invalid.", "basePath");
|
|
||||||
if (defaultHeader == null)
|
|
||||||
throw new ArgumentNullException("defaultHeader");
|
|
||||||
if (apiKey == null)
|
|
||||||
throw new ArgumentNullException("apiKey");
|
|
||||||
if (apiKeyPrefix == null)
|
|
||||||
throw new ArgumentNullException("apiKeyPrefix");
|
|
||||||
|
|
||||||
BasePath = basePath;
|
|
||||||
|
|
||||||
foreach (var keyValuePair in defaultHeader)
|
|
||||||
{
|
|
||||||
DefaultHeader.Add(keyValuePair);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var keyValuePair in apiKey)
|
|
||||||
{
|
|
||||||
ApiKey.Add(keyValuePair);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var keyValuePair in apiKeyPrefix)
|
|
||||||
{
|
|
||||||
ApiKeyPrefix.Add(keyValuePair);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="Configuration" /> class with different settings
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="apiClient">Api client</param>
|
|
||||||
/// <param name="defaultHeader">Dictionary of default HTTP header</param>
|
|
||||||
/// <param name="username">Username</param>
|
|
||||||
/// <param name="password">Password</param>
|
|
||||||
/// <param name="accessToken">accessToken</param>
|
|
||||||
/// <param name="apiKey">Dictionary of API key</param>
|
|
||||||
/// <param name="apiKeyPrefix">Dictionary of API key prefix</param>
|
|
||||||
/// <param name="tempFolderPath">Temp folder path</param>
|
|
||||||
/// <param name="dateTimeFormat">DateTime format string</param>
|
|
||||||
/// <param name="timeout">HTTP connection timeout (in milliseconds)</param>
|
|
||||||
/// <param name="userAgent">HTTP user agent</param>
|
|
||||||
[Obsolete("Use explicit object construction and setting of properties.", true)]
|
|
||||||
public Configuration(
|
|
||||||
// ReSharper disable UnusedParameter.Local
|
|
||||||
ApiClient apiClient = null,
|
|
||||||
IDictionary<string, string> defaultHeader = null,
|
|
||||||
string username = null,
|
|
||||||
string password = null,
|
|
||||||
string accessToken = null,
|
|
||||||
IDictionary<string, string> apiKey = null,
|
|
||||||
IDictionary<string, string> apiKeyPrefix = null,
|
|
||||||
string tempFolderPath = null,
|
|
||||||
string dateTimeFormat = null,
|
|
||||||
int timeout = 100000,
|
|
||||||
string userAgent = "{{httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{packageVersion}}/csharp{{/httpUserAgent}}"
|
|
||||||
// ReSharper restore UnusedParameter.Local
|
|
||||||
)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the Configuration class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="apiClient">Api client.</param>
|
|
||||||
[Obsolete("This constructor caused unexpected sharing of static data. It is no longer supported.", true)]
|
|
||||||
// ReSharper disable once UnusedParameter.Local
|
|
||||||
public Configuration(ApiClient apiClient)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Constructors
|
|
||||||
|
|
||||||
|
|
||||||
#region Properties
|
|
||||||
|
|
||||||
private ApiClient _apiClient = null;
|
|
||||||
/// <summary>
|
|
||||||
/// Gets an instance of an ApiClient for this configuration
|
|
||||||
/// </summary>
|
|
||||||
public virtual ApiClient ApiClient
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_apiClient == null) _apiClient = CreateApiClient();
|
|
||||||
return _apiClient;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String _basePath = null;
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the base path for API access.
|
|
||||||
/// </summary>
|
|
||||||
public virtual string BasePath {
|
|
||||||
get { return _basePath; }
|
|
||||||
set {
|
|
||||||
_basePath = value;
|
|
||||||
// pass-through to ApiClient if it's set.
|
|
||||||
if(_apiClient != null) {
|
|
||||||
_apiClient.RestClient.BaseUrl = new Uri(_basePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the default header.
|
|
||||||
/// </summary>
|
|
||||||
public virtual IDictionary<string, string> DefaultHeader { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the HTTP timeout (milliseconds) of ApiClient. Default to 100000 milliseconds.
|
|
||||||
/// </summary>
|
|
||||||
public virtual int Timeout
|
|
||||||
{
|
|
||||||
{{#netStandard}}get { return (int)ApiClient.RestClient.Timeout.GetValueOrDefault(TimeSpan.FromSeconds(0)).TotalMilliseconds; }
|
|
||||||
set { ApiClient.RestClient.Timeout = TimeSpan.FromMilliseconds(value); }{{/netStandard}}{{^netStandard}}
|
|
||||||
get { return ApiClient.RestClient.Timeout; }
|
|
||||||
set { ApiClient.RestClient.Timeout = value; }{{/netStandard}}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the HTTP user agent.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>Http user agent.</value>
|
|
||||||
public virtual string UserAgent { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the username (HTTP basic authentication).
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The username.</value>
|
|
||||||
public virtual string Username { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the password (HTTP basic authentication).
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The password.</value>
|
|
||||||
public virtual string Password { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the API key with prefix.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
|
|
||||||
/// <returns>API key with prefix.</returns>
|
|
||||||
public string GetApiKeyWithPrefix(string apiKeyIdentifier)
|
|
||||||
{
|
|
||||||
var apiKeyValue = "";
|
|
||||||
ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue);
|
|
||||||
var apiKeyPrefix = "";
|
|
||||||
if (ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix))
|
|
||||||
return apiKeyPrefix + " " + apiKeyValue;
|
|
||||||
else
|
|
||||||
return apiKeyValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the access token for OAuth2 authentication.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The access token.</value>
|
|
||||||
public virtual string AccessToken { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the temporary folder path to store the files downloaded from the server.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>Folder path.</value>
|
|
||||||
public virtual string TempFolderPath
|
|
||||||
{
|
|
||||||
get { return _tempFolderPath; }
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(value))
|
|
||||||
{
|
|
||||||
_tempFolderPath = Path.GetTempPath();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// create the directory if it does not exist
|
|
||||||
if (!Directory.Exists(value))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if the path contains directory separator at the end
|
|
||||||
if (value[value.Length - 1] == Path.DirectorySeparatorChar)
|
|
||||||
{
|
|
||||||
_tempFolderPath = value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_tempFolderPath = value + Path.DirectorySeparatorChar;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the date time format used when serializing in the ApiClient
|
|
||||||
/// By default, it's set to ISO 8601 - "o", for others see:
|
|
||||||
/// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx
|
|
||||||
/// and https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
|
|
||||||
/// No validation is done to ensure that the string you're providing is valid
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The DateTimeFormat string</value>
|
|
||||||
public virtual string DateTimeFormat
|
|
||||||
{
|
|
||||||
get { return _dateTimeFormat; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(value))
|
|
||||||
{
|
|
||||||
// Never allow a blank or null string, go back to the default
|
|
||||||
_dateTimeFormat = ISO8601_DATETIME_FORMAT;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Caution, no validation when you choose date time format other than ISO 8601
|
|
||||||
// Take a look at the above links
|
|
||||||
_dateTimeFormat = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The prefix of the API key.</value>
|
|
||||||
public virtual IDictionary<string, string> ApiKeyPrefix
|
|
||||||
{
|
|
||||||
get { return _apiKeyPrefix; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value == null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("ApiKeyPrefix collection may not be null.");
|
|
||||||
}
|
|
||||||
_apiKeyPrefix = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the API key based on the authentication name.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The API key.</value>
|
|
||||||
public virtual IDictionary<string, string> ApiKey
|
|
||||||
{
|
|
||||||
get { return _apiKey; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value == null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("ApiKey collection may not be null.");
|
|
||||||
}
|
|
||||||
_apiKey = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Properties
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add default header.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key">Header field name.</param>
|
|
||||||
/// <param name="value">Header field value.</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public void AddDefaultHeader(string key, string value)
|
|
||||||
{
|
|
||||||
DefaultHeader[key] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new <see cref="ApiClient" /> based on this <see cref="Configuration" /> instance.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public ApiClient CreateApiClient()
|
|
||||||
{
|
|
||||||
return new ApiClient(BasePath) { Configuration = this };
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a string with essential information for debugging.
|
|
||||||
/// </summary>
|
|
||||||
public static String ToDebugReport()
|
|
||||||
{
|
|
||||||
String report = "C# SDK ({{{packageName}}}) Debug Report:\n";
|
|
||||||
{{^netStandard}}
|
|
||||||
{{^supportsUWP}}
|
|
||||||
report += " OS: " + System.Environment.OSVersion + "\n";
|
|
||||||
report += " .NET Framework Version: " + System.Environment.Version + "\n";
|
|
||||||
{{/supportsUWP}}
|
|
||||||
{{/netStandard}}
|
|
||||||
{{#netStandard}}
|
|
||||||
report += " OS: " + System.Runtime.InteropServices.RuntimeInformation.OSDescription + "\n";
|
|
||||||
{{/netStandard}}
|
|
||||||
report += " Version of the API: {{{version}}}\n";
|
|
||||||
report += " SDK Package Version: {{{packageVersion}}}\n";
|
|
||||||
|
|
||||||
return report;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add Api Key Header.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key">Api Key name.</param>
|
|
||||||
/// <param name="value">Api Key value.</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public void AddApiKey(string key, string value)
|
|
||||||
{
|
|
||||||
ApiKey[key] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the API key prefix.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key">Api Key name.</param>
|
|
||||||
/// <param name="value">Api Key value.</param>
|
|
||||||
public void AddApiKeyPrefix(string key, string value)
|
|
||||||
{
|
|
||||||
ApiKeyPrefix[key] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Methods
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
{{>partial_header}}
|
|
||||||
|
|
||||||
using System;
|
|
||||||
{{#netStandard}}
|
|
||||||
using RestSharp.Portable;
|
|
||||||
{{/netStandard}}
|
|
||||||
{{^netStandard}}
|
|
||||||
using RestSharp;
|
|
||||||
{{/netStandard}}
|
|
||||||
|
|
||||||
namespace {{packageName}}.Client
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A delegate to ExceptionFactory method
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="methodName">Method name</param>
|
|
||||||
/// <param name="response">Response</param>
|
|
||||||
/// <returns>Exceptions</returns>
|
|
||||||
{{>visibility}} delegate Exception ExceptionFactory(string methodName, IRestResponse response);
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<!-- Ref: https://github.com/Fody/Fody -->
|
|
||||||
<Weavers>
|
|
||||||
<PropertyChanged/>
|
|
||||||
</Weavers>
|
|
@ -1,25 +0,0 @@
|
|||||||
{{>partial_header}}
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace {{packageName}}.Client
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// <see cref="GlobalConfiguration"/> provides a compile-time extension point for globally configuring
|
|
||||||
/// API Clients.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// A customized implementation via partial class may reside in another file and may
|
|
||||||
/// be excluded from automatic generation via a .openapi-generator-ignore file.
|
|
||||||
/// </remarks>
|
|
||||||
public partial class GlobalConfiguration : Configuration
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
{{>partial_header}}
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Linq;
|
|
||||||
{{#netStandard}}
|
|
||||||
using RestSharp.Portable;
|
|
||||||
{{/netStandard}}
|
|
||||||
{{^netStandard}}
|
|
||||||
using RestSharp;
|
|
||||||
{{/netStandard}}
|
|
||||||
|
|
||||||
namespace {{packageName}}.Client
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents configuration aspects required to interact with the API endpoints.
|
|
||||||
/// </summary>
|
|
||||||
{{>visibility}} interface IApiAccessor
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the configuration object
|
|
||||||
/// </summary>
|
|
||||||
/// <value>An instance of the Configuration</value>
|
|
||||||
Configuration Configuration {get; set;}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the base path of the API client.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The base path</value>
|
|
||||||
String GetBasePath();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Provides a factory method hook for the creation of exceptions.
|
|
||||||
/// </summary>
|
|
||||||
ExceptionFactory ExceptionFactory { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
{{>partial_header}}
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace {{packageName}}.Client
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a readable-only configuration contract.
|
|
||||||
/// </summary>
|
|
||||||
public interface IReadableConfiguration
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the access token.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>Access token.</value>
|
|
||||||
string AccessToken { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the API key.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>API key.</value>
|
|
||||||
IDictionary<string, string> ApiKey { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the API key prefix.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>API key prefix.</value>
|
|
||||||
IDictionary<string, string> ApiKeyPrefix { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the base path.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>Base path.</value>
|
|
||||||
string BasePath { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the date time format.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>Date time format.</value>
|
|
||||||
string DateTimeFormat { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the default header.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>Default header.</value>
|
|
||||||
IDictionary<string, string> DefaultHeader { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the temp folder path.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>Temp folder path.</value>
|
|
||||||
string TempFolderPath { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the HTTP connection timeout (in milliseconds)
|
|
||||||
/// </summary>
|
|
||||||
/// <value>HTTP connection timeout.</value>
|
|
||||||
int Timeout { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the user agent.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>User agent.</value>
|
|
||||||
string UserAgent { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the username.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>Username.</value>
|
|
||||||
string Username { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the password.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>Password.</value>
|
|
||||||
string Password { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the API key with prefix.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
|
|
||||||
/// <returns>API key with prefix.</returns>
|
|
||||||
string GetApiKeyWithPrefix(string apiKeyIdentifier);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,125 +0,0 @@
|
|||||||
{{>partial_header}}
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using JsonSubTypes;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using NUnit.Framework;
|
|
||||||
|
|
||||||
using {{packageName}}.{{apiPackage}};
|
|
||||||
using {{packageName}}.{{modelPackage}};
|
|
||||||
using {{packageName}}.Client;
|
|
||||||
|
|
||||||
namespace {{packageName}}.Test.Client
|
|
||||||
{
|
|
||||||
public class JsonSubTypesTests
|
|
||||||
{
|
|
||||||
[Test]
|
|
||||||
public void TestSimpleJsonSubTypesExample()
|
|
||||||
{
|
|
||||||
var animal =
|
|
||||||
JsonConvert.DeserializeObject<IAnimal>("{\"Kind\":\"Dog\",\"Breed\":\"Jack Russell Terrier\"}");
|
|
||||||
Assert.AreEqual("Jack Russell Terrier", (animal as Dog)?.Breed);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void DeserializeObjectWithCustomMapping()
|
|
||||||
{
|
|
||||||
var animal =
|
|
||||||
JsonConvert.DeserializeObject<Animal2>("{\"Sound\":\"Bark\",\"Breed\":\"Jack Russell Terrier\"}");
|
|
||||||
Assert.AreEqual("Jack Russell Terrier", (animal as Dog2)?.Breed);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void DeserializeObjectMappingByPropertyPresence()
|
|
||||||
{
|
|
||||||
string json =
|
|
||||||
"[{\"Department\":\"Department1\",\"JobTitle\":\"JobTitle1\",\"FirstName\":\"FirstName1\",\"LastName\":\"LastName1\"}," +
|
|
||||||
"{\"Department\":\"Department1\",\"JobTitle\":\"JobTitle1\",\"FirstName\":\"FirstName1\",\"LastName\":\"LastName1\"}," +
|
|
||||||
"{\"Skill\":\"Painter\",\"FirstName\":\"FirstName1\",\"LastName\":\"LastName1\"}]";
|
|
||||||
|
|
||||||
|
|
||||||
var persons = JsonConvert.DeserializeObject<ICollection<Person>>(json);
|
|
||||||
Assert.AreEqual("Painter", (persons.Last() as Artist)?.Skill);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[JsonConverter(typeof(JsonSubtypes), "Kind")]
|
|
||||||
public interface IAnimal
|
|
||||||
{
|
|
||||||
string Kind { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Dog : IAnimal
|
|
||||||
{
|
|
||||||
public Dog()
|
|
||||||
{
|
|
||||||
Kind = "Dog";
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Kind { get; }
|
|
||||||
public string Breed { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
class Cat : IAnimal
|
|
||||||
{
|
|
||||||
public Cat()
|
|
||||||
{
|
|
||||||
Kind = "Cat";
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Kind { get; }
|
|
||||||
bool Declawed { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[JsonConverter(typeof(JsonSubtypes), "Sound")]
|
|
||||||
[JsonSubtypes.KnownSubType(typeof(Dog2), "Bark")]
|
|
||||||
[JsonSubtypes.KnownSubType(typeof(Cat2), "Meow")]
|
|
||||||
public class Animal2
|
|
||||||
{
|
|
||||||
public virtual string Sound { get; }
|
|
||||||
public string Color { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Dog2 : Animal2
|
|
||||||
{
|
|
||||||
public Dog2()
|
|
||||||
{
|
|
||||||
Sound = "Bark";
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Sound { get; }
|
|
||||||
public string Breed { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Cat2 : Animal2
|
|
||||||
{
|
|
||||||
public Cat2()
|
|
||||||
{
|
|
||||||
Sound = "Meow";
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Sound { get; }
|
|
||||||
public bool Declawed { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[JsonConverter(typeof(JsonSubtypes))]
|
|
||||||
[JsonSubtypes.KnownSubTypeWithProperty(typeof(Employee), "JobTitle")]
|
|
||||||
[JsonSubtypes.KnownSubTypeWithProperty(typeof(Artist), "Skill")]
|
|
||||||
public class Person
|
|
||||||
{
|
|
||||||
public string FirstName { get; set; }
|
|
||||||
public string LastName { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Employee : Person
|
|
||||||
{
|
|
||||||
public string Department { get; set; }
|
|
||||||
public string JobTitle { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Artist : Person
|
|
||||||
{
|
|
||||||
public string Skill { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
{{>partial_header}}
|
|
||||||
using Newtonsoft.Json.Converters;
|
|
||||||
|
|
||||||
namespace {{packageName}}.Client
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Formatter for 'date' openapi formats ss defined by full-date - RFC3339
|
|
||||||
/// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types
|
|
||||||
/// </summary>
|
|
||||||
public class OpenAPIDateConverter : IsoDateTimeConverter
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="OpenAPIDateConverter" /> class.
|
|
||||||
/// </summary>
|
|
||||||
public OpenAPIDateConverter()
|
|
||||||
{
|
|
||||||
// full-date = date-fullyear "-" date-month "-" date-mday
|
|
||||||
DateTimeFormat = "yyyy-MM-dd";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
{{#appName}}
|
|
||||||
{{{.}}}
|
|
||||||
|
|
||||||
{{/appName}}
|
|
||||||
{{#appDescription}}
|
|
||||||
{{{.}}}
|
|
||||||
|
|
||||||
{{/appDescription}}
|
|
||||||
{{#version}}The version of the OpenAPI document: {{.}}{{/version}}
|
|
||||||
{{#infoEmail}}Contact: {{{.}}}{{/infoEmail}}
|
|
||||||
-->
|
|
||||||
<Project ToolsVersion="{{^netStandard}}12.0{{/netStandard}}{{#netStandard}}14.0{{/netStandard}}" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
{{#netStandard}}<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>{{/netStandard}}
|
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProjectGuid>{{packageGuid}}</ProjectGuid>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
|
||||||
<RootNamespace>{{packageName}}</RootNamespace>
|
|
||||||
<AssemblyName>{{packageName}}</AssemblyName>
|
|
||||||
{{#netStandard}}
|
|
||||||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
|
||||||
<TargetFrameworkVersion>{{targetFramework}}</TargetFrameworkVersion>
|
|
||||||
{{/netStandard}}
|
|
||||||
{{^netStandard}}
|
|
||||||
{{^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}}
|
|
||||||
{{/netStandard}}
|
|
||||||
<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>
|
|
||||||
<DocumentationFile>bin\Debug\{{packageName}}.xml</DocumentationFile>
|
|
||||||
</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>
|
|
||||||
<DocumentationFile>bin\Release\{{packageName}}.xml</DocumentationFile>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
{{^netStandard}}
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
|
||||||
<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.{{newtonsoft-json.version}}\lib\{{newtonsoft-json.targetFramework}}\Newtonsoft.Json.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('..\packages')">..\packages\Newtonsoft.Json.{{newtonsoft-json.version}}\lib\{{newtonsoft-json.targetFramework}}\Newtonsoft.Json.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.{{newtonsoft-json.version}}\lib\{{newtonsoft-json.targetFramework}}\Newtonsoft.Json.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\Newtonsoft.Json.{{newtonsoft-json.version}}\lib\{{newtonsoft-json.targetFramework}}\Newtonsoft.Json.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="JsonSubTypes">
|
|
||||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\JsonSubTypes.{{json-subtypes.version}}\lib\{{json-subtypes.targetFramework}}\JsonSubTypes.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('..\packages')">..\packages\JsonSubTypes.{{json-subtypes.version}}\lib\{{json-subtypes.targetFramework}}\JsonSubTypes.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\JsonSubTypes.{{json-subtypes.version}}\lib\{{json-subtypes.targetFramework}}\JsonSubTypes.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\JsonSubTypes.{{json-subtypes.version}}\lib\{{json-subtypes.targetFramework}}\JsonSubTypes.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="RestSharp">
|
|
||||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.{{restsharp.version}}\lib\{{restsharp.targetFramework}}\RestSharp.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.{{restsharp.version}}\lib\{{restsharp.targetFramework}}\RestSharp.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\RestSharp.{{restsharp.version}}\lib\{{restsharp.targetFramework}}\RestSharp.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\RestSharp.{{restsharp.version}}\lib\{{restsharp.targetFramework}}\RestSharp.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
{{#generatePropertyChanged}}
|
|
||||||
<Reference Include="PropertyChanged">
|
|
||||||
<HintPath>..\..\packages\PropertyChanged.Fody.{{propertychanged-fody.version}}\Lib\portable-net4+sl4+wp8+win8+wpa81+MonoAndroid16+MonoTouch40\PropertyChanged.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
{{/generatePropertyChanged}}
|
|
||||||
{{/netStandard}}
|
|
||||||
{{#netStandard}}
|
|
||||||
<!-- A reference to the entire .NET Framework is automatically included -->
|
|
||||||
<None Include="project.json" />
|
|
||||||
{{/netStandard}}
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="**\*.cs"
|
|
||||||
Exclude="obj\**" />
|
|
||||||
</ItemGroup>
|
|
||||||
{{^netStandard}}
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="packages.config" />
|
|
||||||
{{#generatePropertyChanged}}
|
|
||||||
<None Include="FodyWeavers.xml" />
|
|
||||||
{{/generatePropertyChanged}}
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
{{#generatePropertyChanged}}
|
|
||||||
<Import Project="..\..\packages\Fody.{{fody.version}}\build\portable-net+sl+win+wpa+wp\Fody.targets" Condition="Exists('..\..\packages\Fody.{{fody.version}}\build\portable-net+sl+win+wpa+wp\Fody.targets')" />
|
|
||||||
{{/generatePropertyChanged}}
|
|
||||||
{{/netStandard}}
|
|
||||||
{{#netStandard}}
|
|
||||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
{{/netStandard}}
|
|
||||||
</Project>
|
|
@ -1,228 +0,0 @@
|
|||||||
# {{packageName}} - the C# library for the {{appName}}
|
|
||||||
|
|
||||||
{{#appDescriptionWithNewLines}}
|
|
||||||
{{{.}}}
|
|
||||||
{{/appDescriptionWithNewLines}}
|
|
||||||
|
|
||||||
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
|
||||||
|
|
||||||
- API version: {{appVersion}}
|
|
||||||
- SDK version: {{packageVersion}}
|
|
||||||
{{^hideGenerationTimestamp}}
|
|
||||||
- Build date: {{generatedDate}}
|
|
||||||
{{/hideGenerationTimestamp}}
|
|
||||||
- Build package: {{generatorClass}}
|
|
||||||
{{#infoUrl}}
|
|
||||||
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
|
||||||
{{/infoUrl}}
|
|
||||||
|
|
||||||
## Frameworks supported
|
|
||||||
|
|
||||||
{{#netStandard}}
|
|
||||||
|
|
||||||
- .NET Core >=1.0
|
|
||||||
- .NET Framework >=4.6
|
|
||||||
- Mono/Xamarin >=vNext
|
|
||||||
- UWP >=10.0
|
|
||||||
{{/netStandard}}
|
|
||||||
{{^netStandard}}
|
|
||||||
{{^supportsUWP}}
|
|
||||||
|
|
||||||
- .NET 4.0 or later
|
|
||||||
- Windows Phone 7.1 (Mango)
|
|
||||||
{{/supportsUWP}}
|
|
||||||
{{#supportsUWP}}
|
|
||||||
|
|
||||||
- UWP
|
|
||||||
{{/supportsUWP}}
|
|
||||||
{{/netStandard}}
|
|
||||||
|
|
||||||
## Dependencies
|
|
||||||
|
|
||||||
{{#netStandard}}
|
|
||||||
|
|
||||||
- FubarCoder.RestSharp.Portable.Core >=4.0.7
|
|
||||||
- FubarCoder.RestSharp.Portable.HttpClient >=4.0.7
|
|
||||||
- Newtonsoft.Json >=10.0.3
|
|
||||||
{{/netStandard}}
|
|
||||||
{{^netStandard}}
|
|
||||||
|
|
||||||
- [RestSharp](https://www.nuget.org/packages/RestSharp) - 105.1.0 or later
|
|
||||||
- [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json/) - 7.0.0 or later
|
|
||||||
- [JsonSubTypes](https://www.nuget.org/packages/JsonSubTypes/) - 1.2.0 or later
|
|
||||||
|
|
||||||
The DLLs included in the package may not be the latest version. We recommend using [NuGet](https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages:
|
|
||||||
|
|
||||||
```
|
|
||||||
Install-Package RestSharp
|
|
||||||
Install-Package Newtonsoft.Json
|
|
||||||
Install-Package JsonSubTypes
|
|
||||||
```
|
|
||||||
|
|
||||||
NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742)
|
|
||||||
{{/netStandard}}
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
{{#netStandard}}
|
|
||||||
Generate the DLL using your preferred tool
|
|
||||||
{{/netStandard}}
|
|
||||||
{{^netStandard}}
|
|
||||||
Run the following command to generate the DLL
|
|
||||||
|
|
||||||
- [Mac/Linux] `/bin/sh build.sh`
|
|
||||||
- [Windows] `build.bat`
|
|
||||||
{{/netStandard}}
|
|
||||||
|
|
||||||
Then include the DLL (under the `bin` folder) in the C# project, and use the namespaces:
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
using {{packageName}}.{{apiPackage}};
|
|
||||||
using {{packageName}}.Client;
|
|
||||||
using {{packageName}}.{{modelPackage}};
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
{{^netStandard}}
|
|
||||||
|
|
||||||
## Packaging
|
|
||||||
|
|
||||||
A `.nuspec` is included with the project. You can follow the Nuget quickstart to [create](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package#create-the-package) and [publish](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package#publish-the-package) packages.
|
|
||||||
|
|
||||||
This `.nuspec` uses placeholders from the `.csproj`, so build the `.csproj` directly:
|
|
||||||
|
|
||||||
```
|
|
||||||
nuget pack -Build -OutputDirectory out {{packageName}}.csproj
|
|
||||||
```
|
|
||||||
|
|
||||||
Then, publish to a [local feed](https://docs.microsoft.com/en-us/nuget/hosting-packages/local-feeds) or [other host](https://docs.microsoft.com/en-us/nuget/hosting-packages/overview) and consume the new package via Nuget as usual.
|
|
||||||
|
|
||||||
{{/netStandard}}
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using {{packageName}}.{{apiPackage}};
|
|
||||||
using {{packageName}}.Client;
|
|
||||||
using {{packageName}}.{{modelPackage}};
|
|
||||||
|
|
||||||
namespace Example
|
|
||||||
{
|
|
||||||
public class {{operationId}}Example
|
|
||||||
{
|
|
||||||
public static void Main()
|
|
||||||
{
|
|
||||||
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
|
|
||||||
Configuration.Default.BasePath = "{{{basePath}}}";
|
|
||||||
{{#hasAuthMethods}}
|
|
||||||
{{#authMethods}}
|
|
||||||
{{#isBasic}}
|
|
||||||
{{#isBasicBasic}}
|
|
||||||
// Configure HTTP basic authorization: {{{name}}}
|
|
||||||
Configuration.Default.Username = "YOUR_USERNAME";
|
|
||||||
Configuration.Default.Password = "YOUR_PASSWORD";
|
|
||||||
{{/isBasicBasic}}
|
|
||||||
{{#isBasicBearer}}
|
|
||||||
// Configure HTTP bearer authorization: {{{name}}}
|
|
||||||
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
|
|
||||||
{{/isBasicBearer}}
|
|
||||||
{{/isBasic}}
|
|
||||||
{{#isApiKey}}
|
|
||||||
// Configure API key authorization: {{{name}}}
|
|
||||||
Configuration.Default.ApiKey.Add("{{{keyParamName}}}", "YOUR_API_KEY");
|
|
||||||
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
|
||||||
// Configuration.Default.ApiKeyPrefix.Add("{{{keyParamName}}}", "Bearer");
|
|
||||||
{{/isApiKey}}
|
|
||||||
{{#isOAuth}}
|
|
||||||
// Configure OAuth2 access token for authorization: {{{name}}}
|
|
||||||
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
|
|
||||||
{{/isOAuth}}
|
|
||||||
{{/authMethods}}
|
|
||||||
|
|
||||||
{{/hasAuthMethods}}
|
|
||||||
var apiInstance = new {{classname}}(Configuration.Default);
|
|
||||||
{{#allParams}}
|
|
||||||
{{#isPrimitiveType}}
|
|
||||||
var {{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
{{^isPrimitiveType}}
|
|
||||||
var {{paramName}} = new {{{dataType}}}(); // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
{{/allParams}}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
{{#summary}}
|
|
||||||
// {{{.}}}
|
|
||||||
{{/summary}}
|
|
||||||
{{#returnType}}{{{.}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}}
|
|
||||||
Debug.WriteLine(result);{{/returnType}}
|
|
||||||
}
|
|
||||||
catch (ApiException e)
|
|
||||||
{
|
|
||||||
Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message );
|
|
||||||
Debug.Print("Status Code: "+ e.ErrorCode);
|
|
||||||
Debug.Print(e.StackTrace);
|
|
||||||
}
|
|
||||||
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Documentation for API Endpoints
|
|
||||||
|
|
||||||
All URIs are relative to *{{{basePath}}}*
|
|
||||||
|
|
||||||
Class | Method | HTTP request | Description
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{{summary}}}
|
|
||||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
|
||||||
|
|
||||||
## Documentation for Models
|
|
||||||
|
|
||||||
{{#modelPackage}}
|
|
||||||
{{#models}}{{#model}} - [{{{modelPackage}}}.{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
|
|
||||||
{{/model}}{{/models}}
|
|
||||||
{{/modelPackage}}
|
|
||||||
{{^modelPackage}}
|
|
||||||
No model defined in this package
|
|
||||||
{{/modelPackage}}
|
|
||||||
|
|
||||||
<a id="documentation-for-authorization"></a>
|
|
||||||
## Documentation for Authorization
|
|
||||||
|
|
||||||
{{^authMethods}}Endpoints do not require authorization.{{/authMethods}}
|
|
||||||
{{#hasAuthMethods}}Authentication schemes defined for the API:{{/hasAuthMethods}}
|
|
||||||
{{#authMethods}}
|
|
||||||
<a id="{{name}}"></a>
|
|
||||||
### {{name}}
|
|
||||||
|
|
||||||
{{#isApiKey}}
|
|
||||||
- **Type**: API key
|
|
||||||
- **API key parameter name**: {{keyParamName}}
|
|
||||||
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
|
|
||||||
{{/isApiKey}}
|
|
||||||
{{#isBasic}}
|
|
||||||
{{#isBasicBasic}}
|
|
||||||
- **Type**: HTTP basic authentication
|
|
||||||
{{/isBasicBasic}}
|
|
||||||
{{#isBasicBearer}}
|
|
||||||
- **Type**: HTTP bearer authentication
|
|
||||||
{{/isBasicBearer}}
|
|
||||||
{{#isHttpSignature}}
|
|
||||||
- **Type**: HTTP signature authentication
|
|
||||||
{{/isHttpSignature}}
|
|
||||||
{{/isBasic}}
|
|
||||||
{{#isOAuth}}
|
|
||||||
- **Type**: OAuth
|
|
||||||
- **Flow**: {{flow}}
|
|
||||||
- **Authorization URL**: {{authorizationUrl}}
|
|
||||||
- **Scopes**: {{^scopes}}N/A{{/scopes}}
|
|
||||||
{{#scopes}} - {{scope}}: {{description}}
|
|
||||||
{{/scopes}}
|
|
||||||
{{/isOAuth}}
|
|
||||||
|
|
||||||
{{/authMethods}}
|
|
@ -1,137 +0,0 @@
|
|||||||
{{>partial_header}}
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace {{packageName}}.Client
|
|
||||||
{
|
|
||||||
public class ReadOnlyDictionary<T, K> : IDictionary<T, K>
|
|
||||||
{
|
|
||||||
private IDictionary<T, K> _dictionaryImplementation;
|
|
||||||
public IEnumerator<KeyValuePair<T, K>> GetEnumerator()
|
|
||||||
{
|
|
||||||
return _dictionaryImplementation.GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReadOnlyDictionary()
|
|
||||||
{
|
|
||||||
_dictionaryImplementation = new Dictionary<T, K>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReadOnlyDictionary(IDictionary<T, K> dictionaryImplementation)
|
|
||||||
{
|
|
||||||
if (dictionaryImplementation == null) throw new ArgumentNullException("dictionaryImplementation");
|
|
||||||
_dictionaryImplementation = dictionaryImplementation;
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator()
|
|
||||||
{
|
|
||||||
return ((IEnumerable) _dictionaryImplementation).GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Add(KeyValuePair<T, K> item)
|
|
||||||
{
|
|
||||||
throw new ReadonlyOperationException("This instance is readonly.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Clear()
|
|
||||||
{
|
|
||||||
throw new ReadonlyOperationException("This instance is readonly.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Contains(KeyValuePair<T, K> item)
|
|
||||||
{
|
|
||||||
return _dictionaryImplementation.Contains(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CopyTo(KeyValuePair<T, K>[] array, int arrayIndex)
|
|
||||||
{
|
|
||||||
_dictionaryImplementation.CopyTo(array, arrayIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Remove(KeyValuePair<T, K> item)
|
|
||||||
{
|
|
||||||
throw new ReadonlyOperationException("This instance is readonly.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Count
|
|
||||||
{
|
|
||||||
get { return _dictionaryImplementation.Count; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsReadOnly
|
|
||||||
{
|
|
||||||
get { return true; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Add(T key, K value)
|
|
||||||
{
|
|
||||||
throw new ReadonlyOperationException("This instance is readonly.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ContainsKey(T key)
|
|
||||||
{
|
|
||||||
return _dictionaryImplementation.ContainsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Remove(T key)
|
|
||||||
{
|
|
||||||
throw new ReadonlyOperationException("This instance is readonly.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TryGetValue(T key, out K value)
|
|
||||||
{
|
|
||||||
return _dictionaryImplementation.TryGetValue(key, out value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public K this[T key]
|
|
||||||
{
|
|
||||||
get { return _dictionaryImplementation[key]; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
throw new ReadonlyOperationException("This instance is readonly.");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICollection<T> Keys
|
|
||||||
{
|
|
||||||
get { return _dictionaryImplementation.Keys; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICollection<K> Values
|
|
||||||
{
|
|
||||||
get { return _dictionaryImplementation.Values; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class ReadonlyOperationException : Exception
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// For guidelines regarding the creation of new exception types, see
|
|
||||||
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
|
|
||||||
// and
|
|
||||||
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
|
|
||||||
//
|
|
||||||
|
|
||||||
public ReadonlyOperationException()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReadonlyOperationException(string message) : base(message)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReadonlyOperationException(string message, Exception inner) : base(message, inner)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ReadonlyOperationException(
|
|
||||||
SerializationInfo info,
|
|
||||||
StreamingContext context) : base(info, context)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio {{^netStandard}}2012{{/netStandard}}{{#netStandard}}14{{/netStandard}}
|
|
||||||
VisualStudioVersion = {{^netStandard}}12.0.0.0{{/netStandard}}{{#netStandard}}14.0.25420.1{{/netStandard}}
|
|
||||||
MinimumVisualStudioVersion = {{^netStandard}}10.0.0.1{{/netStandard}}{{#netStandard}}10.0.40219.1{{/netStandard}}
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "{{packageName}}", "src\{{packageName}}\{{packageName}}.csproj", "{{packageGuid}}"
|
|
||||||
EndProject
|
|
||||||
{{^excludeTests}}Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "{{testPackageName}}", "src\{{testPackageName}}\{{testPackageName}}.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}"
|
|
||||||
EndProject
|
|
||||||
{{/excludeTests}}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
|
|
@ -1,100 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
{{#appName}}
|
|
||||||
{{{.}}}
|
|
||||||
|
|
||||||
{{/appName}}
|
|
||||||
{{#appDescription}}
|
|
||||||
{{{.}}}
|
|
||||||
|
|
||||||
{{/appDescription}}
|
|
||||||
{{#version}}The version of the OpenAPI document: {{{.}}}{{/version}}
|
|
||||||
{{#infoEmail}}Contact: {{{.}}}{{/infoEmail}}
|
|
||||||
-->
|
|
||||||
<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="System.ComponentModel.DataAnnotations" />
|
|
||||||
<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.{{newtonsoft-json.version}}\lib\{{newtonsoft-json.targetFramework}}\Newtonsoft.Json.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('..\packages')">..\packages\Newtonsoft.Json.{{newtonsoft-json.version}}\lib\{{newtonsoft-json.targetFramework}}\Newtonsoft.Json.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.{{newtonsoft-json.version}}\lib\{{newtonsoft-json.targetFramework}}\Newtonsoft.Json.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\Newtonsoft.Json.{{newtonsoft-json.version}}\lib\{{newtonsoft-json.targetFramework}}\Newtonsoft.Json.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="JsonSubTypes">
|
|
||||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\JsonSubTypes.{{json-subtypes.version}}\lib\{{json-subtypes.targetFramework}}\JsonSubTypes.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('..\packages')">..\packages\JsonSubTypes.{{json-subtypes.version}}\lib\{{json-subtypes.targetFramework}}\JsonSubTypes.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\JsonSubTypes.{{json-subtypes.version}}\lib\{{json-subtypes.targetFramework}}\JsonSubTypes.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\JsonSubTypes.{{json-subtypes.version}}\lib\{{json-subtypes.targetFramework}}\JsonSubTypes.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="RestSharp">
|
|
||||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.{{restsharp.version}}\lib\{{restsharp.targetFramework}}\RestSharp.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.{{restsharp.version}}\lib\{{restsharp.targetFramework}}\RestSharp.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\RestSharp.{{restsharp.version}}\lib\{{restsharp.targetFramework}}\RestSharp.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\RestSharp.{{restsharp.version}}\lib\{{restsharp.targetFramework}}\RestSharp.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="nunit.framework">
|
|
||||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\NUnit.{{nunit.version}}\lib\{{nunit.targetFramework}}\nunit.framework.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('..\packages')">..\packages\NUnit.{{nunit.version}}\lib\{{nunit.targetFramework}}\nunit.framework.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\NUnit.{{nunit.version}}\lib\{{nunit.targetFramework}}\nunit.framework.dll</HintPath>
|
|
||||||
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\NUnit.{{nunit.version}}\lib\{{nunit.targetFramework}}\nunit.framework.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="**\*.cs"
|
|
||||||
Exclude="obj\**"/>
|
|
||||||
</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>
|
|
@ -1,508 +0,0 @@
|
|||||||
{{>partial_header}}
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
{{#netStandard}}
|
|
||||||
using RestSharp.Portable;
|
|
||||||
{{/netStandard}}
|
|
||||||
{{^netStandard}}
|
|
||||||
using RestSharp;
|
|
||||||
{{/netStandard}}
|
|
||||||
using {{packageName}}.Client;
|
|
||||||
{{#hasImport}}using {{packageName}}.{{modelPackage}};
|
|
||||||
{{/hasImport}}
|
|
||||||
|
|
||||||
namespace {{packageName}}.{{apiPackage}}
|
|
||||||
{
|
|
||||||
{{#operations}}
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a collection of functions to interact with the API endpoints
|
|
||||||
/// </summary>
|
|
||||||
{{>visibility}} interface {{interfacePrefix}}{{classname}} : IApiAccessor
|
|
||||||
{
|
|
||||||
#region Synchronous Operations
|
|
||||||
{{#operation}}
|
|
||||||
/// <summary>
|
|
||||||
/// {{{summary}}}
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// {{{notes}}}
|
|
||||||
/// </remarks>
|
|
||||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
|
||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
|
||||||
{{/allParams}}/// <returns>{{{returnType}}}</returns>
|
|
||||||
{{#isDeprecated}}
|
|
||||||
[Obsolete]
|
|
||||||
{{/isDeprecated}}
|
|
||||||
{{{returnType}}}{{^returnType}}void{{/returnType}} {{operationId}} ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}});
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// {{{summary}}}
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// {{{notes}}}
|
|
||||||
/// </remarks>
|
|
||||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
|
||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
|
||||||
{{/allParams}}/// <returns>ApiResponse of {{{returnType}}}{{^returnType}}Object(void){{/returnType}}</returns>
|
|
||||||
{{#isDeprecated}}
|
|
||||||
[Obsolete]
|
|
||||||
{{/isDeprecated}}
|
|
||||||
ApiResponse<{{{returnType}}}{{^returnType}}Object{{/returnType}}> {{operationId}}WithHttpInfo ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}});
|
|
||||||
{{/operation}}
|
|
||||||
#endregion Synchronous Operations
|
|
||||||
{{#supportsAsync}}
|
|
||||||
#region Asynchronous Operations
|
|
||||||
{{#operation}}
|
|
||||||
/// <summary>
|
|
||||||
/// {{{summary}}}
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// {{{notes}}}
|
|
||||||
/// </remarks>
|
|
||||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
|
||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
|
||||||
{{/allParams}}/// <param name="cancellationToken">Cancellation Token to cancel request (optional) </param>
|
|
||||||
/// <returns>Task of {{{returnType}}}{{^returnType}}void{{/returnType}}</returns>
|
|
||||||
{{#isDeprecated}}
|
|
||||||
[Obsolete]
|
|
||||||
{{/isDeprecated}}
|
|
||||||
{{#returnType}}System.Threading.Tasks.Task<{{{.}}}>{{/returnType}}{{^returnType}}System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}CancellationToken cancellationToken = default(CancellationToken));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// {{summary}}
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// {{{notes}}}
|
|
||||||
/// </remarks>
|
|
||||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
|
||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
|
||||||
{{/allParams}}/// <param name="cancellationToken">Cancellation Token to cancel request (optional) </param>
|
|
||||||
/// <returns>Task of ApiResponse{{#returnType}} ({{.}}){{/returnType}}</returns>
|
|
||||||
{{#isDeprecated}}
|
|
||||||
[Obsolete]
|
|
||||||
{{/isDeprecated}}
|
|
||||||
System.Threading.Tasks.Task<ApiResponse<{{{returnType}}}{{^returnType}}Object{{/returnType}}>> {{operationId}}WithHttpInfoAsync ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}CancellationToken cancellationToken = default(CancellationToken));
|
|
||||||
{{/operation}}
|
|
||||||
#endregion Asynchronous Operations
|
|
||||||
{{/supportsAsync}}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a collection of functions to interact with the API endpoints
|
|
||||||
/// </summary>
|
|
||||||
{{>visibility}} partial class {{classname}} : {{interfacePrefix}}{{classname}}
|
|
||||||
{
|
|
||||||
private {{packageName}}.Client.ExceptionFactory _exceptionFactory = (name, response) => null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="{{classname}}"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public {{classname}}(String basePath)
|
|
||||||
{
|
|
||||||
this.Configuration = new {{packageName}}.Client.Configuration { BasePath = basePath };
|
|
||||||
|
|
||||||
ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="{{classname}}"/> class
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public {{classname}}()
|
|
||||||
{
|
|
||||||
this.Configuration = {{packageName}}.Client.Configuration.Default;
|
|
||||||
|
|
||||||
ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="{{classname}}"/> class
|
|
||||||
/// using Configuration object
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="configuration">An instance of Configuration</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public {{classname}}({{packageName}}.Client.Configuration configuration = null)
|
|
||||||
{
|
|
||||||
if (configuration == null) // use the default one in Configuration
|
|
||||||
this.Configuration = {{packageName}}.Client.Configuration.Default;
|
|
||||||
else
|
|
||||||
this.Configuration = configuration;
|
|
||||||
|
|
||||||
ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <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 'Configuration.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 {{packageName}}.Client.Configuration Configuration {get; set;}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Provides a factory method hook for the creation of exceptions.
|
|
||||||
/// </summary>
|
|
||||||
public {{packageName}}.Client.ExceptionFactory ExceptionFactory
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported.");
|
|
||||||
}
|
|
||||||
return _exceptionFactory;
|
|
||||||
}
|
|
||||||
set { _exceptionFactory = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the default header.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Dictionary of HTTP header</returns>
|
|
||||||
[Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")]
|
|
||||||
public IDictionary<String, String> DefaultHeader()
|
|
||||||
{
|
|
||||||
return new {{^net35}}ReadOnly{{/net35}}Dictionary<string, string>(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);
|
|
||||||
}
|
|
||||||
|
|
||||||
{{#operation}}
|
|
||||||
/// <summary>
|
|
||||||
/// {{{summary}}} {{{notes}}}
|
|
||||||
/// </summary>
|
|
||||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
|
||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
|
||||||
{{/allParams}}/// <returns>{{{returnType}}}</returns>
|
|
||||||
{{#isDeprecated}}
|
|
||||||
[Obsolete]
|
|
||||||
{{/isDeprecated}}
|
|
||||||
public {{{returnType}}}{{^returnType}}void{{/returnType}} {{operationId}} ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}})
|
|
||||||
{
|
|
||||||
{{#returnType}}ApiResponse<{{{returnType}}}> localVarResponse = {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
|
|
||||||
return localVarResponse.Data;{{/returnType}}{{^returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{/returnType}}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// {{{summary}}} {{{notes}}}
|
|
||||||
/// </summary>
|
|
||||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
|
||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
|
||||||
{{/allParams}}/// <returns>ApiResponse of {{{returnType}}}{{^returnType}}Object(void){{/returnType}}</returns>
|
|
||||||
{{#isDeprecated}}
|
|
||||||
[Obsolete]
|
|
||||||
{{/isDeprecated}}
|
|
||||||
public ApiResponse<{{{returnType}}}{{^returnType}}Object{{/returnType}}> {{operationId}}WithHttpInfo ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}})
|
|
||||||
{
|
|
||||||
{{#allParams}}
|
|
||||||
{{#required}}
|
|
||||||
// verify the required parameter '{{paramName}}' is set
|
|
||||||
if ({{paramName}} == null)
|
|
||||||
throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}");
|
|
||||||
{{/required}}
|
|
||||||
{{/allParams}}
|
|
||||||
|
|
||||||
var localVarPath = "{{#netStandard}}.{{/netStandard}}{{{path}}}";
|
|
||||||
var localVarPathParams = new Dictionary<String, String>();
|
|
||||||
var localVarQueryParams = new List<KeyValuePair<String, String>>();
|
|
||||||
var localVarHeaderParams = new Dictionary<String, String>(this.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[] {
|
|
||||||
{{#consumes}}
|
|
||||||
"{{{mediaType}}}"{{^-last}}, {{/-last}}
|
|
||||||
{{/consumes}}
|
|
||||||
};
|
|
||||||
String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
|
|
||||||
|
|
||||||
// to determine the Accept header
|
|
||||||
String[] localVarHttpHeaderAccepts = new String[] {
|
|
||||||
{{#produces}}
|
|
||||||
"{{{mediaType}}}"{{^-last}},{{/-last}}
|
|
||||||
{{/produces}}
|
|
||||||
};
|
|
||||||
String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
|
|
||||||
if (localVarHttpHeaderAccept != null)
|
|
||||||
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
|
|
||||||
|
|
||||||
{{#pathParams}}
|
|
||||||
if ({{paramName}} != null) localVarPathParams.Add("{{baseName}}", this.Configuration.ApiClient.ParameterToString({{paramName}})); // path parameter
|
|
||||||
{{/pathParams}}
|
|
||||||
{{#queryParams}}
|
|
||||||
if ({{paramName}} != null) localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("{{collectionFormat}}", "{{baseName}}", {{paramName}})); // query parameter
|
|
||||||
{{/queryParams}}
|
|
||||||
{{#headerParams}}
|
|
||||||
if ({{paramName}} != null) localVarHeaderParams.Add("{{baseName}}", this.Configuration.ApiClient.ParameterToString({{paramName}})); // header parameter
|
|
||||||
{{/headerParams}}
|
|
||||||
{{#formParams}}
|
|
||||||
if ({{paramName}} != null) {{#isFile}}localVarFileParams.Add("{{baseName}}", this.Configuration.ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isFile}}{{^isFile}}localVarFormParams.Add("{{baseName}}", {{#vendorExtensions.x-is-json}}{{paramName}}.ToJson(){{/vendorExtensions.x-is-json}}{{^vendorExtensions.x-is-json}}this.Configuration.ApiClient.{{#isPrimitiveType}}ParameterToString{{/isPrimitiveType}}{{^isPrimitiveType}}Serialize{{/isPrimitiveType}}({{paramName}}){{/vendorExtensions.x-is-json}}); // form parameter{{/isFile}}
|
|
||||||
{{/formParams}}
|
|
||||||
{{#bodyParam}}
|
|
||||||
if ({{paramName}} != null && {{paramName}}.GetType() != typeof(byte[]))
|
|
||||||
{
|
|
||||||
localVarPostBody = this.Configuration.ApiClient.Serialize({{paramName}}); // http body (model) parameter
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
localVarPostBody = {{paramName}}; // byte array
|
|
||||||
}
|
|
||||||
{{/bodyParam}}
|
|
||||||
|
|
||||||
{{#authMethods}}
|
|
||||||
// authentication ({{name}}) required
|
|
||||||
{{#isApiKey}}
|
|
||||||
{{#isKeyInHeader}}
|
|
||||||
if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
|
||||||
{
|
|
||||||
localVarHeaderParams["{{keyParamName}}"] = this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}");
|
|
||||||
}
|
|
||||||
{{/isKeyInHeader}}
|
|
||||||
{{#isKeyInQuery}}
|
|
||||||
if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
|
||||||
{
|
|
||||||
localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")));
|
|
||||||
}
|
|
||||||
{{/isKeyInQuery}}
|
|
||||||
{{/isApiKey}}
|
|
||||||
{{#isBasic}}
|
|
||||||
{{#isBasicBasic}}
|
|
||||||
// http basic authentication required
|
|
||||||
if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password))
|
|
||||||
{
|
|
||||||
localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password);
|
|
||||||
}
|
|
||||||
{{/isBasicBasic}}
|
|
||||||
{{#isBasicBearer}}
|
|
||||||
// http bearer authentication required
|
|
||||||
if (!String.IsNullOrEmpty(this.Configuration.AccessToken))
|
|
||||||
{
|
|
||||||
localVarHeaderParams["Authorization"] = "Bearer " + this.Configuration.AccessToken;
|
|
||||||
}
|
|
||||||
{{/isBasicBearer}}
|
|
||||||
{{/isBasic}}
|
|
||||||
{{#isOAuth}}
|
|
||||||
// oauth required
|
|
||||||
if (!String.IsNullOrEmpty(this.Configuration.AccessToken))
|
|
||||||
{
|
|
||||||
localVarHeaderParams["Authorization"] = "Bearer " + this.Configuration.AccessToken;
|
|
||||||
}
|
|
||||||
{{/isOAuth}}
|
|
||||||
{{/authMethods}}
|
|
||||||
|
|
||||||
// make the HTTP request
|
|
||||||
IRestResponse localVarResponse = (IRestResponse) this.Configuration.ApiClient.CallApi(localVarPath,
|
|
||||||
Method.{{httpMethod}}, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
|
||||||
localVarPathParams, localVarHttpContentType);
|
|
||||||
|
|
||||||
int localVarStatusCode = (int) localVarResponse.StatusCode;
|
|
||||||
|
|
||||||
if (ExceptionFactory != null)
|
|
||||||
{
|
|
||||||
Exception exception = ExceptionFactory("{{operationId}}", localVarResponse);
|
|
||||||
if (exception != null) throw exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
{{#returnType}}
|
|
||||||
return new ApiResponse<{{{returnType}}}>(localVarStatusCode,
|
|
||||||
localVarResponse.Headers.ToDictionary(x => x.{{^netStandard}}Name{{/netStandard}}{{#netStandard}}Key{{/netStandard}}, x => string.Join(",", x.Value){{#caseInsensitiveResponseHeaders}}, StringComparer.OrdinalIgnoreCase{{/caseInsensitiveResponseHeaders}}),
|
|
||||||
({{{returnType}}}) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof({{{returnContainer}}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}})));
|
|
||||||
{{/returnType}}
|
|
||||||
{{^returnType}}
|
|
||||||
return new ApiResponse<Object>(localVarStatusCode,
|
|
||||||
localVarResponse.Headers.ToDictionary(x => x.{{^netStandard}}Name{{/netStandard}}{{#netStandard}}Key{{/netStandard}}, x => string.Join(",", x.Value){{#caseInsensitiveResponseHeaders}}, StringComparer.OrdinalIgnoreCase{{/caseInsensitiveResponseHeaders}}),
|
|
||||||
null);
|
|
||||||
{{/returnType}}
|
|
||||||
}
|
|
||||||
|
|
||||||
{{#supportsAsync}}
|
|
||||||
/// <summary>
|
|
||||||
/// {{{summary}}} {{{notes}}}
|
|
||||||
/// </summary>
|
|
||||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
|
||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
|
||||||
{{/allParams}}/// <param name="cancellationToken">Cancellation Token to cancel request (optional) </param>
|
|
||||||
/// <returns>Task of {{{returnType}}}{{^returnType}}void{{/returnType}}</returns>
|
|
||||||
{{#isDeprecated}}
|
|
||||||
[Obsolete]
|
|
||||||
{{/isDeprecated}}
|
|
||||||
{{#returnType}}public async System.Threading.Tasks.Task<{{{.}}}>{{/returnType}}{{^returnType}}public async System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}CancellationToken cancellationToken = default(CancellationToken))
|
|
||||||
{
|
|
||||||
{{#returnType}}ApiResponse<{{{returnType}}}> localVarResponse = await {{operationId}}WithHttpInfoAsync({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken);
|
|
||||||
return localVarResponse.Data;{{/returnType}}{{^returnType}}await {{operationId}}WithHttpInfoAsync({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken);{{/returnType}}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// {{{summary}}} {{{notes}}}
|
|
||||||
/// </summary>
|
|
||||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
|
||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
|
|
||||||
{{/allParams}}/// <param name="cancellationToken">Cancellation Token to cancel request (optional) </param>
|
|
||||||
/// <returns>Task of ApiResponse{{#returnType}} ({{.}}){{/returnType}}</returns>
|
|
||||||
{{#isDeprecated}}
|
|
||||||
[Obsolete]
|
|
||||||
{{/isDeprecated}}
|
|
||||||
public async System.Threading.Tasks.Task<ApiResponse<{{{returnType}}}{{^returnType}}Object{{/returnType}}>> {{operationId}}WithHttpInfoAsync ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}CancellationToken cancellationToken = default(CancellationToken))
|
|
||||||
{
|
|
||||||
{{#allParams}}
|
|
||||||
{{#required}}
|
|
||||||
// verify the required parameter '{{paramName}}' is set
|
|
||||||
if ({{paramName}} == null)
|
|
||||||
throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}");
|
|
||||||
{{/required}}
|
|
||||||
{{/allParams}}
|
|
||||||
|
|
||||||
var localVarPath = "{{#netStandard}}.{{/netStandard}}{{{path}}}";
|
|
||||||
var localVarPathParams = new Dictionary<String, String>();
|
|
||||||
var localVarQueryParams = new List<KeyValuePair<String, String>>();
|
|
||||||
var localVarHeaderParams = new Dictionary<String, String>(this.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[] {
|
|
||||||
{{#consumes}}
|
|
||||||
"{{{mediaType}}}"{{^-last}}, {{/-last}}
|
|
||||||
{{/consumes}}
|
|
||||||
};
|
|
||||||
String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
|
|
||||||
|
|
||||||
// to determine the Accept header
|
|
||||||
String[] localVarHttpHeaderAccepts = new String[] {
|
|
||||||
{{#produces}}
|
|
||||||
"{{{mediaType}}}"{{^-last}},{{/-last}}
|
|
||||||
{{/produces}}
|
|
||||||
};
|
|
||||||
String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
|
|
||||||
if (localVarHttpHeaderAccept != null)
|
|
||||||
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
|
|
||||||
|
|
||||||
{{#pathParams}}
|
|
||||||
if ({{paramName}} != null) localVarPathParams.Add("{{baseName}}", this.Configuration.ApiClient.ParameterToString({{paramName}})); // path parameter
|
|
||||||
{{/pathParams}}
|
|
||||||
{{#queryParams}}
|
|
||||||
if ({{paramName}} != null) localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("{{collectionFormat}}", "{{baseName}}", {{paramName}})); // query parameter
|
|
||||||
{{/queryParams}}
|
|
||||||
{{#headerParams}}
|
|
||||||
if ({{paramName}} != null) localVarHeaderParams.Add("{{baseName}}", this.Configuration.ApiClient.ParameterToString({{paramName}})); // header parameter
|
|
||||||
{{/headerParams}}
|
|
||||||
{{#formParams}}
|
|
||||||
if ({{paramName}} != null) {{#isFile}}localVarFileParams.Add("{{baseName}}", this.Configuration.ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isFile}}{{^isFile}}localVarFormParams.Add("{{baseName}}", {{#vendorExtensions.x-is-json}}{{paramName}}.ToJson(){{/vendorExtensions.x-is-json}}{{^vendorExtensions.x-is-json}}this.Configuration.ApiClient.{{#isPrimitiveType}}ParameterToString{{/isPrimitiveType}}{{^isPrimitiveType}}Serialize{{/isPrimitiveType}}({{paramName}}){{/vendorExtensions.x-is-json}}); // form parameter{{/isFile}}
|
|
||||||
{{/formParams}}
|
|
||||||
{{#bodyParam}}
|
|
||||||
if ({{paramName}} != null && {{paramName}}.GetType() != typeof(byte[]))
|
|
||||||
{
|
|
||||||
localVarPostBody = this.Configuration.ApiClient.Serialize({{paramName}}); // http body (model) parameter
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
localVarPostBody = {{paramName}}; // byte array
|
|
||||||
}
|
|
||||||
{{/bodyParam}}
|
|
||||||
|
|
||||||
{{#authMethods}}
|
|
||||||
// authentication ({{name}}) required
|
|
||||||
{{#isApiKey}}
|
|
||||||
{{#isKeyInHeader}}
|
|
||||||
if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
|
||||||
{
|
|
||||||
localVarHeaderParams["{{keyParamName}}"] = this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}");
|
|
||||||
}
|
|
||||||
{{/isKeyInHeader}}
|
|
||||||
{{#isKeyInQuery}}
|
|
||||||
if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
|
||||||
{
|
|
||||||
localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "{{keyParamName}}", this.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")));
|
|
||||||
}
|
|
||||||
{{/isKeyInQuery}}
|
|
||||||
{{/isApiKey}}
|
|
||||||
{{#isBasic}}
|
|
||||||
{{#isBasicBasic}}
|
|
||||||
// http basic authentication required
|
|
||||||
if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password))
|
|
||||||
{
|
|
||||||
localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password);
|
|
||||||
}
|
|
||||||
{{/isBasicBasic}}
|
|
||||||
{{#isBasicBearer}}
|
|
||||||
// http bearer authentication required
|
|
||||||
if (!String.IsNullOrEmpty(this.Configuration.AccessToken))
|
|
||||||
{
|
|
||||||
localVarHeaderParams["Authorization"] = "Bearer " + this.Configuration.AccessToken;
|
|
||||||
}
|
|
||||||
{{/isBasicBearer}}
|
|
||||||
{{/isBasic}}
|
|
||||||
{{#isOAuth}}
|
|
||||||
// oauth required
|
|
||||||
if (!String.IsNullOrEmpty(this.Configuration.AccessToken))
|
|
||||||
{
|
|
||||||
localVarHeaderParams["Authorization"] = "Bearer " + this.Configuration.AccessToken;
|
|
||||||
}
|
|
||||||
{{/isOAuth}}
|
|
||||||
{{/authMethods}}
|
|
||||||
|
|
||||||
// make the HTTP request
|
|
||||||
IRestResponse localVarResponse = (IRestResponse) await this.Configuration.ApiClient.CallApiAsync(localVarPath,
|
|
||||||
Method.{{httpMethod}}, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
|
||||||
localVarPathParams, localVarHttpContentType, cancellationToken);
|
|
||||||
|
|
||||||
int localVarStatusCode = (int) localVarResponse.StatusCode;
|
|
||||||
|
|
||||||
if (ExceptionFactory != null)
|
|
||||||
{
|
|
||||||
Exception exception = ExceptionFactory("{{operationId}}", localVarResponse);
|
|
||||||
if (exception != null) throw exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
{{#returnType}}
|
|
||||||
return new ApiResponse<{{{returnType}}}>(localVarStatusCode,
|
|
||||||
localVarResponse.Headers.ToDictionary(x => x.{{^netStandard}}Name{{/netStandard}}{{#netStandard}}Key{{/netStandard}}, x => string.Join(",", x.Value){{#caseInsensitiveResponseHeaders}}, StringComparer.OrdinalIgnoreCase{{/caseInsensitiveResponseHeaders}}),
|
|
||||||
({{{returnType}}}) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof({{{returnContainer}}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}})));
|
|
||||||
{{/returnType}}
|
|
||||||
{{^returnType}}
|
|
||||||
return new ApiResponse<Object>(localVarStatusCode,
|
|
||||||
localVarResponse.Headers.ToDictionary(x => x.{{^netStandard}}Name{{/netStandard}}{{#netStandard}}Key{{/netStandard}}, x => string.Join(",", x.Value){{#caseInsensitiveResponseHeaders}}, StringComparer.OrdinalIgnoreCase{{/caseInsensitiveResponseHeaders}}),
|
|
||||||
null);
|
|
||||||
{{/returnType}}
|
|
||||||
}
|
|
||||||
|
|
||||||
{{/supportsAsync}}
|
|
||||||
{{/operation}}
|
|
||||||
}
|
|
||||||
{{/operations}}
|
|
||||||
}
|
|
@ -1,131 +0,0 @@
|
|||||||
# {{packageName}}.{{apiPackage}}.{{classname}}{{#description}}
|
|
||||||
|
|
||||||
{{.}}{{/description}}
|
|
||||||
|
|
||||||
All URIs are relative to *{{{basePath}}}*
|
|
||||||
|
|
||||||
Method | HTTP request | Description
|
|
||||||
------------- | ------------- | -------------
|
|
||||||
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{summary}}
|
|
||||||
{{/operation}}{{/operations}}
|
|
||||||
|
|
||||||
{{#operations}}
|
|
||||||
{{#operation}}
|
|
||||||
|
|
||||||
## {{{operationId}}}
|
|
||||||
|
|
||||||
> {{returnType}}{{^returnType}}void{{/returnType}} {{operationId}} ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}})
|
|
||||||
|
|
||||||
{{{summary}}}{{#notes}}
|
|
||||||
|
|
||||||
{{{.}}}{{/notes}}
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using {{packageName}}.{{apiPackage}};
|
|
||||||
using {{packageName}}.Client;
|
|
||||||
using {{packageName}}.{{modelPackage}};
|
|
||||||
|
|
||||||
namespace Example
|
|
||||||
{
|
|
||||||
public class {{operationId}}Example
|
|
||||||
{
|
|
||||||
public static void Main()
|
|
||||||
{
|
|
||||||
Configuration.Default.BasePath = "{{{basePath}}}";
|
|
||||||
{{#hasAuthMethods}}
|
|
||||||
{{#authMethods}}
|
|
||||||
{{#isBasic}}
|
|
||||||
{{#isBasicBasic}}
|
|
||||||
// Configure HTTP basic authorization: {{{name}}}
|
|
||||||
Configuration.Default.Username = "YOUR_USERNAME";
|
|
||||||
Configuration.Default.Password = "YOUR_PASSWORD";
|
|
||||||
{{/isBasicBasic}}
|
|
||||||
{{#isBasicBearer}}
|
|
||||||
// Configure HTTP bearer authorization: {{{name}}}
|
|
||||||
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
|
|
||||||
{{/isBasicBearer}}
|
|
||||||
{{/isBasic}}
|
|
||||||
{{#isApiKey}}
|
|
||||||
// Configure API key authorization: {{{name}}}
|
|
||||||
Configuration.Default.AddApiKey("{{{keyParamName}}}", "YOUR_API_KEY");
|
|
||||||
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
|
||||||
// Configuration.Default.AddApiKeyPrefix("{{{keyParamName}}}", "Bearer");
|
|
||||||
{{/isApiKey}}
|
|
||||||
{{#isOAuth}}
|
|
||||||
// Configure OAuth2 access token for authorization: {{{name}}}
|
|
||||||
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
|
|
||||||
{{/isOAuth}}
|
|
||||||
{{/authMethods}}
|
|
||||||
|
|
||||||
{{/hasAuthMethods}}
|
|
||||||
var apiInstance = new {{classname}}(Configuration.Default);
|
|
||||||
{{#allParams}}
|
|
||||||
{{#isPrimitiveType}}
|
|
||||||
var {{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
{{^isPrimitiveType}}
|
|
||||||
var {{paramName}} = new {{{dataType}}}(); // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
|
||||||
{{/isPrimitiveType}}
|
|
||||||
{{/allParams}}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
{{#summary}}
|
|
||||||
// {{{.}}}
|
|
||||||
{{/summary}}
|
|
||||||
{{#returnType}}{{{.}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}}
|
|
||||||
Debug.WriteLine(result);{{/returnType}}
|
|
||||||
}
|
|
||||||
catch (ApiException e)
|
|
||||||
{
|
|
||||||
Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message );
|
|
||||||
Debug.Print("Status Code: "+ e.ErrorCode);
|
|
||||||
Debug.Print(e.StackTrace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Parameters
|
|
||||||
|
|
||||||
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
|
|
||||||
{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{#isContainer}}{{baseType}}{{/isContainer}}{{^isContainer}}{{dataType}}{{/isContainer}}.md){{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{.}}]{{/defaultValue}}
|
|
||||||
{{/allParams}}
|
|
||||||
|
|
||||||
### Return type
|
|
||||||
|
|
||||||
{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}}
|
|
||||||
|
|
||||||
### Authorization
|
|
||||||
|
|
||||||
{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}}
|
|
||||||
|
|
||||||
### HTTP request headers
|
|
||||||
|
|
||||||
- **Content-Type**: {{#consumes}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
|
|
||||||
- **Accept**: {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}}
|
|
||||||
|
|
||||||
{{#responses.0}}
|
|
||||||
|
|
||||||
### HTTP response details
|
|
||||||
| Status code | Description | Response headers |
|
|
||||||
|-------------|-------------|------------------|
|
|
||||||
{{#responses}}
|
|
||||||
| **{{code}}** | {{message}} | {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} |
|
|
||||||
{{/responses}}
|
|
||||||
{{/responses.0}}
|
|
||||||
|
|
||||||
[[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)
|
|
||||||
|
|
||||||
{{/operation}}
|
|
||||||
{{/operations}}
|
|
@ -1,74 +0,0 @@
|
|||||||
{{>partial_header}}
|
|
||||||
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 {{packageName}}.Client;
|
|
||||||
using {{packageName}}.{{apiPackage}};
|
|
||||||
{{#hasImport}}using {{packageName}}.{{modelPackage}};
|
|
||||||
{{/hasImport}}
|
|
||||||
|
|
||||||
namespace {{packageName}}.Test
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Class for testing {{classname}}
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
/// Please update the test case below to test the API endpoint.
|
|
||||||
/// </remarks>
|
|
||||||
public class {{classname}}Tests
|
|
||||||
{
|
|
||||||
private {{classname}} instance;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Setup before each unit test
|
|
||||||
/// </summary>
|
|
||||||
[SetUp]
|
|
||||||
public void Init()
|
|
||||||
{
|
|
||||||
instance = new {{classname}}();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up after each unit test
|
|
||||||
/// </summary>
|
|
||||||
[TearDown]
|
|
||||||
public void Cleanup()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Test an instance of {{classname}}
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void {{operationId}}InstanceTest()
|
|
||||||
{
|
|
||||||
// TODO uncomment below to test 'IsInstanceOf' {{classname}}
|
|
||||||
//Assert.IsInstanceOf(typeof({{classname}}), instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
{{#operations}}{{#operation}}
|
|
||||||
/// <summary>
|
|
||||||
/// Test {{operationId}}
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void {{operationId}}Test()
|
|
||||||
{
|
|
||||||
// TODO uncomment below to test the method and replace null with proper value
|
|
||||||
{{#allParams}}
|
|
||||||
//{{{dataType}}} {{paramName}} = null;
|
|
||||||
{{/allParams}}
|
|
||||||
//{{#returnType}}var response = {{/returnType}}instance.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
|
|
||||||
{{#returnType}}//Assert.IsInstanceOf(typeof({{{returnType}}}), response, "response is {{{returnType}}}");{{/returnType}}
|
|
||||||
}
|
|
||||||
{{/operation}}{{/operations}}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# Generated by: https://github.com/openapitools/openapi-generator.git
|
|
||||||
#
|
|
||||||
|
|
||||||
frameworkVersion={{targetFrameworkNuget}}
|
|
||||||
|
|
||||||
# sdk must match installed frameworks under PREFIX/lib/mono/[value]
|
|
||||||
sdk={{x-mcs-sdk}}
|
|
||||||
|
|
||||||
# langversion refers to C# language features. see man mcs for details.
|
|
||||||
langversion=${sdk}
|
|
||||||
nuget_cmd=nuget
|
|
||||||
|
|
||||||
# Match against our known SDK possibilities
|
|
||||||
case "${sdk}" in
|
|
||||||
4)
|
|
||||||
langversion=4
|
|
||||||
;;
|
|
||||||
4.5*)
|
|
||||||
langversion=5
|
|
||||||
;;
|
|
||||||
4.6*)
|
|
||||||
langversion=6
|
|
||||||
;;
|
|
||||||
4.7*)
|
|
||||||
langversion=7 # ignoring 7.1 for now.
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
langversion=6
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "[INFO] Target framework: ${frameworkVersion}"
|
|
||||||
|
|
||||||
if ! type nuget &>/dev/null; then
|
|
||||||
echo "[INFO] Download nuget and packages"
|
|
||||||
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe;
|
|
||||||
nuget_cmd="mono nuget.exe"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mozroots --import --sync
|
|
||||||
${nuget_cmd} install src/{{packageName}}/packages.config -o packages;
|
|
||||||
|
|
||||||
echo "[INFO] Copy DLLs to the 'bin' folder"
|
|
||||||
mkdir -p bin;
|
|
||||||
cp packages/Newtonsoft.Json.{{newtonsoft-json.version}}/lib/{{newtonsoft-json.targetFramework}}/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll;
|
|
||||||
cp packages/RestSharp.{{restsharp.version}}/lib/{{restsharp.targetFramework}}/RestSharp.dll bin/RestSharp.dll;
|
|
||||||
cp packages/JsonSubTypes.{{json-subtypes.version}}/lib/{{json-subtypes.targetFramework}}/JsonSubTypes.dll bin/JsonSubTypes.dll
|
|
||||||
{{#generatePropertyChanged}}
|
|
||||||
cp packages/Fody.{{fody.version}}/Fody.dll bin/Fody.dll
|
|
||||||
cp packages/PropertyChanged.Fody.{{propertychanged-fody.version}}/PropertyChanged.Fody.dll bin/PropertyChanged.Fody.dll
|
|
||||||
cp packages/PropertyChanged.Fody.{{propertychanged-fody.version}}/Lib/dotnet/PropertyChanged.dll bin/PropertyChanged.dll
|
|
||||||
{{/generatePropertyChanged}}
|
|
||||||
|
|
||||||
echo "[INFO] Run 'mcs' to build bin/{{{packageName}}}.dll"
|
|
||||||
mcs -langversion:${langversion} -sdk:${sdk} -r:bin/Newtonsoft.Json.dll,bin/JsonSubTypes.dll,\
|
|
||||||
{{#generatePropertyChanged}}
|
|
||||||
bin/Fody.dll,\
|
|
||||||
bin/PropertyChanged.Fody.dll,\
|
|
||||||
bin/PropertyChanged.dll,\
|
|
||||||
{{/generatePropertyChanged}}
|
|
||||||
bin/RestSharp.dll,\
|
|
||||||
System.ComponentModel.DataAnnotations.dll,\
|
|
||||||
System.Runtime.Serialization.dll \
|
|
||||||
-target:library \
|
|
||||||
-out:bin/{{packageName}}.dll \
|
|
||||||
-recurse:'src/{{packageName}}/*.cs' \
|
|
||||||
-doc:bin/{{packageName}}.xml \
|
|
||||||
-platform:anycpu
|
|
||||||
|
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
|
||||||
echo "[ERROR] Compilation failed with exit code $?"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "[INFO] bin/{{{packageName}}}.dll was created successfully"
|
|
||||||
fi
|
|
@ -1,26 +0,0 @@
|
|||||||
:: Generated by: https://github.com/openapitools/openapi-generator.git
|
|
||||||
::
|
|
||||||
|
|
||||||
@echo off
|
|
||||||
|
|
||||||
{{#supportsAsync}}
|
|
||||||
SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319
|
|
||||||
{{/supportsAsync}}
|
|
||||||
{{^supportsAsync}}
|
|
||||||
SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v3.5
|
|
||||||
{{/supportsAsync}}
|
|
||||||
|
|
||||||
if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', '.\nuget.exe')"
|
|
||||||
.\nuget.exe install src\{{packageName}}\packages.config -o packages
|
|
||||||
|
|
||||||
if not exist ".\bin" mkdir bin
|
|
||||||
|
|
||||||
copy packages\Newtonsoft.Json.{{newtonsoft-json.version}}\lib\{{newtonsoft-json.targetFramework}}\Newtonsoft.Json.dll bin\Newtonsoft.Json.dll
|
|
||||||
copy packages\JsonSubTypes.{{json-subtypes.version}}\lib\{{json-subtypes.targetFramework}}\JsonSubTypes.dll bin\JsonSubTypes.dll
|
|
||||||
copy packages\RestSharp.{{restsharp.version}}\lib\{{restsharp.targetFramework}}\RestSharp.dll bin\RestSharp.dll
|
|
||||||
{{#generatePropertyChanged}}
|
|
||||||
copy packages\Fody.{{fody.version}}\Fody.dll bin\Fody.dll
|
|
||||||
copy packages\PropertyChanged.Fody.{{propertychanged-fody.version}}\PropertyChanged.Fody.dll bin\PropertyChanged.Fody.dll
|
|
||||||
copy packages\PropertyChanged.Fody.{{propertychanged-fody.version}}\Lib\dotnet\PropertyChanged.dll bin\PropertyChanged.dll
|
|
||||||
{{/generatePropertyChanged}}
|
|
||||||
%CSCPATH%\csc /reference:bin\Newtonsoft.Json.dll;bin\JsonSubTypes.dll;bin\RestSharp.dll;System.ComponentModel.DataAnnotations.dll {{#generatePropertyChanged}}/r:bin\Fody.dll;bin\PropertyChanged.Fody.dll;bin\PropertyChanged.dll{{/generatePropertyChanged}} /target:library /out:bin\{{packageName}}.dll /recurse:src\{{packageName}}\*.cs /doc:bin\{{packageName}}.xml
|
|
@ -1,22 +0,0 @@
|
|||||||
/// <summary>
|
|
||||||
/// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
|
||||||
/// </summary>
|
|
||||||
{{#description}}
|
|
||||||
/// <value>{{.}}</value>
|
|
||||||
{{/description}}
|
|
||||||
{{^useGenericHost}}
|
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
|
||||||
{{/useGenericHost}}
|
|
||||||
{{>visibility}} enum {{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}
|
|
||||||
{
|
|
||||||
{{#allowableValues}}
|
|
||||||
{{#enumVars}}
|
|
||||||
/// <summary>
|
|
||||||
/// Enum {{name}} for {{{value}}}
|
|
||||||
/// </summary>
|
|
||||||
[EnumMember(Value = {{#isLong}}"{{/isLong}}{{#isInteger}}"{{/isInteger}}{{#isFloat}}"{{/isFloat}}{{#isDouble}}"{{/isDouble}}{{{value}}}{{#isLong}}"{{/isLong}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isFloat}}"{{/isFloat}})]
|
|
||||||
{{name}}{{#isLong}} = {{{value}}}{{/isLong}}{{#isInteger}} = {{{value}}}{{/isInteger}}{{^isInteger}} = {{-index}}{{/isInteger}}{{^-last}},{{/-last}}
|
|
||||||
|
|
||||||
{{/enumVars}}
|
|
||||||
{{/allowableValues}}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
|
||||||
#
|
|
||||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
|
||||||
|
|
||||||
git_user_id=$1
|
|
||||||
git_repo_id=$2
|
|
||||||
release_note=$3
|
|
||||||
git_host=$4
|
|
||||||
|
|
||||||
if [ "$git_host" = "" ]; then
|
|
||||||
git_host="{{{gitHost}}}"
|
|
||||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$git_user_id" = "" ]; then
|
|
||||||
git_user_id="{{{gitUserId}}}"
|
|
||||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$git_repo_id" = "" ]; then
|
|
||||||
git_repo_id="{{{gitRepoId}}}"
|
|
||||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$release_note" = "" ]; then
|
|
||||||
release_note="{{{releaseNote}}}"
|
|
||||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Initialize the local directory as a Git repository
|
|
||||||
git init
|
|
||||||
|
|
||||||
# Adds the files in the local repository and stages them for commit.
|
|
||||||
git add .
|
|
||||||
|
|
||||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
|
||||||
git commit -m "$release_note"
|
|
||||||
|
|
||||||
# Sets the new remote
|
|
||||||
git_remote=$(git remote)
|
|
||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
|
||||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
|
||||||
else
|
|
||||||
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
git pull origin master
|
|
||||||
|
|
||||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
|
||||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
|
||||||
git push origin master 2>&1 | grep -v 'To https'
|
|
@ -1,362 +0,0 @@
|
|||||||
## Ignore Visual Studio temporary files, build results, and
|
|
||||||
## files generated by popular Visual Studio add-ons.
|
|
||||||
##
|
|
||||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
|
||||||
|
|
||||||
# User-specific files
|
|
||||||
*.rsuser
|
|
||||||
*.suo
|
|
||||||
*.user
|
|
||||||
*.userosscache
|
|
||||||
*.sln.docstates
|
|
||||||
|
|
||||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
|
||||||
*.userprefs
|
|
||||||
|
|
||||||
# Mono auto generated files
|
|
||||||
mono_crash.*
|
|
||||||
|
|
||||||
# Build results
|
|
||||||
[Dd]ebug/
|
|
||||||
[Dd]ebugPublic/
|
|
||||||
[Rr]elease/
|
|
||||||
[Rr]eleases/
|
|
||||||
x64/
|
|
||||||
x86/
|
|
||||||
[Ww][Ii][Nn]32/
|
|
||||||
[Aa][Rr][Mm]/
|
|
||||||
[Aa][Rr][Mm]64/
|
|
||||||
bld/
|
|
||||||
[Bb]in/
|
|
||||||
[Oo]bj/
|
|
||||||
[Ll]og/
|
|
||||||
[Ll]ogs/
|
|
||||||
|
|
||||||
# Visual Studio 2015/2017 cache/options directory
|
|
||||||
.vs/
|
|
||||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
|
||||||
#wwwroot/
|
|
||||||
|
|
||||||
# Visual Studio 2017 auto generated files
|
|
||||||
Generated\ Files/
|
|
||||||
|
|
||||||
# MSTest test Results
|
|
||||||
[Tt]est[Rr]esult*/
|
|
||||||
[Bb]uild[Ll]og.*
|
|
||||||
|
|
||||||
# NUnit
|
|
||||||
*.VisualState.xml
|
|
||||||
TestResult.xml
|
|
||||||
nunit-*.xml
|
|
||||||
|
|
||||||
# Build Results of an ATL Project
|
|
||||||
[Dd]ebugPS/
|
|
||||||
[Rr]eleasePS/
|
|
||||||
dlldata.c
|
|
||||||
|
|
||||||
# Benchmark Results
|
|
||||||
BenchmarkDotNet.Artifacts/
|
|
||||||
|
|
||||||
# .NET Core
|
|
||||||
project.lock.json
|
|
||||||
project.fragment.lock.json
|
|
||||||
artifacts/
|
|
||||||
|
|
||||||
# ASP.NET Scaffolding
|
|
||||||
ScaffoldingReadMe.txt
|
|
||||||
|
|
||||||
# StyleCop
|
|
||||||
StyleCopReport.xml
|
|
||||||
|
|
||||||
# Files built by Visual Studio
|
|
||||||
*_i.c
|
|
||||||
*_p.c
|
|
||||||
*_h.h
|
|
||||||
*.ilk
|
|
||||||
*.meta
|
|
||||||
*.obj
|
|
||||||
*.iobj
|
|
||||||
*.pch
|
|
||||||
*.pdb
|
|
||||||
*.ipdb
|
|
||||||
*.pgc
|
|
||||||
*.pgd
|
|
||||||
*.rsp
|
|
||||||
*.sbr
|
|
||||||
*.tlb
|
|
||||||
*.tli
|
|
||||||
*.tlh
|
|
||||||
*.tmp
|
|
||||||
*.tmp_proj
|
|
||||||
*_wpftmp.csproj
|
|
||||||
*.log
|
|
||||||
*.vspscc
|
|
||||||
*.vssscc
|
|
||||||
.builds
|
|
||||||
*.pidb
|
|
||||||
*.svclog
|
|
||||||
*.scc
|
|
||||||
|
|
||||||
# Chutzpah Test files
|
|
||||||
_Chutzpah*
|
|
||||||
|
|
||||||
# Visual C++ cache files
|
|
||||||
ipch/
|
|
||||||
*.aps
|
|
||||||
*.ncb
|
|
||||||
*.opendb
|
|
||||||
*.opensdf
|
|
||||||
*.sdf
|
|
||||||
*.cachefile
|
|
||||||
*.VC.db
|
|
||||||
*.VC.VC.opendb
|
|
||||||
|
|
||||||
# Visual Studio profiler
|
|
||||||
*.psess
|
|
||||||
*.vsp
|
|
||||||
*.vspx
|
|
||||||
*.sap
|
|
||||||
|
|
||||||
# Visual Studio Trace Files
|
|
||||||
*.e2e
|
|
||||||
|
|
||||||
# TFS 2012 Local Workspace
|
|
||||||
$tf/
|
|
||||||
|
|
||||||
# Guidance Automation Toolkit
|
|
||||||
*.gpState
|
|
||||||
|
|
||||||
# ReSharper is a .NET coding add-in
|
|
||||||
_ReSharper*/
|
|
||||||
*.[Rr]e[Ss]harper
|
|
||||||
*.DotSettings.user
|
|
||||||
|
|
||||||
# TeamCity is a build add-in
|
|
||||||
_TeamCity*
|
|
||||||
|
|
||||||
# DotCover is a Code Coverage Tool
|
|
||||||
*.dotCover
|
|
||||||
|
|
||||||
# AxoCover is a Code Coverage Tool
|
|
||||||
.axoCover/*
|
|
||||||
!.axoCover/settings.json
|
|
||||||
|
|
||||||
# Coverlet is a free, cross platform Code Coverage Tool
|
|
||||||
coverage*.json
|
|
||||||
coverage*.xml
|
|
||||||
coverage*.info
|
|
||||||
|
|
||||||
# Visual Studio code coverage results
|
|
||||||
*.coverage
|
|
||||||
*.coveragexml
|
|
||||||
|
|
||||||
# NCrunch
|
|
||||||
_NCrunch_*
|
|
||||||
.*crunch*.local.xml
|
|
||||||
nCrunchTemp_*
|
|
||||||
|
|
||||||
# MightyMoose
|
|
||||||
*.mm.*
|
|
||||||
AutoTest.Net/
|
|
||||||
|
|
||||||
# Web workbench (sass)
|
|
||||||
.sass-cache/
|
|
||||||
|
|
||||||
# Installshield output folder
|
|
||||||
[Ee]xpress/
|
|
||||||
|
|
||||||
# DocProject is a documentation generator add-in
|
|
||||||
DocProject/buildhelp/
|
|
||||||
DocProject/Help/*.HxT
|
|
||||||
DocProject/Help/*.HxC
|
|
||||||
DocProject/Help/*.hhc
|
|
||||||
DocProject/Help/*.hhk
|
|
||||||
DocProject/Help/*.hhp
|
|
||||||
DocProject/Help/Html2
|
|
||||||
DocProject/Help/html
|
|
||||||
|
|
||||||
# Click-Once directory
|
|
||||||
publish/
|
|
||||||
|
|
||||||
# Publish Web Output
|
|
||||||
*.[Pp]ublish.xml
|
|
||||||
*.azurePubxml
|
|
||||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
|
||||||
# but database connection strings (with potential passwords) will be unencrypted
|
|
||||||
*.pubxml
|
|
||||||
*.publishproj
|
|
||||||
|
|
||||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
|
||||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
|
||||||
# in these scripts will be unencrypted
|
|
||||||
PublishScripts/
|
|
||||||
|
|
||||||
# NuGet Packages
|
|
||||||
*.nupkg
|
|
||||||
# NuGet Symbol Packages
|
|
||||||
*.snupkg
|
|
||||||
# The packages folder can be ignored because of Package Restore
|
|
||||||
**/[Pp]ackages/*
|
|
||||||
# except build/, which is used as an MSBuild target.
|
|
||||||
!**/[Pp]ackages/build/
|
|
||||||
# Uncomment if necessary however generally it will be regenerated when needed
|
|
||||||
#!**/[Pp]ackages/repositories.config
|
|
||||||
# NuGet v3's project.json files produces more ignorable files
|
|
||||||
*.nuget.props
|
|
||||||
*.nuget.targets
|
|
||||||
|
|
||||||
# Microsoft Azure Build Output
|
|
||||||
csx/
|
|
||||||
*.build.csdef
|
|
||||||
|
|
||||||
# Microsoft Azure Emulator
|
|
||||||
ecf/
|
|
||||||
rcf/
|
|
||||||
|
|
||||||
# Windows Store app package directories and files
|
|
||||||
AppPackages/
|
|
||||||
BundleArtifacts/
|
|
||||||
Package.StoreAssociation.xml
|
|
||||||
_pkginfo.txt
|
|
||||||
*.appx
|
|
||||||
*.appxbundle
|
|
||||||
*.appxupload
|
|
||||||
|
|
||||||
# Visual Studio cache files
|
|
||||||
# files ending in .cache can be ignored
|
|
||||||
*.[Cc]ache
|
|
||||||
# but keep track of directories ending in .cache
|
|
||||||
!?*.[Cc]ache/
|
|
||||||
|
|
||||||
# Others
|
|
||||||
ClientBin/
|
|
||||||
~$*
|
|
||||||
*~
|
|
||||||
*.dbmdl
|
|
||||||
*.dbproj.schemaview
|
|
||||||
*.jfm
|
|
||||||
*.pfx
|
|
||||||
*.publishsettings
|
|
||||||
orleans.codegen.cs
|
|
||||||
|
|
||||||
# Including strong name files can present a security risk
|
|
||||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
|
||||||
#*.snk
|
|
||||||
|
|
||||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
|
||||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
|
||||||
#bower_components/
|
|
||||||
|
|
||||||
# RIA/Silverlight projects
|
|
||||||
Generated_Code/
|
|
||||||
|
|
||||||
# Backup & report files from converting an old project file
|
|
||||||
# to a newer Visual Studio version. Backup files are not needed,
|
|
||||||
# because we have git ;-)
|
|
||||||
_UpgradeReport_Files/
|
|
||||||
Backup*/
|
|
||||||
UpgradeLog*.XML
|
|
||||||
UpgradeLog*.htm
|
|
||||||
ServiceFabricBackup/
|
|
||||||
*.rptproj.bak
|
|
||||||
|
|
||||||
# SQL Server files
|
|
||||||
*.mdf
|
|
||||||
*.ldf
|
|
||||||
*.ndf
|
|
||||||
|
|
||||||
# Business Intelligence projects
|
|
||||||
*.rdl.data
|
|
||||||
*.bim.layout
|
|
||||||
*.bim_*.settings
|
|
||||||
*.rptproj.rsuser
|
|
||||||
*- [Bb]ackup.rdl
|
|
||||||
*- [Bb]ackup ([0-9]).rdl
|
|
||||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
|
||||||
|
|
||||||
# Microsoft Fakes
|
|
||||||
FakesAssemblies/
|
|
||||||
|
|
||||||
# GhostDoc plugin setting file
|
|
||||||
*.GhostDoc.xml
|
|
||||||
|
|
||||||
# Node.js Tools for Visual Studio
|
|
||||||
.ntvs_analysis.dat
|
|
||||||
node_modules/
|
|
||||||
|
|
||||||
# Visual Studio 6 build log
|
|
||||||
*.plg
|
|
||||||
|
|
||||||
# Visual Studio 6 workspace options file
|
|
||||||
*.opt
|
|
||||||
|
|
||||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
|
||||||
*.vbw
|
|
||||||
|
|
||||||
# Visual Studio LightSwitch build output
|
|
||||||
**/*.HTMLClient/GeneratedArtifacts
|
|
||||||
**/*.DesktopClient/GeneratedArtifacts
|
|
||||||
**/*.DesktopClient/ModelManifest.xml
|
|
||||||
**/*.Server/GeneratedArtifacts
|
|
||||||
**/*.Server/ModelManifest.xml
|
|
||||||
_Pvt_Extensions
|
|
||||||
|
|
||||||
# Paket dependency manager
|
|
||||||
.paket/paket.exe
|
|
||||||
paket-files/
|
|
||||||
|
|
||||||
# FAKE - F# Make
|
|
||||||
.fake/
|
|
||||||
|
|
||||||
# CodeRush personal settings
|
|
||||||
.cr/personal
|
|
||||||
|
|
||||||
# Python Tools for Visual Studio (PTVS)
|
|
||||||
__pycache__/
|
|
||||||
*.pyc
|
|
||||||
|
|
||||||
# Cake - Uncomment if you are using it
|
|
||||||
# tools/**
|
|
||||||
# !tools/packages.config
|
|
||||||
|
|
||||||
# Tabs Studio
|
|
||||||
*.tss
|
|
||||||
|
|
||||||
# Telerik's JustMock configuration file
|
|
||||||
*.jmconfig
|
|
||||||
|
|
||||||
# BizTalk build output
|
|
||||||
*.btp.cs
|
|
||||||
*.btm.cs
|
|
||||||
*.odx.cs
|
|
||||||
*.xsd.cs
|
|
||||||
|
|
||||||
# OpenCover UI analysis results
|
|
||||||
OpenCover/
|
|
||||||
|
|
||||||
# Azure Stream Analytics local run output
|
|
||||||
ASALocalRun/
|
|
||||||
|
|
||||||
# MSBuild Binary and Structured Log
|
|
||||||
*.binlog
|
|
||||||
|
|
||||||
# NVidia Nsight GPU debugger configuration file
|
|
||||||
*.nvuser
|
|
||||||
|
|
||||||
# MFractors (Xamarin productivity tool) working folder
|
|
||||||
.mfractor/
|
|
||||||
|
|
||||||
# Local History for Visual Studio
|
|
||||||
.localhistory/
|
|
||||||
|
|
||||||
# BeatPulse healthcheck temp database
|
|
||||||
healthchecksdb
|
|
||||||
|
|
||||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
|
||||||
MigrationBackup/
|
|
||||||
|
|
||||||
# Ionide (cross platform F# VS Code tools) working folder
|
|
||||||
.ionide/
|
|
||||||
|
|
||||||
# Fody - auto-generated XML schema
|
|
||||||
FodyWeavers.xsd
|
|
@ -1,38 +0,0 @@
|
|||||||
{{>partial_header}}
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
{{^netStandard}}
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
{{/netStandard}}
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Converters;
|
|
||||||
{{#models}}
|
|
||||||
{{#model}}
|
|
||||||
{{#discriminator}}
|
|
||||||
using JsonSubTypes;
|
|
||||||
{{/discriminator}}
|
|
||||||
{{/model}}
|
|
||||||
{{/models}}
|
|
||||||
{{^netStandard}}
|
|
||||||
{{#generatePropertyChanged}}
|
|
||||||
using PropertyChanged;
|
|
||||||
using System.ComponentModel;
|
|
||||||
{{/generatePropertyChanged}}
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
{{/netStandard}}
|
|
||||||
using OpenAPIDateConverter = {{packageName}}.Client.OpenAPIDateConverter;
|
|
||||||
|
|
||||||
{{#models}}
|
|
||||||
{{#model}}
|
|
||||||
namespace {{packageName}}.{{modelPackage}}
|
|
||||||
{
|
|
||||||
{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}}{{/isEnum}}
|
|
||||||
{{/model}}
|
|
||||||
{{/models}}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
/// <summary>
|
|
||||||
/// {{description}}{{^description}}Defines {{{name}}}{{/description}}
|
|
||||||
/// </summary>
|
|
||||||
{{#description}}
|
|
||||||
/// <value>{{.}}</value>
|
|
||||||
{{/description}}
|
|
||||||
{{#allowableValues}}{{#enumVars}}{{#-first}}{{#isString}}{{^useGenericHost}}
|
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
|
||||||
{{/useGenericHost}}{{/isString}}{{/-first}}{{/enumVars}}{{/allowableValues}}
|
|
||||||
{{>visibility}} enum {{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}{{#vendorExtensions.x-enum-byte}}: byte{{/vendorExtensions.x-enum-byte}}
|
|
||||||
{
|
|
||||||
{{#allowableValues}}
|
|
||||||
{{#enumVars}}
|
|
||||||
/// <summary>
|
|
||||||
/// Enum {{name}} for value: {{{value}}}
|
|
||||||
/// </summary>
|
|
||||||
{{#isString}}
|
|
||||||
[EnumMember(Value = "{{{value}}}")]
|
|
||||||
{{/isString}}
|
|
||||||
{{name}}{{^isString}} = {{{value}}}{{/isString}}{{#isString}} = {{-index}}{{/isString}}{{^-last}},{{/-last}}
|
|
||||||
|
|
||||||
{{/enumVars}}
|
|
||||||
{{/allowableValues}}
|
|
||||||
}{{! NOTE: This model's enumVars is modified to look like CodegenProperty}}
|
|
@ -1,339 +0,0 @@
|
|||||||
/// <summary>
|
|
||||||
/// {{description}}{{^description}}{{classname}}{{/description}}
|
|
||||||
/// </summary>
|
|
||||||
[DataContract]
|
|
||||||
{{#discriminator}}
|
|
||||||
[JsonConverter(typeof(JsonSubtypes), "{{#lambda.camelcase_param}}{{{discriminatorName}}}{{/lambda.camelcase_param}}")]{{#children}}
|
|
||||||
[JsonSubtypes.KnownSubType(typeof({{classname}}), "{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}")]{{/children}}
|
|
||||||
{{/discriminator}}
|
|
||||||
{{#generatePropertyChanged}}
|
|
||||||
[ImplementPropertyChanged]
|
|
||||||
{{/generatePropertyChanged}}
|
|
||||||
{{>visibility}} partial class {{classname}} : {{#parent}}{{{.}}}, {{/parent}} IEquatable<{{classname}}>{{^netStandard}}{{#validatable}}, IValidatableObject{{/validatable}}{{/netStandard}}
|
|
||||||
{
|
|
||||||
{{#vars}}
|
|
||||||
{{#items.isEnum}}
|
|
||||||
{{#items}}
|
|
||||||
{{^complexType}}
|
|
||||||
{{>modelInnerEnum}}
|
|
||||||
{{/complexType}}
|
|
||||||
{{/items}}
|
|
||||||
{{/items.isEnum}}
|
|
||||||
{{#isEnum}}
|
|
||||||
{{^complexType}}
|
|
||||||
{{>modelInnerEnum}}
|
|
||||||
{{/complexType}}
|
|
||||||
{{/isEnum}}
|
|
||||||
{{#isEnum}}
|
|
||||||
/// <summary>
|
|
||||||
/// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
|
||||||
/// </summary>
|
|
||||||
{{#description}}
|
|
||||||
/// <value>{{.}}</value>
|
|
||||||
{{/description}}
|
|
||||||
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#vendorExtensions.x-emit-default-value}}true{{/vendorExtensions.x-emit-default-value}}{{^vendorExtensions.x-emit-default-value}}{{#isNullable}}true{{/isNullable}}{{^isNullable}}{{#required}}true{{/required}}{{^required}}false{{/required}}{{/isNullable}}{{/vendorExtensions.x-emit-default-value}})]
|
|
||||||
{{#deprecated}}
|
|
||||||
[Obsolete]
|
|
||||||
{{/deprecated}}
|
|
||||||
public {{{complexType}}}{{^complexType}}{{{datatypeWithEnum}}}{{/complexType}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}} {{name}} { get; set; }
|
|
||||||
{{/isEnum}}
|
|
||||||
{{/vars}}
|
|
||||||
{{#hasRequired}}
|
|
||||||
{{^hasOnlyReadOnly}}
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="{{classname}}" /> class.
|
|
||||||
/// </summary>
|
|
||||||
[JsonConstructorAttribute]
|
|
||||||
protected {{classname}}() { }
|
|
||||||
{{/hasOnlyReadOnly}}
|
|
||||||
{{/hasRequired}}
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="{{classname}}" /> class.
|
|
||||||
/// </summary>
|
|
||||||
{{#vars}}
|
|
||||||
{{^isReadOnly}}
|
|
||||||
/// <param name="{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}">{{description}}{{^description}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{/description}}{{#required}} (required){{/required}}{{#defaultValue}} (default to {{.}}){{/defaultValue}}.</param>
|
|
||||||
{{/isReadOnly}}
|
|
||||||
{{/vars}}
|
|
||||||
{{#hasOnlyReadOnly}}
|
|
||||||
[JsonConstructorAttribute]
|
|
||||||
{{/hasOnlyReadOnly}}
|
|
||||||
public {{classname}}({{#readWriteVars}}{{{datatypeWithEnum}}}{{#isEnum}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}}{{/isEnum}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{{defaultValue}}}{{^defaultValue}}default({{{datatypeWithEnum}}}{{#isEnum}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}}{{/isEnum}}){{/defaultValue}}{{^-last}}, {{/-last}}{{/readWriteVars}}){{#parent}} : base({{#parentVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{^-last}}, {{/-last}}{{/parentVars}}){{/parent}}
|
|
||||||
{
|
|
||||||
{{#vars}}
|
|
||||||
{{^isInherited}}
|
|
||||||
{{^isReadOnly}}
|
|
||||||
{{#required}}
|
|
||||||
// to ensure "{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}" is required (not null)
|
|
||||||
if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} == null)
|
|
||||||
{
|
|
||||||
throw new InvalidDataException("{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} is a required property for {{classname}} and cannot be null");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
|
||||||
}
|
|
||||||
|
|
||||||
{{/required}}
|
|
||||||
{{#isNullable}}
|
|
||||||
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
|
||||||
{{/isNullable}}
|
|
||||||
{{/isReadOnly}}
|
|
||||||
{{/isInherited}}
|
|
||||||
{{/vars}}
|
|
||||||
{{#vars}}
|
|
||||||
{{^isInherited}}
|
|
||||||
{{^isReadOnly}}
|
|
||||||
{{^required}}
|
|
||||||
{{#defaultValue}}// use default value if no "{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}" provided
|
|
||||||
if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} == null)
|
|
||||||
{
|
|
||||||
this.{{name}} = {{{defaultValue}}};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
|
||||||
}
|
|
||||||
{{/defaultValue}}
|
|
||||||
{{^defaultValue}}
|
|
||||||
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
|
||||||
{{/defaultValue}}
|
|
||||||
{{/required}}
|
|
||||||
{{/isReadOnly}}
|
|
||||||
{{/isInherited}}
|
|
||||||
{{/vars}}
|
|
||||||
}
|
|
||||||
|
|
||||||
{{#vars}}
|
|
||||||
{{^isInherited}}
|
|
||||||
{{^isEnum}}
|
|
||||||
/// <summary>
|
|
||||||
/// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
|
||||||
/// </summary>{{#description}}
|
|
||||||
/// <value>{{.}}</value>{{/description}}
|
|
||||||
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#vendorExtensions.x-emit-default-value}}true{{/vendorExtensions.x-emit-default-value}}{{^vendorExtensions.x-emit-default-value}}{{#isNullable}}true{{/isNullable}}{{^isNullable}}{{#required}}true{{/required}}{{^required}}false{{/required}}{{/isNullable}}{{/vendorExtensions.x-emit-default-value}})]{{#isDate}}
|
|
||||||
[JsonConverter(typeof(OpenAPIDateConverter))]{{/isDate}}
|
|
||||||
{{#deprecated}}
|
|
||||||
[Obsolete]
|
|
||||||
{{/deprecated}}
|
|
||||||
public {{{dataType}}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; }
|
|
||||||
{{/isEnum}}
|
|
||||||
{{/isInherited}}
|
|
||||||
|
|
||||||
{{/vars}}
|
|
||||||
/// <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 {{classname}} {\n");
|
|
||||||
{{#parent}}
|
|
||||||
sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n");
|
|
||||||
{{/parent}}
|
|
||||||
{{#vars}}
|
|
||||||
sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
|
|
||||||
{{/vars}}
|
|
||||||
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 {{#parent}}{{^isArray}}{{^isMap}}override {{/isMap}}{{/isArray}}{{/parent}}{{^parent}}virtual {{/parent}}string ToJson()
|
|
||||||
{
|
|
||||||
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns true if objects are equal
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input">Object to be compared</param>
|
|
||||||
/// <returns>Boolean</returns>
|
|
||||||
public override bool Equals(object input)
|
|
||||||
{
|
|
||||||
return this.Equals(input as {{classname}});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns true if {{classname}} instances are equal
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input">Instance of {{classname}} to be compared</param>
|
|
||||||
/// <returns>Boolean</returns>
|
|
||||||
public bool Equals({{classname}} input)
|
|
||||||
{
|
|
||||||
if (input == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return {{#vars}}{{#parent}}base.Equals(input) && {{/parent}}{{^isContainer}}
|
|
||||||
(
|
|
||||||
this.{{name}} == input.{{name}} ||
|
|
||||||
(this.{{name}} != null &&
|
|
||||||
this.{{name}}.Equals(input.{{name}}))
|
|
||||||
){{^-last}} && {{/-last}}{{/isContainer}}{{#isContainer}}
|
|
||||||
(
|
|
||||||
this.{{name}} == input.{{name}} ||
|
|
||||||
this.{{name}} != null &&
|
|
||||||
input.{{name}} != null &&
|
|
||||||
this.{{name}}.SequenceEqual(input.{{name}})
|
|
||||||
){{^-last}} && {{/-last}}{{/isContainer}}{{/vars}}{{^vars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/vars}};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the hash code
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Hash code</returns>
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
unchecked // Overflow is fine, just wrap
|
|
||||||
{
|
|
||||||
{{#parent}}
|
|
||||||
int hashCode = base.GetHashCode();
|
|
||||||
{{/parent}}
|
|
||||||
{{^parent}}
|
|
||||||
int hashCode = 41;
|
|
||||||
{{/parent}}
|
|
||||||
{{#vars}}
|
|
||||||
if (this.{{name}} != null)
|
|
||||||
hashCode = hashCode * 59 + this.{{name}}.GetHashCode();
|
|
||||||
{{/vars}}
|
|
||||||
return hashCode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{{^netStandard}}
|
|
||||||
|
|
||||||
{{#generatePropertyChanged}}
|
|
||||||
/// <summary>
|
|
||||||
/// Property changed event handler
|
|
||||||
/// </summary>
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Trigger when a property changed
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="propertyName">Property Name</param>
|
|
||||||
public virtual void OnPropertyChanged(string propertyName)
|
|
||||||
{
|
|
||||||
// NOTE: property changed is handled via "code weaving" using Fody.
|
|
||||||
// Properties with setters are modified at compile time to notify of changes.
|
|
||||||
var propertyChanged = PropertyChanged;
|
|
||||||
if (propertyChanged != null)
|
|
||||||
{
|
|
||||||
propertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{{/generatePropertyChanged}}
|
|
||||||
{{#validatable}}
|
|
||||||
{{#hasChildren}}
|
|
||||||
/// <summary>
|
|
||||||
/// To validate all properties of the instance
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="validationContext">Validation context</param>
|
|
||||||
/// <returns>Validation Result</returns>
|
|
||||||
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
|
|
||||||
{
|
|
||||||
return this.BaseValidate(validationContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// To validate all properties of the instance
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="validationContext">Validation context</param>
|
|
||||||
/// <returns>Validation Result</returns>
|
|
||||||
protected IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> BaseValidate(ValidationContext validationContext)
|
|
||||||
{
|
|
||||||
{{/hasChildren}}
|
|
||||||
{{^hasChildren}}
|
|
||||||
/// <summary>
|
|
||||||
/// To validate all properties of the instance
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="validationContext">Validation context</param>
|
|
||||||
/// <returns>Validation Result</returns>
|
|
||||||
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
|
|
||||||
{
|
|
||||||
{{/hasChildren}}
|
|
||||||
{{#parent}}
|
|
||||||
{{^isArray}}
|
|
||||||
{{^isMap}}
|
|
||||||
foreach(var x in base.BaseValidate(validationContext)) yield return x;
|
|
||||||
{{/isMap}}
|
|
||||||
{{/isArray}}
|
|
||||||
{{/parent}}
|
|
||||||
{{#vars}}
|
|
||||||
{{#hasValidation}}
|
|
||||||
{{#isEnum}}
|
|
||||||
{{#maxLength}}
|
|
||||||
// {{{name}}} ({{{dataType}}}) maxLength
|
|
||||||
if(this.{{{name}}} != null && this.{{{name}}}.ToString().Length > {{maxLength}})
|
|
||||||
{
|
|
||||||
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, length must be less than {{maxLength}}.", new [] { "{{{name}}}" });
|
|
||||||
}
|
|
||||||
{{/maxLength}}
|
|
||||||
{{/isEnum}}
|
|
||||||
{{^isEnum}}
|
|
||||||
{{#maxLength}}
|
|
||||||
// {{{name}}} ({{{dataType}}}) maxLength
|
|
||||||
if(this.{{{name}}} != null && this.{{{name}}}.Length > {{maxLength}})
|
|
||||||
{
|
|
||||||
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, length must be less than {{maxLength}}.", new [] { "{{{name}}}" });
|
|
||||||
}
|
|
||||||
{{/maxLength}}
|
|
||||||
{{/isEnum}}
|
|
||||||
|
|
||||||
{{#isEnum}}
|
|
||||||
{{#minLength}}
|
|
||||||
// {{{name}}} ({{{dataType}}}) minLength
|
|
||||||
if(this.{{{name}}} != null && this.{{{name}}}.ToString().Length < {{minLength}})
|
|
||||||
{
|
|
||||||
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, length must be greater than {{minLength}}.", new [] { "{{{name}}}" });
|
|
||||||
}
|
|
||||||
{{/minLength}}
|
|
||||||
{{/isEnum}}
|
|
||||||
{{^isEnum}}
|
|
||||||
{{#minLength}}
|
|
||||||
// {{{name}}} ({{{dataType}}}) minLength
|
|
||||||
if(this.{{{name}}} != null && this.{{{name}}}.Length < {{minLength}})
|
|
||||||
{
|
|
||||||
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, length must be greater than {{minLength}}.", new [] { "{{{name}}}" });
|
|
||||||
}
|
|
||||||
{{/minLength}}
|
|
||||||
{{/isEnum}}
|
|
||||||
|
|
||||||
{{#maximum}}
|
|
||||||
// {{{name}}} ({{{dataType}}}) maximum
|
|
||||||
if(this.{{{name}}} > ({{{dataType}}}){{maximum}})
|
|
||||||
{
|
|
||||||
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must be a value less than or equal to {{maximum}}.", new [] { "{{{name}}}" });
|
|
||||||
}
|
|
||||||
|
|
||||||
{{/maximum}}
|
|
||||||
{{#minimum}}
|
|
||||||
// {{{name}}} ({{{dataType}}}) minimum
|
|
||||||
if(this.{{{name}}} < ({{{dataType}}}){{minimum}})
|
|
||||||
{
|
|
||||||
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must be a value greater than or equal to {{minimum}}.", new [] { "{{{name}}}" });
|
|
||||||
}
|
|
||||||
|
|
||||||
{{/minimum}}
|
|
||||||
{{#pattern}}
|
|
||||||
{{^isByteArray}}
|
|
||||||
// {{{name}}} ({{{dataType}}}) pattern
|
|
||||||
Regex regex{{{name}}} = new Regex(@"{{{vendorExtensions.x-regex}}}"{{#vendorExtensions.x-modifiers}}{{#-first}}, {{/-first}}RegexOptions.{{{.}}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}});
|
|
||||||
if (false == regex{{{name}}}.Match(this.{{{name}}}{{#isUuid}}.ToString(){{/isUuid}}).Success)
|
|
||||||
{
|
|
||||||
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must match a pattern of " + regex{{{name}}}, new [] { "{{{name}}}" });
|
|
||||||
}
|
|
||||||
|
|
||||||
{{/isByteArray}}
|
|
||||||
{{/pattern}}
|
|
||||||
{{/hasValidation}}
|
|
||||||
{{/vars}}
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
{{/validatable}}
|
|
||||||
{{/netStandard}}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
{{^isContainer}}
|
|
||||||
/// <summary>
|
|
||||||
/// {{description}}{{^description}}Defines {{{name}}}{{/description}}
|
|
||||||
/// </summary>
|
|
||||||
{{#description}}
|
|
||||||
/// <value>{{.}}</value>
|
|
||||||
{{/description}}
|
|
||||||
{{#isString}}
|
|
||||||
{{^useGenericHost}}
|
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
|
||||||
{{/useGenericHost}}
|
|
||||||
{{/isString}}
|
|
||||||
{{>visibility}} enum {{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}{{#vendorExtensions.x-enum-byte}}: byte{{/vendorExtensions.x-enum-byte}}
|
|
||||||
{
|
|
||||||
{{#allowableValues}}
|
|
||||||
{{#enumVars}}
|
|
||||||
/// <summary>
|
|
||||||
/// Enum {{name}} for value: {{{value}}}
|
|
||||||
/// </summary>
|
|
||||||
{{#isString}}
|
|
||||||
[EnumMember(Value = "{{{value}}}")]
|
|
||||||
{{/isString}}
|
|
||||||
{{name}}{{^isString}} = {{{value}}}{{/isString}}{{#isString}} = {{-index}}{{/isString}}{{^-last}},{{/-last}}
|
|
||||||
|
|
||||||
{{/enumVars}}
|
|
||||||
{{/allowableValues}}
|
|
||||||
}
|
|
||||||
{{/isContainer}}
|
|
@ -1,23 +0,0 @@
|
|||||||
{{#models}}
|
|
||||||
{{#model}}
|
|
||||||
|
|
||||||
# {{{packageName}}}.{{modelPackage}}.{{{classname}}}
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
{{#parent}}
|
|
||||||
{{#parentVars}}
|
|
||||||
**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
|
||||||
{{/parentVars}}
|
|
||||||
{{/parent}}
|
|
||||||
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
|
||||||
{{/vars}}
|
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models)
|
|
||||||
[[Back to API list]](../README.md#documentation-for-api-endpoints)
|
|
||||||
[[Back to README]](../README.md)
|
|
||||||
|
|
||||||
{{/model}}
|
|
||||||
{{/models}}
|
|
@ -1,89 +0,0 @@
|
|||||||
{{>partial_header}}
|
|
||||||
|
|
||||||
using NUnit.Framework;
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.IO;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using {{packageName}}.{{apiPackage}};
|
|
||||||
using {{packageName}}.{{modelPackage}};
|
|
||||||
using {{packageName}}.Client;
|
|
||||||
using System.Reflection;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
{{#models}}
|
|
||||||
{{#model}}
|
|
||||||
namespace {{packageName}}.Test
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Class for testing {{classname}}
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
/// Please update the test case below to test the model.
|
|
||||||
/// </remarks>
|
|
||||||
public class {{classname}}Tests
|
|
||||||
{
|
|
||||||
// TODO uncomment below to declare an instance variable for {{classname}}
|
|
||||||
//private {{classname}} instance;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Setup before each test
|
|
||||||
/// </summary>
|
|
||||||
[SetUp]
|
|
||||||
public void Init()
|
|
||||||
{
|
|
||||||
// TODO uncomment below to create an instance of {{classname}}
|
|
||||||
//instance = new {{classname}}();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up after each test
|
|
||||||
/// </summary>
|
|
||||||
[TearDown]
|
|
||||||
public void Cleanup()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Test an instance of {{classname}}
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void {{classname}}InstanceTest()
|
|
||||||
{
|
|
||||||
// TODO uncomment below to test "IsInstanceOf" {{classname}}
|
|
||||||
//Assert.IsInstanceOf(typeof({{classname}}), instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
{{#discriminator}}
|
|
||||||
{{#children}}
|
|
||||||
/// <summary>
|
|
||||||
/// Test deserialize a {{classname}} from type {{parent}}
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void {{classname}}DeserializeFrom{{parent}}Test()
|
|
||||||
{
|
|
||||||
// TODO uncomment below to test deserialize a {{classname}} from type {{parent}}
|
|
||||||
//Assert.IsInstanceOf(typeof({{parent}}), JsonConvert.DeserializeObject<{{parent}}>(new {{classname}}().ToJson()));
|
|
||||||
}
|
|
||||||
{{/children}}
|
|
||||||
{{/discriminator}}
|
|
||||||
|
|
||||||
{{#vars}}
|
|
||||||
/// <summary>
|
|
||||||
/// Test the property '{{name}}'
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void {{name}}Test()
|
|
||||||
{
|
|
||||||
// TODO unit test for the property '{{name}}'
|
|
||||||
}
|
|
||||||
{{/vars}}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
{{/model}}
|
|
||||||
{{/models}}
|
|
@ -1,22 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# Generated by: https://github.com/openapitools/openapi-generator.git
|
|
||||||
#
|
|
||||||
|
|
||||||
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
|
|
||||||
mozroots --import --sync
|
|
||||||
|
|
||||||
echo "[INFO] remove bin/Debug/{{{packageName}}}.Test.dll"
|
|
||||||
rm src/{{{packageName}}}.Test/bin/Debug/{{{packageName}}}.Test.dll 2> /dev/null
|
|
||||||
|
|
||||||
echo "[INFO] install NUnit runners via NuGet"
|
|
||||||
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
|
|
||||||
mozroots --import --sync
|
|
||||||
mono nuget.exe install src/{{{packageName}}}.Test/packages.config -o packages
|
|
||||||
|
|
||||||
echo "[INFO] Install NUnit Console 3.x runners via NuGet"
|
|
||||||
mono nuget.exe install NUnit.ConsoleRunner -Version 3.10.0 -OutputDirectory packages
|
|
||||||
|
|
||||||
echo "[INFO] Build the solution and run the unit test"
|
|
||||||
xbuild {{{packageName}}}.sln && \
|
|
||||||
mono ./packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe src/{{{packageName}}}.Test/bin/Debug/{{{packageName}}}.Test.dll
|
|
@ -1,49 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>{{targetFrameworkNuget}}</TargetFramework>
|
|
||||||
<AssemblyName>{{packageName}}</AssemblyName>
|
|
||||||
<PackageId>{{packageName}}</PackageId>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<Authors>{{packageAuthors}}</Authors>
|
|
||||||
<Company>{{packageCompany}}</Company>
|
|
||||||
<AssemblyTitle>{{packageTitle}}</AssemblyTitle>
|
|
||||||
<Description>{{packageDescription}}</Description>
|
|
||||||
<Copyright>{{packageCopyright}}</Copyright>
|
|
||||||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
|
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
|
||||||
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
|
|
||||||
<RootNamespace>{{packageName}}</RootNamespace>
|
|
||||||
<Version>{{packageVersion}}</Version>
|
|
||||||
{{#nullableReferenceTypes}}
|
|
||||||
<Nullable>annotations</Nullable>
|
|
||||||
{{/nullableReferenceTypes}}
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
{{#netStandard}}
|
|
||||||
<PackageReference Include="FubarCoder.RestSharp.Portable.Core" Version="4.0.7" />
|
|
||||||
<PackageReference Include="FubarCoder.RestSharp.Portable.HttpClient" Version="4.0.7" />
|
|
||||||
{{/netStandard}}
|
|
||||||
{{^netStandard}}
|
|
||||||
<PackageReference Include="RestSharp" Version="{{restsharp.version}}" />
|
|
||||||
{{/netStandard}}
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="{{newtonsoft-json.version}}" />
|
|
||||||
<PackageReference Include="JsonSubTypes" Version="{{json-subtypes.version}}" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
{{^netStandard}}
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Runtime.Serialization" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
|
||||||
{{/netStandard}}
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,49 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>{{targetFrameworkNuget}}</TargetFramework>
|
|
||||||
<AssemblyName>{{testPackageName}}</AssemblyName>
|
|
||||||
<PackageId>{{testPackageName}}</PackageId>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<Authors>{{packageAuthors}}</Authors>
|
|
||||||
<Company>{{packageCompany}}</Company>
|
|
||||||
<AssemblyTitle>{{packageTitle}}</AssemblyTitle>
|
|
||||||
<Description>{{packageDescription}}</Description>
|
|
||||||
<Copyright>{{packageCopyright}}</Copyright>
|
|
||||||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
|
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
|
||||||
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
|
|
||||||
<RootNamespace>{{testPackageName}}</RootNamespace>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="NUnit" Version="2.6.4" />
|
|
||||||
{{#netStandard}}
|
|
||||||
<PackageReference Include="FubarCoder.RestSharp.Portable.Core" Version="4.0.7" />
|
|
||||||
{{/netStandard}}
|
|
||||||
{{^netStandard}}
|
|
||||||
<PackageReference Include="RestSharp" Version="{{restsharp.version}}" />
|
|
||||||
{{/netStandard}}
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="{{newtonsoft-json.version}}" />
|
|
||||||
<PackageReference Include="JsonSubTypes" Version="{{json-subtypes.version}}" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
{{^netStandard}}
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Runtime.Serialization" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
|
||||||
{{/netStandard}}
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\{{packageName}}\{{packageName}}.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,53 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
|
||||||
<metadata>
|
|
||||||
<!-- The identifier that must be unique within the hosting gallery -->
|
|
||||||
<id>$id$</id>
|
|
||||||
<title>{{packageTitle}}</title>
|
|
||||||
|
|
||||||
<!-- The package version number that is used when resolving dependencies -->
|
|
||||||
<version>$version$</version>
|
|
||||||
|
|
||||||
<!-- Authors contain text that appears directly on the gallery -->
|
|
||||||
<authors>$author$</authors>
|
|
||||||
|
|
||||||
<!-- Owners are typically nuget.org identities that allow gallery
|
|
||||||
users to easily find other packages by the same owners. -->
|
|
||||||
<owners>$author$</owners>
|
|
||||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
|
||||||
<developmentDependency>false</developmentDependency>
|
|
||||||
|
|
||||||
<!-- The description can be used in package manager UI. Note that the
|
|
||||||
nuget.org gallery uses information you add in the portal. -->
|
|
||||||
<description>{{packageDescription}}</description>
|
|
||||||
{{#termsOfService}}
|
|
||||||
<copyright>{{.}}</copyright>
|
|
||||||
{{/termsOfService}}
|
|
||||||
{{#licenseUrl}}
|
|
||||||
<licenseUrl>{{.}}</licenseUrl>
|
|
||||||
{{/licenseUrl}}
|
|
||||||
|
|
||||||
<!-- Dependencies are automatically installed when the package is installed -->
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
<dependency id="NewtonSoft.Json" version="{{newtonsoft-json.version}}" />
|
|
||||||
<dependency id="JsonSubTypes" version="{{json-subtypes.version}}" />
|
|
||||||
<dependency id="RestSharp" version="{{restsharp.version}}" />
|
|
||||||
{{#generatePropertyChanged}}
|
|
||||||
<dependency id="Fody" version="{{fody.version}}" />
|
|
||||||
<dependency id="PropertyChanged.Fody" version="{{propertychanged-fody.version}}" />
|
|
||||||
{{/generatePropertyChanged}}
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
</metadata>
|
|
||||||
<files>
|
|
||||||
|
|
||||||
<!-- A readme.txt will be displayed when the package is installed -->
|
|
||||||
<file src="..\..\README.md" target="" />
|
|
||||||
<file src="..\..\docs\**\*.*" target="docs" />
|
|
||||||
{{#generatePropertyChanged}}
|
|
||||||
<file src="..\..\packages\Fody.1.29.4\build\portable-net+sl+win+wpa+wp\Fody.targets" target="build" />
|
|
||||||
{{/generatePropertyChanged}}
|
|
||||||
|
|
||||||
</files>
|
|
||||||
</package>
|
|
@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<packages>
|
|
||||||
<package id="NUnit" version="{{nunit.version}}" targetFramework="{{nunit.targetFramework}}" />
|
|
||||||
<package id="RestSharp" version="{{restsharp.version}}" targetFramework="{{restsharp.targetFramework}}" developmentDependency="true" />
|
|
||||||
<package id="Newtonsoft.Json" version="{{newtonsoft-json.version}}" targetFramework="{{newtonsoft-json.targetFramework}}" developmentDependency="true" />
|
|
||||||
<package id="JsonSubTypes" version="{{json-subtypes.version}}" targetFramework="{{json-subtypes.targetFramework}}" developmentDependency="true" />
|
|
||||||
{{#generatePropertyChanged}}
|
|
||||||
<package id="Fody" version="{{fody.version}}" targetFramework="{{fody.targetFramework}}" developmentDependency="true" />
|
|
||||||
<package id="PropertyChanged.Fody" version="{{propertychanged-fody.version}}" targetFramework="{{propertychanged-fody.targetFramework}}" developmentDependency="true" />
|
|
||||||
{{/generatePropertyChanged}}
|
|
||||||
</packages>
|
|
@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<packages>
|
|
||||||
<package id="NUnit" version="{{nunit.version}}" targetFramework="{{nunit.targetFramework}}" />
|
|
||||||
<package id="RestSharp" version="{{restsharp.version}}" targetFramework="{{restsharp.targetFramework}}" developmentDependency="true" />
|
|
||||||
<package id="Newtonsoft.Json" version="{{newtonsoft-json.version}}" targetFramework="{{newtonsoft-json.targetFramework}}" developmentDependency="true" />
|
|
||||||
<package id="JsonSubTypes" version="{{json-subtypes.version}}" targetFramework="{{json-subtypes.targetFramework}}" developmentDependency="true" />
|
|
||||||
</packages>
|
|
@ -1,13 +0,0 @@
|
|||||||
/*
|
|
||||||
{{#appName}}
|
|
||||||
* {{{.}}}
|
|
||||||
*
|
|
||||||
{{/appName}}
|
|
||||||
{{#appDescription}}
|
|
||||||
* {{{.}}}
|
|
||||||
*
|
|
||||||
{{/appDescription}}
|
|
||||||
* {{#version}}The version of the OpenAPI document: {{{.}}}{{/version}}
|
|
||||||
* {{#infoEmail}}Contact: {{{.}}}{{/infoEmail}}
|
|
||||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
|
||||||
*/
|
|
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"supports": {},
|
|
||||||
"dependencies": {
|
|
||||||
"FubarCoder.RestSharp.Portable.Core": "4.0.7",
|
|
||||||
"FubarCoder.RestSharp.Portable.HttpClient": "4.0.7",
|
|
||||||
"Newtonsoft.Json": "{{newtonsoft-json.version}}",
|
|
||||||
"JsonSubTypes": "{{json-subtypes.version}}"
|
|
||||||
},
|
|
||||||
"frameworks": {
|
|
||||||
"{{targetFrameworkNuget}}": {}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
#
|
|
||||||
# Generated by: https://github.com/openapitools/openapi-generator.git
|
|
||||||
#
|
|
||||||
language: csharp
|
|
||||||
mono:
|
|
||||||
- latest
|
|
||||||
solution: {{{packageName}}}.sln
|
|
||||||
script:
|
|
||||||
- /bin/sh ./mono_nunit_test.sh
|
|
@ -1 +0,0 @@
|
|||||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}}
|
|
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
|
||||||
* Copyright 2018 SmartBear Software
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.openapitools.codegen.csharp;
|
|
||||||
|
|
||||||
import org.openapitools.codegen.CodegenConstants;
|
|
||||||
import org.openapitools.codegen.languages.CSharpClientCodegen;
|
|
||||||
import org.testng.Assert;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
public class CSharpClientCodegenTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testInitialConfigValues() throws Exception {
|
|
||||||
final CSharpClientCodegen codegen = new CSharpClientCodegen();
|
|
||||||
codegen.processOpts();
|
|
||||||
|
|
||||||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE);
|
|
||||||
Assert.assertTrue(codegen.isHideGenerationTimestamp());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSettersForConfigValues() throws Exception {
|
|
||||||
final CSharpClientCodegen codegen = new CSharpClientCodegen();
|
|
||||||
codegen.setHideGenerationTimestamp(false);
|
|
||||||
codegen.processOpts();
|
|
||||||
|
|
||||||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE);
|
|
||||||
Assert.assertFalse(codegen.isHideGenerationTimestamp());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAdditionalPropertiesPutForConfigValues() throws Exception {
|
|
||||||
final CSharpClientCodegen codegen = new CSharpClientCodegen();
|
|
||||||
codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false);
|
|
||||||
codegen.processOpts();
|
|
||||||
|
|
||||||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE);
|
|
||||||
Assert.assertFalse(codegen.isHideGenerationTimestamp());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openapitools.codegen.csharp;
|
package org.openapitools.codegen.csharpnetcore;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import io.swagger.v3.oas.models.OpenAPI;
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
@ -29,7 +29,6 @@ import org.openapitools.codegen.TestUtils;
|
|||||||
import org.openapitools.codegen.languages.AbstractCSharpCodegen;
|
import org.openapitools.codegen.languages.AbstractCSharpCodegen;
|
||||||
import org.openapitools.codegen.languages.AspNetCoreServerCodegen;
|
import org.openapitools.codegen.languages.AspNetCoreServerCodegen;
|
||||||
import org.openapitools.codegen.languages.CSharpNetCoreClientCodegen;
|
import org.openapitools.codegen.languages.CSharpNetCoreClientCodegen;
|
||||||
import org.openapitools.codegen.languages.CSharpClientCodegen;
|
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
@ -66,7 +65,7 @@ public class CSharpModelTest {
|
|||||||
public void arrayPropertyTest() {
|
public void arrayPropertyTest() {
|
||||||
final Schema schema = getArrayTestSchema();
|
final Schema schema = getArrayTestSchema();
|
||||||
|
|
||||||
final DefaultCodegen codegen = new CSharpClientCodegen();
|
final DefaultCodegen codegen = new CSharpNetCoreClientCodegen();
|
||||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||||
codegen.setOpenAPI(openAPI);
|
codegen.setOpenAPI(openAPI);
|
||||||
final CodegenModel generated = codegen.fromModel("sample", schema);
|
final CodegenModel generated = codegen.fromModel("sample", schema);
|
||||||
@ -93,7 +92,7 @@ public class CSharpModelTest {
|
|||||||
public void arrayPropertyCollectionOptionTest() {
|
public void arrayPropertyCollectionOptionTest() {
|
||||||
final Schema schema = getArrayTestSchema();
|
final Schema schema = getArrayTestSchema();
|
||||||
|
|
||||||
final CSharpClientCodegen codegen = new CSharpClientCodegen();
|
final CSharpNetCoreClientCodegen codegen = new CSharpNetCoreClientCodegen();
|
||||||
codegen.setUseCollection(true);
|
codegen.setUseCollection(true);
|
||||||
|
|
||||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||||
@ -118,7 +117,7 @@ public class CSharpModelTest {
|
|||||||
public void arrayPropertyICollectionOptionTest() {
|
public void arrayPropertyICollectionOptionTest() {
|
||||||
final Schema schema = getArrayTestSchema();
|
final Schema schema = getArrayTestSchema();
|
||||||
|
|
||||||
final CSharpClientCodegen codegen = new CSharpClientCodegen();
|
final CSharpNetCoreClientCodegen codegen = new CSharpNetCoreClientCodegen();
|
||||||
codegen.setUseCollection(true);
|
codegen.setUseCollection(true);
|
||||||
codegen.setReturnICollection(true);
|
codegen.setReturnICollection(true);
|
||||||
|
|
||||||
@ -159,7 +158,7 @@ public class CSharpModelTest {
|
|||||||
.addProperties("createdAt", new DateTimeSchema())
|
.addProperties("createdAt", new DateTimeSchema())
|
||||||
.addRequiredItem("id")
|
.addRequiredItem("id")
|
||||||
.addRequiredItem("name");
|
.addRequiredItem("name");
|
||||||
final DefaultCodegen codegen = new CSharpClientCodegen();
|
final DefaultCodegen codegen = new CSharpNetCoreClientCodegen();
|
||||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||||
codegen.setOpenAPI(openAPI);
|
codegen.setOpenAPI(openAPI);
|
||||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||||
@ -205,7 +204,7 @@ public class CSharpModelTest {
|
|||||||
.items(new StringSchema()))
|
.items(new StringSchema()))
|
||||||
.addProperties("name", new StringSchema().nullable(true))
|
.addProperties("name", new StringSchema().nullable(true))
|
||||||
.addRequiredItem("id");
|
.addRequiredItem("id");
|
||||||
final DefaultCodegen codegen = new CSharpClientCodegen();
|
final DefaultCodegen codegen = new CSharpNetCoreClientCodegen();
|
||||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||||
codegen.setOpenAPI(openAPI);
|
codegen.setOpenAPI(openAPI);
|
||||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||||
@ -254,7 +253,7 @@ public class CSharpModelTest {
|
|||||||
.items(new StringSchema()))
|
.items(new StringSchema()))
|
||||||
.addProperties("name", new StringSchema().nullable(true))
|
.addProperties("name", new StringSchema().nullable(true))
|
||||||
.addRequiredItem("id");
|
.addRequiredItem("id");
|
||||||
final DefaultCodegen codegen = new CSharpClientCodegen();
|
final DefaultCodegen codegen = new CSharpNetCoreClientCodegen();
|
||||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||||
codegen.setOpenAPI(openAPI);
|
codegen.setOpenAPI(openAPI);
|
||||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||||
@ -422,7 +421,7 @@ public class CSharpModelTest {
|
|||||||
.addProperties("urls", new ArraySchema()
|
.addProperties("urls", new ArraySchema()
|
||||||
.items(new StringSchema()))
|
.items(new StringSchema()))
|
||||||
.addRequiredItem("id");
|
.addRequiredItem("id");
|
||||||
final DefaultCodegen codegen = new CSharpClientCodegen();
|
final DefaultCodegen codegen = new CSharpNetCoreClientCodegen();
|
||||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||||
codegen.setOpenAPI(openAPI);
|
codegen.setOpenAPI(openAPI);
|
||||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||||
@ -460,7 +459,7 @@ public class CSharpModelTest {
|
|||||||
.addProperties("translations", new MapSchema()
|
.addProperties("translations", new MapSchema()
|
||||||
.additionalProperties(new StringSchema()))
|
.additionalProperties(new StringSchema()))
|
||||||
.addRequiredItem("id");
|
.addRequiredItem("id");
|
||||||
final DefaultCodegen codegen = new CSharpClientCodegen();
|
final DefaultCodegen codegen = new CSharpNetCoreClientCodegen();
|
||||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||||
codegen.setOpenAPI(openAPI);
|
codegen.setOpenAPI(openAPI);
|
||||||
final CodegenModel cm = codegen.fromModel("sample", schema);
|
final CodegenModel cm = codegen.fromModel("sample", schema);
|
||||||
@ -486,7 +485,7 @@ public class CSharpModelTest {
|
|||||||
final Schema schema = new Schema()
|
final Schema schema = new Schema()
|
||||||
.description("a sample model")
|
.description("a sample model")
|
||||||
.addProperties("children", new Schema().$ref("#/components/schemas/Children"));
|
.addProperties("children", new Schema().$ref("#/components/schemas/Children"));
|
||||||
final DefaultCodegen codegen = new CSharpClientCodegen();
|
final DefaultCodegen codegen = new CSharpNetCoreClientCodegen();
|
||||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||||
codegen.setOpenAPI(openAPI);
|
codegen.setOpenAPI(openAPI);
|
||||||
final CodegenModel cm = codegen.fromModel("sample", schema);
|
final CodegenModel cm = codegen.fromModel("sample", schema);
|
||||||
@ -511,7 +510,7 @@ public class CSharpModelTest {
|
|||||||
.description("a sample model")
|
.description("a sample model")
|
||||||
.addProperties("children", new ArraySchema()
|
.addProperties("children", new ArraySchema()
|
||||||
.items(new Schema().$ref("#/components/schemas/Children")));
|
.items(new Schema().$ref("#/components/schemas/Children")));
|
||||||
final DefaultCodegen codegen = new CSharpClientCodegen();
|
final DefaultCodegen codegen = new CSharpNetCoreClientCodegen();
|
||||||
codegen.setOpenAPI(openAPI);
|
codegen.setOpenAPI(openAPI);
|
||||||
final CodegenModel cm = codegen.fromModel("sample", schema);
|
final CodegenModel cm = codegen.fromModel("sample", schema);
|
||||||
|
|
||||||
@ -537,7 +536,7 @@ public class CSharpModelTest {
|
|||||||
.description("a sample model")
|
.description("a sample model")
|
||||||
.addProperties("children", new MapSchema()
|
.addProperties("children", new MapSchema()
|
||||||
.additionalProperties(new Schema().$ref("#/components/schemas/Children")));
|
.additionalProperties(new Schema().$ref("#/components/schemas/Children")));
|
||||||
final DefaultCodegen codegen = new CSharpClientCodegen();
|
final DefaultCodegen codegen = new CSharpNetCoreClientCodegen();
|
||||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||||
codegen.setOpenAPI(openAPI);
|
codegen.setOpenAPI(openAPI);
|
||||||
final CodegenModel cm = codegen.fromModel("sample", schema);
|
final CodegenModel cm = codegen.fromModel("sample", schema);
|
||||||
@ -564,7 +563,7 @@ public class CSharpModelTest {
|
|||||||
final Schema schema = new ArraySchema()
|
final Schema schema = new ArraySchema()
|
||||||
.items(new Schema().$ref("#/components/schemas/Children"))
|
.items(new Schema().$ref("#/components/schemas/Children"))
|
||||||
.description("an array model");
|
.description("an array model");
|
||||||
final DefaultCodegen codegen = new CSharpClientCodegen();
|
final DefaultCodegen codegen = new CSharpNetCoreClientCodegen();
|
||||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||||
codegen.setOpenAPI(openAPI);
|
codegen.setOpenAPI(openAPI);
|
||||||
final CodegenModel cm = codegen.fromModel("sample", schema);
|
final CodegenModel cm = codegen.fromModel("sample", schema);
|
||||||
@ -583,7 +582,7 @@ public class CSharpModelTest {
|
|||||||
final Schema schema = new Schema()
|
final Schema schema = new Schema()
|
||||||
.description("a map model")
|
.description("a map model")
|
||||||
.additionalProperties(new Schema().$ref("#/components/schemas/Children"));
|
.additionalProperties(new Schema().$ref("#/components/schemas/Children"));
|
||||||
final DefaultCodegen codegen = new CSharpClientCodegen();
|
final DefaultCodegen codegen = new CSharpNetCoreClientCodegen();
|
||||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||||
codegen.setOpenAPI(openAPI);
|
codegen.setOpenAPI(openAPI);
|
||||||
final CodegenModel cm = codegen.fromModel("sample", schema);
|
final CodegenModel cm = codegen.fromModel("sample", schema);
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openapitools.codegen.csharp;
|
package org.openapitools.codegen.csharpnetcore;
|
||||||
|
|
||||||
import io.swagger.v3.oas.models.OpenAPI;
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
import io.swagger.v3.oas.models.Operation;
|
import io.swagger.v3.oas.models.Operation;
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openapitools.codegen.csharp;
|
package org.openapitools.codegen.csharpnetcore;
|
||||||
|
|
||||||
import io.swagger.v3.oas.models.OpenAPI;
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
import io.swagger.v3.oas.models.media.Schema;
|
import io.swagger.v3.oas.models.media.Schema;
|
||||||
@ -25,7 +25,7 @@ import org.openapitools.codegen.CodegenProperty;
|
|||||||
import org.openapitools.codegen.DefaultCodegen;
|
import org.openapitools.codegen.DefaultCodegen;
|
||||||
import org.openapitools.codegen.TestUtils;
|
import org.openapitools.codegen.TestUtils;
|
||||||
import org.openapitools.codegen.languages.AspNetCoreServerCodegen;
|
import org.openapitools.codegen.languages.AspNetCoreServerCodegen;
|
||||||
import org.openapitools.codegen.languages.CSharpClientCodegen;
|
import org.openapitools.codegen.languages.CSharpNetCoreClientCodegen;
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ public class CsharpModelEnumTest {
|
|||||||
.child(subModel)
|
.child(subModel)
|
||||||
.interfaces(new ArrayList<RefModel>());
|
.interfaces(new ArrayList<RefModel>());
|
||||||
*/
|
*/
|
||||||
final DefaultCodegen codegen = new CSharpClientCodegen();
|
final DefaultCodegen codegen = new CSharpNetCoreClientCodegen();
|
||||||
final Map<String, Schema> allModels = new HashMap<>();
|
final Map<String, Schema> allModels = new HashMap<>();
|
||||||
allModels.put("ParentModel", parentModel);
|
allModels.put("ParentModel", parentModel);
|
||||||
allModels.put("SubModel", subModel);
|
allModels.put("SubModel", subModel);
|
@ -1,362 +0,0 @@
|
|||||||
## Ignore Visual Studio temporary files, build results, and
|
|
||||||
## files generated by popular Visual Studio add-ons.
|
|
||||||
##
|
|
||||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
|
||||||
|
|
||||||
# User-specific files
|
|
||||||
*.rsuser
|
|
||||||
*.suo
|
|
||||||
*.user
|
|
||||||
*.userosscache
|
|
||||||
*.sln.docstates
|
|
||||||
|
|
||||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
|
||||||
*.userprefs
|
|
||||||
|
|
||||||
# Mono auto generated files
|
|
||||||
mono_crash.*
|
|
||||||
|
|
||||||
# Build results
|
|
||||||
[Dd]ebug/
|
|
||||||
[Dd]ebugPublic/
|
|
||||||
[Rr]elease/
|
|
||||||
[Rr]eleases/
|
|
||||||
x64/
|
|
||||||
x86/
|
|
||||||
[Ww][Ii][Nn]32/
|
|
||||||
[Aa][Rr][Mm]/
|
|
||||||
[Aa][Rr][Mm]64/
|
|
||||||
bld/
|
|
||||||
[Bb]in/
|
|
||||||
[Oo]bj/
|
|
||||||
[Ll]og/
|
|
||||||
[Ll]ogs/
|
|
||||||
|
|
||||||
# Visual Studio 2015/2017 cache/options directory
|
|
||||||
.vs/
|
|
||||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
|
||||||
#wwwroot/
|
|
||||||
|
|
||||||
# Visual Studio 2017 auto generated files
|
|
||||||
Generated\ Files/
|
|
||||||
|
|
||||||
# MSTest test Results
|
|
||||||
[Tt]est[Rr]esult*/
|
|
||||||
[Bb]uild[Ll]og.*
|
|
||||||
|
|
||||||
# NUnit
|
|
||||||
*.VisualState.xml
|
|
||||||
TestResult.xml
|
|
||||||
nunit-*.xml
|
|
||||||
|
|
||||||
# Build Results of an ATL Project
|
|
||||||
[Dd]ebugPS/
|
|
||||||
[Rr]eleasePS/
|
|
||||||
dlldata.c
|
|
||||||
|
|
||||||
# Benchmark Results
|
|
||||||
BenchmarkDotNet.Artifacts/
|
|
||||||
|
|
||||||
# .NET Core
|
|
||||||
project.lock.json
|
|
||||||
project.fragment.lock.json
|
|
||||||
artifacts/
|
|
||||||
|
|
||||||
# ASP.NET Scaffolding
|
|
||||||
ScaffoldingReadMe.txt
|
|
||||||
|
|
||||||
# StyleCop
|
|
||||||
StyleCopReport.xml
|
|
||||||
|
|
||||||
# Files built by Visual Studio
|
|
||||||
*_i.c
|
|
||||||
*_p.c
|
|
||||||
*_h.h
|
|
||||||
*.ilk
|
|
||||||
*.meta
|
|
||||||
*.obj
|
|
||||||
*.iobj
|
|
||||||
*.pch
|
|
||||||
*.pdb
|
|
||||||
*.ipdb
|
|
||||||
*.pgc
|
|
||||||
*.pgd
|
|
||||||
*.rsp
|
|
||||||
*.sbr
|
|
||||||
*.tlb
|
|
||||||
*.tli
|
|
||||||
*.tlh
|
|
||||||
*.tmp
|
|
||||||
*.tmp_proj
|
|
||||||
*_wpftmp.csproj
|
|
||||||
*.log
|
|
||||||
*.vspscc
|
|
||||||
*.vssscc
|
|
||||||
.builds
|
|
||||||
*.pidb
|
|
||||||
*.svclog
|
|
||||||
*.scc
|
|
||||||
|
|
||||||
# Chutzpah Test files
|
|
||||||
_Chutzpah*
|
|
||||||
|
|
||||||
# Visual C++ cache files
|
|
||||||
ipch/
|
|
||||||
*.aps
|
|
||||||
*.ncb
|
|
||||||
*.opendb
|
|
||||||
*.opensdf
|
|
||||||
*.sdf
|
|
||||||
*.cachefile
|
|
||||||
*.VC.db
|
|
||||||
*.VC.VC.opendb
|
|
||||||
|
|
||||||
# Visual Studio profiler
|
|
||||||
*.psess
|
|
||||||
*.vsp
|
|
||||||
*.vspx
|
|
||||||
*.sap
|
|
||||||
|
|
||||||
# Visual Studio Trace Files
|
|
||||||
*.e2e
|
|
||||||
|
|
||||||
# TFS 2012 Local Workspace
|
|
||||||
$tf/
|
|
||||||
|
|
||||||
# Guidance Automation Toolkit
|
|
||||||
*.gpState
|
|
||||||
|
|
||||||
# ReSharper is a .NET coding add-in
|
|
||||||
_ReSharper*/
|
|
||||||
*.[Rr]e[Ss]harper
|
|
||||||
*.DotSettings.user
|
|
||||||
|
|
||||||
# TeamCity is a build add-in
|
|
||||||
_TeamCity*
|
|
||||||
|
|
||||||
# DotCover is a Code Coverage Tool
|
|
||||||
*.dotCover
|
|
||||||
|
|
||||||
# AxoCover is a Code Coverage Tool
|
|
||||||
.axoCover/*
|
|
||||||
!.axoCover/settings.json
|
|
||||||
|
|
||||||
# Coverlet is a free, cross platform Code Coverage Tool
|
|
||||||
coverage*.json
|
|
||||||
coverage*.xml
|
|
||||||
coverage*.info
|
|
||||||
|
|
||||||
# Visual Studio code coverage results
|
|
||||||
*.coverage
|
|
||||||
*.coveragexml
|
|
||||||
|
|
||||||
# NCrunch
|
|
||||||
_NCrunch_*
|
|
||||||
.*crunch*.local.xml
|
|
||||||
nCrunchTemp_*
|
|
||||||
|
|
||||||
# MightyMoose
|
|
||||||
*.mm.*
|
|
||||||
AutoTest.Net/
|
|
||||||
|
|
||||||
# Web workbench (sass)
|
|
||||||
.sass-cache/
|
|
||||||
|
|
||||||
# Installshield output folder
|
|
||||||
[Ee]xpress/
|
|
||||||
|
|
||||||
# DocProject is a documentation generator add-in
|
|
||||||
DocProject/buildhelp/
|
|
||||||
DocProject/Help/*.HxT
|
|
||||||
DocProject/Help/*.HxC
|
|
||||||
DocProject/Help/*.hhc
|
|
||||||
DocProject/Help/*.hhk
|
|
||||||
DocProject/Help/*.hhp
|
|
||||||
DocProject/Help/Html2
|
|
||||||
DocProject/Help/html
|
|
||||||
|
|
||||||
# Click-Once directory
|
|
||||||
publish/
|
|
||||||
|
|
||||||
# Publish Web Output
|
|
||||||
*.[Pp]ublish.xml
|
|
||||||
*.azurePubxml
|
|
||||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
|
||||||
# but database connection strings (with potential passwords) will be unencrypted
|
|
||||||
*.pubxml
|
|
||||||
*.publishproj
|
|
||||||
|
|
||||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
|
||||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
|
||||||
# in these scripts will be unencrypted
|
|
||||||
PublishScripts/
|
|
||||||
|
|
||||||
# NuGet Packages
|
|
||||||
*.nupkg
|
|
||||||
# NuGet Symbol Packages
|
|
||||||
*.snupkg
|
|
||||||
# The packages folder can be ignored because of Package Restore
|
|
||||||
**/[Pp]ackages/*
|
|
||||||
# except build/, which is used as an MSBuild target.
|
|
||||||
!**/[Pp]ackages/build/
|
|
||||||
# Uncomment if necessary however generally it will be regenerated when needed
|
|
||||||
#!**/[Pp]ackages/repositories.config
|
|
||||||
# NuGet v3's project.json files produces more ignorable files
|
|
||||||
*.nuget.props
|
|
||||||
*.nuget.targets
|
|
||||||
|
|
||||||
# Microsoft Azure Build Output
|
|
||||||
csx/
|
|
||||||
*.build.csdef
|
|
||||||
|
|
||||||
# Microsoft Azure Emulator
|
|
||||||
ecf/
|
|
||||||
rcf/
|
|
||||||
|
|
||||||
# Windows Store app package directories and files
|
|
||||||
AppPackages/
|
|
||||||
BundleArtifacts/
|
|
||||||
Package.StoreAssociation.xml
|
|
||||||
_pkginfo.txt
|
|
||||||
*.appx
|
|
||||||
*.appxbundle
|
|
||||||
*.appxupload
|
|
||||||
|
|
||||||
# Visual Studio cache files
|
|
||||||
# files ending in .cache can be ignored
|
|
||||||
*.[Cc]ache
|
|
||||||
# but keep track of directories ending in .cache
|
|
||||||
!?*.[Cc]ache/
|
|
||||||
|
|
||||||
# Others
|
|
||||||
ClientBin/
|
|
||||||
~$*
|
|
||||||
*~
|
|
||||||
*.dbmdl
|
|
||||||
*.dbproj.schemaview
|
|
||||||
*.jfm
|
|
||||||
*.pfx
|
|
||||||
*.publishsettings
|
|
||||||
orleans.codegen.cs
|
|
||||||
|
|
||||||
# Including strong name files can present a security risk
|
|
||||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
|
||||||
#*.snk
|
|
||||||
|
|
||||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
|
||||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
|
||||||
#bower_components/
|
|
||||||
|
|
||||||
# RIA/Silverlight projects
|
|
||||||
Generated_Code/
|
|
||||||
|
|
||||||
# Backup & report files from converting an old project file
|
|
||||||
# to a newer Visual Studio version. Backup files are not needed,
|
|
||||||
# because we have git ;-)
|
|
||||||
_UpgradeReport_Files/
|
|
||||||
Backup*/
|
|
||||||
UpgradeLog*.XML
|
|
||||||
UpgradeLog*.htm
|
|
||||||
ServiceFabricBackup/
|
|
||||||
*.rptproj.bak
|
|
||||||
|
|
||||||
# SQL Server files
|
|
||||||
*.mdf
|
|
||||||
*.ldf
|
|
||||||
*.ndf
|
|
||||||
|
|
||||||
# Business Intelligence projects
|
|
||||||
*.rdl.data
|
|
||||||
*.bim.layout
|
|
||||||
*.bim_*.settings
|
|
||||||
*.rptproj.rsuser
|
|
||||||
*- [Bb]ackup.rdl
|
|
||||||
*- [Bb]ackup ([0-9]).rdl
|
|
||||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
|
||||||
|
|
||||||
# Microsoft Fakes
|
|
||||||
FakesAssemblies/
|
|
||||||
|
|
||||||
# GhostDoc plugin setting file
|
|
||||||
*.GhostDoc.xml
|
|
||||||
|
|
||||||
# Node.js Tools for Visual Studio
|
|
||||||
.ntvs_analysis.dat
|
|
||||||
node_modules/
|
|
||||||
|
|
||||||
# Visual Studio 6 build log
|
|
||||||
*.plg
|
|
||||||
|
|
||||||
# Visual Studio 6 workspace options file
|
|
||||||
*.opt
|
|
||||||
|
|
||||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
|
||||||
*.vbw
|
|
||||||
|
|
||||||
# Visual Studio LightSwitch build output
|
|
||||||
**/*.HTMLClient/GeneratedArtifacts
|
|
||||||
**/*.DesktopClient/GeneratedArtifacts
|
|
||||||
**/*.DesktopClient/ModelManifest.xml
|
|
||||||
**/*.Server/GeneratedArtifacts
|
|
||||||
**/*.Server/ModelManifest.xml
|
|
||||||
_Pvt_Extensions
|
|
||||||
|
|
||||||
# Paket dependency manager
|
|
||||||
.paket/paket.exe
|
|
||||||
paket-files/
|
|
||||||
|
|
||||||
# FAKE - F# Make
|
|
||||||
.fake/
|
|
||||||
|
|
||||||
# CodeRush personal settings
|
|
||||||
.cr/personal
|
|
||||||
|
|
||||||
# Python Tools for Visual Studio (PTVS)
|
|
||||||
__pycache__/
|
|
||||||
*.pyc
|
|
||||||
|
|
||||||
# Cake - Uncomment if you are using it
|
|
||||||
# tools/**
|
|
||||||
# !tools/packages.config
|
|
||||||
|
|
||||||
# Tabs Studio
|
|
||||||
*.tss
|
|
||||||
|
|
||||||
# Telerik's JustMock configuration file
|
|
||||||
*.jmconfig
|
|
||||||
|
|
||||||
# BizTalk build output
|
|
||||||
*.btp.cs
|
|
||||||
*.btm.cs
|
|
||||||
*.odx.cs
|
|
||||||
*.xsd.cs
|
|
||||||
|
|
||||||
# OpenCover UI analysis results
|
|
||||||
OpenCover/
|
|
||||||
|
|
||||||
# Azure Stream Analytics local run output
|
|
||||||
ASALocalRun/
|
|
||||||
|
|
||||||
# MSBuild Binary and Structured Log
|
|
||||||
*.binlog
|
|
||||||
|
|
||||||
# NVidia Nsight GPU debugger configuration file
|
|
||||||
*.nvuser
|
|
||||||
|
|
||||||
# MFractors (Xamarin productivity tool) working folder
|
|
||||||
.mfractor/
|
|
||||||
|
|
||||||
# Local History for Visual Studio
|
|
||||||
.localhistory/
|
|
||||||
|
|
||||||
# BeatPulse healthcheck temp database
|
|
||||||
healthchecksdb
|
|
||||||
|
|
||||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
|
||||||
MigrationBackup/
|
|
||||||
|
|
||||||
# Ionide (cross platform F# VS Code tools) working folder
|
|
||||||
.ionide/
|
|
||||||
|
|
||||||
# Fody - auto-generated XML schema
|
|
||||||
FodyWeavers.xsd
|
|
@ -1,4 +0,0 @@
|
|||||||
# OpenAPI Generator Ignore
|
|
||||||
# The test project must embed linux-logo.png so it can be loaded as a stream.
|
|
||||||
src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
|
|
||||||
|
|
@ -1,132 +0,0 @@
|
|||||||
.gitignore
|
|
||||||
.travis.yml
|
|
||||||
Org.OpenAPITools.sln
|
|
||||||
README.md
|
|
||||||
build.bat
|
|
||||||
build.sh
|
|
||||||
docs/AdditionalPropertiesClass.md
|
|
||||||
docs/AllOfWithSingleRef.md
|
|
||||||
docs/Animal.md
|
|
||||||
docs/AnotherFakeApi.md
|
|
||||||
docs/ApiResponse.md
|
|
||||||
docs/ArrayOfArrayOfNumberOnly.md
|
|
||||||
docs/ArrayOfNumberOnly.md
|
|
||||||
docs/ArrayTest.md
|
|
||||||
docs/Capitalization.md
|
|
||||||
docs/Cat.md
|
|
||||||
docs/CatAllOf.md
|
|
||||||
docs/Category.md
|
|
||||||
docs/ClassModel.md
|
|
||||||
docs/DefaultApi.md
|
|
||||||
docs/DeprecatedObject.md
|
|
||||||
docs/Dog.md
|
|
||||||
docs/DogAllOf.md
|
|
||||||
docs/EnumArrays.md
|
|
||||||
docs/EnumClass.md
|
|
||||||
docs/EnumTest.md
|
|
||||||
docs/FakeApi.md
|
|
||||||
docs/FakeClassnameTags123Api.md
|
|
||||||
docs/File.md
|
|
||||||
docs/FileSchemaTestClass.md
|
|
||||||
docs/Foo.md
|
|
||||||
docs/FooGetDefaultResponse.md
|
|
||||||
docs/FormatTest.md
|
|
||||||
docs/HasOnlyReadOnly.md
|
|
||||||
docs/HealthCheckResult.md
|
|
||||||
docs/List.md
|
|
||||||
docs/MapTest.md
|
|
||||||
docs/MixedPropertiesAndAdditionalPropertiesClass.md
|
|
||||||
docs/Model200Response.md
|
|
||||||
docs/ModelClient.md
|
|
||||||
docs/Name.md
|
|
||||||
docs/NullableClass.md
|
|
||||||
docs/NumberOnly.md
|
|
||||||
docs/ObjectWithDeprecatedFields.md
|
|
||||||
docs/Order.md
|
|
||||||
docs/OuterComposite.md
|
|
||||||
docs/OuterEnum.md
|
|
||||||
docs/OuterEnumDefaultValue.md
|
|
||||||
docs/OuterEnumInteger.md
|
|
||||||
docs/OuterEnumIntegerDefaultValue.md
|
|
||||||
docs/OuterObjectWithEnumProperty.md
|
|
||||||
docs/Pet.md
|
|
||||||
docs/PetApi.md
|
|
||||||
docs/ReadOnlyFirst.md
|
|
||||||
docs/Return.md
|
|
||||||
docs/SingleRefType.md
|
|
||||||
docs/SpecialModelName.md
|
|
||||||
docs/StoreApi.md
|
|
||||||
docs/Tag.md
|
|
||||||
docs/User.md
|
|
||||||
docs/UserApi.md
|
|
||||||
git_push.sh
|
|
||||||
mono_nunit_test.sh
|
|
||||||
src/Org.OpenAPITools.Test/packages.config
|
|
||||||
src/Org.OpenAPITools/Api/AnotherFakeApi.cs
|
|
||||||
src/Org.OpenAPITools/Api/DefaultApi.cs
|
|
||||||
src/Org.OpenAPITools/Api/FakeApi.cs
|
|
||||||
src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs
|
|
||||||
src/Org.OpenAPITools/Api/PetApi.cs
|
|
||||||
src/Org.OpenAPITools/Api/StoreApi.cs
|
|
||||||
src/Org.OpenAPITools/Api/UserApi.cs
|
|
||||||
src/Org.OpenAPITools/Client/ApiClient.cs
|
|
||||||
src/Org.OpenAPITools/Client/ApiException.cs
|
|
||||||
src/Org.OpenAPITools/Client/ApiResponse.cs
|
|
||||||
src/Org.OpenAPITools/Client/Configuration.cs
|
|
||||||
src/Org.OpenAPITools/Client/ExceptionFactory.cs
|
|
||||||
src/Org.OpenAPITools/Client/GlobalConfiguration.cs
|
|
||||||
src/Org.OpenAPITools/Client/IApiAccessor.cs
|
|
||||||
src/Org.OpenAPITools/Client/IReadableConfiguration.cs
|
|
||||||
src/Org.OpenAPITools/Client/OpenAPIDateConverter.cs
|
|
||||||
src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
|
|
||||||
src/Org.OpenAPITools/Model/AllOfWithSingleRef.cs
|
|
||||||
src/Org.OpenAPITools/Model/Animal.cs
|
|
||||||
src/Org.OpenAPITools/Model/ApiResponse.cs
|
|
||||||
src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
|
|
||||||
src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
|
|
||||||
src/Org.OpenAPITools/Model/ArrayTest.cs
|
|
||||||
src/Org.OpenAPITools/Model/Capitalization.cs
|
|
||||||
src/Org.OpenAPITools/Model/Cat.cs
|
|
||||||
src/Org.OpenAPITools/Model/CatAllOf.cs
|
|
||||||
src/Org.OpenAPITools/Model/Category.cs
|
|
||||||
src/Org.OpenAPITools/Model/ClassModel.cs
|
|
||||||
src/Org.OpenAPITools/Model/DeprecatedObject.cs
|
|
||||||
src/Org.OpenAPITools/Model/Dog.cs
|
|
||||||
src/Org.OpenAPITools/Model/DogAllOf.cs
|
|
||||||
src/Org.OpenAPITools/Model/EnumArrays.cs
|
|
||||||
src/Org.OpenAPITools/Model/EnumClass.cs
|
|
||||||
src/Org.OpenAPITools/Model/EnumTest.cs
|
|
||||||
src/Org.OpenAPITools/Model/File.cs
|
|
||||||
src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
|
|
||||||
src/Org.OpenAPITools/Model/Foo.cs
|
|
||||||
src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
|
|
||||||
src/Org.OpenAPITools/Model/FormatTest.cs
|
|
||||||
src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
|
|
||||||
src/Org.OpenAPITools/Model/HealthCheckResult.cs
|
|
||||||
src/Org.OpenAPITools/Model/List.cs
|
|
||||||
src/Org.OpenAPITools/Model/MapTest.cs
|
|
||||||
src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
|
|
||||||
src/Org.OpenAPITools/Model/Model200Response.cs
|
|
||||||
src/Org.OpenAPITools/Model/ModelClient.cs
|
|
||||||
src/Org.OpenAPITools/Model/Name.cs
|
|
||||||
src/Org.OpenAPITools/Model/NullableClass.cs
|
|
||||||
src/Org.OpenAPITools/Model/NumberOnly.cs
|
|
||||||
src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
|
|
||||||
src/Org.OpenAPITools/Model/Order.cs
|
|
||||||
src/Org.OpenAPITools/Model/OuterComposite.cs
|
|
||||||
src/Org.OpenAPITools/Model/OuterEnum.cs
|
|
||||||
src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs
|
|
||||||
src/Org.OpenAPITools/Model/OuterEnumInteger.cs
|
|
||||||
src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs
|
|
||||||
src/Org.OpenAPITools/Model/OuterObjectWithEnumProperty.cs
|
|
||||||
src/Org.OpenAPITools/Model/Pet.cs
|
|
||||||
src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
|
|
||||||
src/Org.OpenAPITools/Model/Return.cs
|
|
||||||
src/Org.OpenAPITools/Model/SingleRefType.cs
|
|
||||||
src/Org.OpenAPITools/Model/SpecialModelName.cs
|
|
||||||
src/Org.OpenAPITools/Model/Tag.cs
|
|
||||||
src/Org.OpenAPITools/Model/User.cs
|
|
||||||
src/Org.OpenAPITools/Org.OpenAPITools.csproj
|
|
||||||
src/Org.OpenAPITools/Org.OpenAPITools.nuspec
|
|
||||||
src/Org.OpenAPITools/Properties/AssemblyInfo.cs
|
|
||||||
src/Org.OpenAPITools/packages.config
|
|
@ -1 +0,0 @@
|
|||||||
7.0.0-SNAPSHOT
|
|
@ -1,9 +0,0 @@
|
|||||||
#
|
|
||||||
# Generated by: https://github.com/openapitools/openapi-generator.git
|
|
||||||
#
|
|
||||||
language: csharp
|
|
||||||
mono:
|
|
||||||
- latest
|
|
||||||
solution: Org.OpenAPITools.sln
|
|
||||||
script:
|
|
||||||
- /bin/sh ./mono_nunit_test.sh
|
|
@ -1,27 +0,0 @@
|
|||||||
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}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{321C8C3F-0156-40C1-AE42-D59761FB9B6C}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools.Test", "src\Org.OpenAPITools.Test\Org.OpenAPITools.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
|
|
||||||
{321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{321C8C3F-0156-40C1-AE42-D59761FB9B6C}.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
|
|
@ -1,246 +0,0 @@
|
|||||||
# Org.OpenAPITools - the C# library for the OpenAPI Petstore
|
|
||||||
|
|
||||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
|
||||||
|
|
||||||
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
|
||||||
|
|
||||||
- API version: 1.0.0
|
|
||||||
- SDK version: 1.0.0
|
|
||||||
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen
|
|
||||||
|
|
||||||
## Frameworks supported
|
|
||||||
|
|
||||||
|
|
||||||
- .NET 4.0 or later
|
|
||||||
- Windows Phone 7.1 (Mango)
|
|
||||||
|
|
||||||
## Dependencies
|
|
||||||
|
|
||||||
|
|
||||||
- [RestSharp](https://www.nuget.org/packages/RestSharp) - 105.1.0 or later
|
|
||||||
- [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json/) - 7.0.0 or later
|
|
||||||
- [JsonSubTypes](https://www.nuget.org/packages/JsonSubTypes/) - 1.2.0 or later
|
|
||||||
|
|
||||||
The DLLs included in the package may not be the latest version. We recommend using [NuGet](https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages:
|
|
||||||
|
|
||||||
```
|
|
||||||
Install-Package RestSharp
|
|
||||||
Install-Package Newtonsoft.Json
|
|
||||||
Install-Package JsonSubTypes
|
|
||||||
```
|
|
||||||
|
|
||||||
NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742)
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
Run the following command to generate the DLL
|
|
||||||
|
|
||||||
- [Mac/Linux] `/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 Org.OpenAPITools.Api;
|
|
||||||
using Org.OpenAPITools.Client;
|
|
||||||
using Org.OpenAPITools.Model;
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Packaging
|
|
||||||
|
|
||||||
A `.nuspec` is included with the project. You can follow the Nuget quickstart to [create](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package#create-the-package) and [publish](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package#publish-the-package) packages.
|
|
||||||
|
|
||||||
This `.nuspec` uses placeholders from the `.csproj`, so build the `.csproj` directly:
|
|
||||||
|
|
||||||
```
|
|
||||||
nuget pack -Build -OutputDirectory out Org.OpenAPITools.csproj
|
|
||||||
```
|
|
||||||
|
|
||||||
Then, publish to a [local feed](https://docs.microsoft.com/en-us/nuget/hosting-packages/local-feeds) or [other host](https://docs.microsoft.com/en-us/nuget/hosting-packages/overview) and consume the new package via Nuget as usual.
|
|
||||||
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using Org.OpenAPITools.Api;
|
|
||||||
using Org.OpenAPITools.Client;
|
|
||||||
using Org.OpenAPITools.Model;
|
|
||||||
|
|
||||||
namespace Example
|
|
||||||
{
|
|
||||||
public class Example
|
|
||||||
{
|
|
||||||
public static void Main()
|
|
||||||
{
|
|
||||||
|
|
||||||
Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
|
|
||||||
var apiInstance = new AnotherFakeApi(Configuration.Default);
|
|
||||||
var modelClient = new ModelClient(); // ModelClient | client model
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// To test special tags
|
|
||||||
ModelClient result = apiInstance.Call123TestSpecialTags(modelClient);
|
|
||||||
Debug.WriteLine(result);
|
|
||||||
}
|
|
||||||
catch (ApiException e)
|
|
||||||
{
|
|
||||||
Debug.Print("Exception when calling AnotherFakeApi.Call123TestSpecialTags: " + e.Message );
|
|
||||||
Debug.Print("Status Code: "+ e.ErrorCode);
|
|
||||||
Debug.Print(e.StackTrace);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Documentation for API Endpoints
|
|
||||||
|
|
||||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
|
||||||
|
|
||||||
Class | Method | HTTP request | Description
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
*AnotherFakeApi* | [**Call123TestSpecialTags**](docs/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
|
|
||||||
*DefaultApi* | [**FooGet**](docs/DefaultApi.md#fooget) | **GET** /foo |
|
|
||||||
*FakeApi* | [**FakeHealthGet**](docs/FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint
|
|
||||||
*FakeApi* | [**FakeHttpSignatureTest**](docs/FakeApi.md#fakehttpsignaturetest) | **GET** /fake/http-signature-test | test http signature authentication
|
|
||||||
*FakeApi* | [**FakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean |
|
|
||||||
*FakeApi* | [**FakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite |
|
|
||||||
*FakeApi* | [**FakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number |
|
|
||||||
*FakeApi* | [**FakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string |
|
|
||||||
*FakeApi* | [**FakePropertyEnumIntegerSerialize**](docs/FakeApi.md#fakepropertyenumintegerserialize) | **POST** /fake/property/enum-int |
|
|
||||||
*FakeApi* | [**TestBodyWithBinary**](docs/FakeApi.md#testbodywithbinary) | **PUT** /fake/body-with-binary |
|
|
||||||
*FakeApi* | [**TestBodyWithFileSchema**](docs/FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema |
|
|
||||||
*FakeApi* | [**TestBodyWithQueryParams**](docs/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params |
|
|
||||||
*FakeApi* | [**TestClientModel**](docs/FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model
|
|
||||||
*FakeApi* | [**TestEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
|
||||||
*FakeApi* | [**TestEnumParameters**](docs/FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters
|
|
||||||
*FakeApi* | [**TestGroupParameters**](docs/FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional)
|
|
||||||
*FakeApi* | [**TestInlineAdditionalProperties**](docs/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
|
|
||||||
*FakeApi* | [**TestJsonFormData**](docs/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data
|
|
||||||
*FakeApi* | [**TestQueryParameterCollectionFormat**](docs/FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters |
|
|
||||||
*FakeClassnameTags123Api* | [**TestClassname**](docs/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case
|
|
||||||
*PetApi* | [**AddPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store
|
|
||||||
*PetApi* | [**DeletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
|
|
||||||
*PetApi* | [**FindPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status
|
|
||||||
*PetApi* | [**FindPetsByTags**](docs/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags
|
|
||||||
*PetApi* | [**GetPetById**](docs/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID
|
|
||||||
*PetApi* | [**UpdatePet**](docs/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet
|
|
||||||
*PetApi* | [**UpdatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
|
||||||
*PetApi* | [**UploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image
|
|
||||||
*PetApi* | [**UploadFileWithRequiredFile**](docs/PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
|
|
||||||
*StoreApi* | [**DeleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
|
|
||||||
*StoreApi* | [**GetInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
|
|
||||||
*StoreApi* | [**GetOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID
|
|
||||||
*StoreApi* | [**PlaceOrder**](docs/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet
|
|
||||||
*UserApi* | [**CreateUser**](docs/UserApi.md#createuser) | **POST** /user | Create user
|
|
||||||
*UserApi* | [**CreateUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array
|
|
||||||
*UserApi* | [**CreateUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array
|
|
||||||
*UserApi* | [**DeleteUser**](docs/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user
|
|
||||||
*UserApi* | [**GetUserByName**](docs/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name
|
|
||||||
*UserApi* | [**LoginUser**](docs/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system
|
|
||||||
*UserApi* | [**LogoutUser**](docs/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session
|
|
||||||
*UserApi* | [**UpdateUser**](docs/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user
|
|
||||||
|
|
||||||
|
|
||||||
## Documentation for Models
|
|
||||||
|
|
||||||
- [Model.AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
|
|
||||||
- [Model.AllOfWithSingleRef](docs/AllOfWithSingleRef.md)
|
|
||||||
- [Model.Animal](docs/Animal.md)
|
|
||||||
- [Model.ApiResponse](docs/ApiResponse.md)
|
|
||||||
- [Model.ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
|
||||||
- [Model.ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
|
||||||
- [Model.ArrayTest](docs/ArrayTest.md)
|
|
||||||
- [Model.Capitalization](docs/Capitalization.md)
|
|
||||||
- [Model.Cat](docs/Cat.md)
|
|
||||||
- [Model.CatAllOf](docs/CatAllOf.md)
|
|
||||||
- [Model.Category](docs/Category.md)
|
|
||||||
- [Model.ClassModel](docs/ClassModel.md)
|
|
||||||
- [Model.DeprecatedObject](docs/DeprecatedObject.md)
|
|
||||||
- [Model.Dog](docs/Dog.md)
|
|
||||||
- [Model.DogAllOf](docs/DogAllOf.md)
|
|
||||||
- [Model.EnumArrays](docs/EnumArrays.md)
|
|
||||||
- [Model.EnumClass](docs/EnumClass.md)
|
|
||||||
- [Model.EnumTest](docs/EnumTest.md)
|
|
||||||
- [Model.File](docs/File.md)
|
|
||||||
- [Model.FileSchemaTestClass](docs/FileSchemaTestClass.md)
|
|
||||||
- [Model.Foo](docs/Foo.md)
|
|
||||||
- [Model.FooGetDefaultResponse](docs/FooGetDefaultResponse.md)
|
|
||||||
- [Model.FormatTest](docs/FormatTest.md)
|
|
||||||
- [Model.HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
|
||||||
- [Model.HealthCheckResult](docs/HealthCheckResult.md)
|
|
||||||
- [Model.List](docs/List.md)
|
|
||||||
- [Model.MapTest](docs/MapTest.md)
|
|
||||||
- [Model.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
|
|
||||||
- [Model.Model200Response](docs/Model200Response.md)
|
|
||||||
- [Model.ModelClient](docs/ModelClient.md)
|
|
||||||
- [Model.Name](docs/Name.md)
|
|
||||||
- [Model.NullableClass](docs/NullableClass.md)
|
|
||||||
- [Model.NumberOnly](docs/NumberOnly.md)
|
|
||||||
- [Model.ObjectWithDeprecatedFields](docs/ObjectWithDeprecatedFields.md)
|
|
||||||
- [Model.Order](docs/Order.md)
|
|
||||||
- [Model.OuterComposite](docs/OuterComposite.md)
|
|
||||||
- [Model.OuterEnum](docs/OuterEnum.md)
|
|
||||||
- [Model.OuterEnumDefaultValue](docs/OuterEnumDefaultValue.md)
|
|
||||||
- [Model.OuterEnumInteger](docs/OuterEnumInteger.md)
|
|
||||||
- [Model.OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md)
|
|
||||||
- [Model.OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md)
|
|
||||||
- [Model.Pet](docs/Pet.md)
|
|
||||||
- [Model.ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
|
||||||
- [Model.Return](docs/Return.md)
|
|
||||||
- [Model.SingleRefType](docs/SingleRefType.md)
|
|
||||||
- [Model.SpecialModelName](docs/SpecialModelName.md)
|
|
||||||
- [Model.Tag](docs/Tag.md)
|
|
||||||
- [Model.User](docs/User.md)
|
|
||||||
|
|
||||||
|
|
||||||
<a id="documentation-for-authorization"></a>
|
|
||||||
## Documentation for Authorization
|
|
||||||
|
|
||||||
|
|
||||||
Authentication schemes defined for the API:
|
|
||||||
<a id="petstore_auth"></a>
|
|
||||||
### petstore_auth
|
|
||||||
|
|
||||||
- **Type**: OAuth
|
|
||||||
- **Flow**: implicit
|
|
||||||
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
|
||||||
- **Scopes**:
|
|
||||||
- write:pets: modify pets in your account
|
|
||||||
- read:pets: read your pets
|
|
||||||
|
|
||||||
<a id="api_key"></a>
|
|
||||||
### api_key
|
|
||||||
|
|
||||||
- **Type**: API key
|
|
||||||
- **API key parameter name**: api_key
|
|
||||||
- **Location**: HTTP header
|
|
||||||
|
|
||||||
<a id="api_key_query"></a>
|
|
||||||
### api_key_query
|
|
||||||
|
|
||||||
- **Type**: API key
|
|
||||||
- **API key parameter name**: api_key_query
|
|
||||||
- **Location**: URL query string
|
|
||||||
|
|
||||||
<a id="http_basic_test"></a>
|
|
||||||
### http_basic_test
|
|
||||||
|
|
||||||
- **Type**: HTTP basic authentication
|
|
||||||
|
|
||||||
<a id="bearer_test"></a>
|
|
||||||
### bearer_test
|
|
||||||
|
|
||||||
- **Type**: HTTP bearer authentication
|
|
||||||
|
|
||||||
<a id="http_signature_test"></a>
|
|
||||||
### http_signature_test
|
|
||||||
|
|
||||||
- **Type**: HTTP signature authentication
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
|||||||
:: Generated by: https://github.com/openapitools/openapi-generator.git
|
|
||||||
::
|
|
||||||
|
|
||||||
@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://dist.nuget.org/win-x86-commandline/latest/nuget.exe', '.\nuget.exe')"
|
|
||||||
.\nuget.exe install src\Org.OpenAPITools\packages.config -o packages
|
|
||||||
|
|
||||||
if not exist ".\bin" mkdir bin
|
|
||||||
|
|
||||||
copy packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll bin\Newtonsoft.Json.dll
|
|
||||||
copy packages\JsonSubTypes.1.6.0\lib\net45\JsonSubTypes.dll bin\JsonSubTypes.dll
|
|
||||||
copy packages\RestSharp.105.1.0\lib\net45\RestSharp.dll bin\RestSharp.dll
|
|
||||||
%CSCPATH%\csc /reference:bin\Newtonsoft.Json.dll;bin\JsonSubTypes.dll;bin\RestSharp.dll;System.ComponentModel.DataAnnotations.dll /target:library /out:bin\Org.OpenAPITools.dll /recurse:src\Org.OpenAPITools\*.cs /doc:bin\Org.OpenAPITools.xml
|
|
@ -1,68 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# Generated by: https://github.com/openapitools/openapi-generator.git
|
|
||||||
#
|
|
||||||
|
|
||||||
frameworkVersion=net45
|
|
||||||
|
|
||||||
# sdk must match installed frameworks under PREFIX/lib/mono/[value]
|
|
||||||
sdk=4.5.2-api
|
|
||||||
|
|
||||||
# langversion refers to C# language features. see man mcs for details.
|
|
||||||
langversion=${sdk}
|
|
||||||
nuget_cmd=nuget
|
|
||||||
|
|
||||||
# Match against our known SDK possibilities
|
|
||||||
case "${sdk}" in
|
|
||||||
4)
|
|
||||||
langversion=4
|
|
||||||
;;
|
|
||||||
4.5*)
|
|
||||||
langversion=5
|
|
||||||
;;
|
|
||||||
4.6*)
|
|
||||||
langversion=6
|
|
||||||
;;
|
|
||||||
4.7*)
|
|
||||||
langversion=7 # ignoring 7.1 for now.
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
langversion=6
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "[INFO] Target framework: ${frameworkVersion}"
|
|
||||||
|
|
||||||
if ! type nuget &>/dev/null; then
|
|
||||||
echo "[INFO] Download nuget and packages"
|
|
||||||
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe;
|
|
||||||
nuget_cmd="mono nuget.exe"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mozroots --import --sync
|
|
||||||
${nuget_cmd} install src/Org.OpenAPITools/packages.config -o packages;
|
|
||||||
|
|
||||||
echo "[INFO] Copy DLLs to the 'bin' folder"
|
|
||||||
mkdir -p bin;
|
|
||||||
cp packages/Newtonsoft.Json.12.0.3/lib/net45/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll;
|
|
||||||
cp packages/RestSharp.105.1.0/lib/net45/RestSharp.dll bin/RestSharp.dll;
|
|
||||||
cp packages/JsonSubTypes.1.6.0/lib/net45/JsonSubTypes.dll bin/JsonSubTypes.dll
|
|
||||||
|
|
||||||
echo "[INFO] Run 'mcs' to build bin/Org.OpenAPITools.dll"
|
|
||||||
mcs -langversion:${langversion} -sdk:${sdk} -r:bin/Newtonsoft.Json.dll,bin/JsonSubTypes.dll,\
|
|
||||||
bin/RestSharp.dll,\
|
|
||||||
System.ComponentModel.DataAnnotations.dll,\
|
|
||||||
System.Runtime.Serialization.dll \
|
|
||||||
-target:library \
|
|
||||||
-out:bin/Org.OpenAPITools.dll \
|
|
||||||
-recurse:'src/Org.OpenAPITools/*.cs' \
|
|
||||||
-doc:bin/Org.OpenAPITools.xml \
|
|
||||||
-platform:anycpu
|
|
||||||
|
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
|
||||||
echo "[ERROR] Compilation failed with exit code $?"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "[INFO] bin/Org.OpenAPITools.dll was created successfully"
|
|
||||||
fi
|
|
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.AdditionalPropertiesAnyType
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**Name** | **string** | | [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)
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.AdditionalPropertiesArray
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**Name** | **string** | | [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)
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.AdditionalPropertiesBoolean
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**Name** | **string** | | [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)
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.AdditionalPropertiesClass
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**MapProperty** | **Dictionary<string, string>** | | [optional]
|
|
||||||
**MapOfMapProperty** | **Dictionary<string, Dictionary<string, string>>** | | [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)
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.AdditionalPropertiesInteger
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**Name** | **string** | | [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)
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.AdditionalPropertiesNumber
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**Name** | **string** | | [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)
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.AdditionalPropertiesObject
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**Name** | **string** | | [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)
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.AdditionalPropertiesString
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**Name** | **string** | | [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)
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.AllOfWithSingleRef
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**Username** | **string** | | [optional]
|
|
||||||
**SingleRefType** | **SingleRefType** | | [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)
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.Animal
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**ClassName** | **string** | |
|
|
||||||
**Color** | **string** | | [optional] [default to "red"]
|
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models)
|
|
||||||
[[Back to API list]](../README.md#documentation-for-api-endpoints)
|
|
||||||
[[Back to README]](../README.md)
|
|
||||||
|
|
@ -1,85 +0,0 @@
|
|||||||
# Org.OpenAPITools.Api.AnotherFakeApi
|
|
||||||
|
|
||||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
|
||||||
|
|
||||||
Method | HTTP request | Description
|
|
||||||
------------- | ------------- | -------------
|
|
||||||
[**Call123TestSpecialTags**](AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Call123TestSpecialTags
|
|
||||||
|
|
||||||
> ModelClient Call123TestSpecialTags (ModelClient modelClient)
|
|
||||||
|
|
||||||
To test special tags
|
|
||||||
|
|
||||||
To test special tags and operation ID starting with number
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using Org.OpenAPITools.Api;
|
|
||||||
using Org.OpenAPITools.Client;
|
|
||||||
using Org.OpenAPITools.Model;
|
|
||||||
|
|
||||||
namespace Example
|
|
||||||
{
|
|
||||||
public class Call123TestSpecialTagsExample
|
|
||||||
{
|
|
||||||
public static void Main()
|
|
||||||
{
|
|
||||||
Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
|
|
||||||
var apiInstance = new AnotherFakeApi(Configuration.Default);
|
|
||||||
var modelClient = new ModelClient(); // ModelClient | client model
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// To test special tags
|
|
||||||
ModelClient result = apiInstance.Call123TestSpecialTags(modelClient);
|
|
||||||
Debug.WriteLine(result);
|
|
||||||
}
|
|
||||||
catch (ApiException e)
|
|
||||||
{
|
|
||||||
Debug.Print("Exception when calling AnotherFakeApi.Call123TestSpecialTags: " + e.Message );
|
|
||||||
Debug.Print("Status Code: "+ e.ErrorCode);
|
|
||||||
Debug.Print(e.StackTrace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Parameters
|
|
||||||
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------- | ------------- | ------------- | -------------
|
|
||||||
**modelClient** | [**ModelClient**](ModelClient.md)| client model |
|
|
||||||
|
|
||||||
### Return type
|
|
||||||
|
|
||||||
[**ModelClient**](ModelClient.md)
|
|
||||||
|
|
||||||
### Authorization
|
|
||||||
|
|
||||||
No authorization required
|
|
||||||
|
|
||||||
### HTTP request headers
|
|
||||||
|
|
||||||
- **Content-Type**: application/json
|
|
||||||
- **Accept**: application/json
|
|
||||||
|
|
||||||
|
|
||||||
### HTTP response details
|
|
||||||
| Status code | Description | Response headers |
|
|
||||||
|-------------|-------------|------------------|
|
|
||||||
| **200** | successful operation | - |
|
|
||||||
|
|
||||||
[[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)
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.ApiResponse
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**Code** | **int** | | [optional]
|
|
||||||
**Type** | **string** | | [optional]
|
|
||||||
**Message** | **string** | | [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)
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.ArrayOfArrayOfNumberOnly
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**ArrayArrayNumber** | **List<List<decimal>>** | | [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)
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.ArrayOfNumberOnly
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**ArrayNumber** | **List<decimal>** | | [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)
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.ArrayTest
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**ArrayOfString** | **List<string>** | | [optional]
|
|
||||||
**ArrayArrayOfInteger** | **List<List<long>>** | | [optional]
|
|
||||||
**ArrayArrayOfModel** | **List<List<ReadOnlyFirst>>** | | [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)
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.BigCat
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**Declawed** | **bool** | | [optional]
|
|
||||||
**Kind** | **string** | | [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)
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.BigCatAllOf
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**Kind** | **string** | | [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)
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.Capitalization
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**SmallCamel** | **string** | | [optional]
|
|
||||||
**CapitalCamel** | **string** | | [optional]
|
|
||||||
**SmallSnake** | **string** | | [optional]
|
|
||||||
**CapitalSnake** | **string** | | [optional]
|
|
||||||
**SCAETHFlowPoints** | **string** | | [optional]
|
|
||||||
**ATT_NAME** | **string** | Name of the pet | [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)
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.Cat
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**ClassName** | **string** | |
|
|
||||||
**Color** | **string** | | [optional] [default to "red"]
|
|
||||||
**Declawed** | **bool** | | [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)
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.CatAllOf
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**Declawed** | **bool** | | [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)
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.Category
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**Id** | **long** | | [optional]
|
|
||||||
**Name** | **string** | | [default to "default-name"]
|
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models)
|
|
||||||
[[Back to API list]](../README.md#documentation-for-api-endpoints)
|
|
||||||
[[Back to README]](../README.md)
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
# Org.OpenAPITools.Model.ClassModel
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**VarClass** | **string** | | [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)
|
|
||||||
|
|
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