diff --git a/appveyor.yml b/appveyor.yml
index e14c8966489..f2fcac6c248 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -42,15 +42,6 @@ build_script:
## build C# API client (.net 5.0 with ConditionalSerialization)
#- 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 c# API client (multiple frameworks)
- 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
# test C# API Client using conditional-serialization
- 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
# generate all petstore clients
diff --git a/bin/configs/csharp-OpenAPIClient.yaml b/bin/configs/csharp-OpenAPIClient.yaml
deleted file mode 100644
index 5855eb4a350..00000000000
--- a/bin/configs/csharp-OpenAPIClient.yaml
+++ /dev/null
@@ -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}'
diff --git a/bin/configs/unmaintained/csharp-OpenAPIClientNet35.yaml b/bin/configs/unmaintained/csharp-OpenAPIClientNet35.yaml
deleted file mode 100644
index c308c2ceed9..00000000000
--- a/bin/configs/unmaintained/csharp-OpenAPIClientNet35.yaml
+++ /dev/null
@@ -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}'
diff --git a/bin/configs/unmaintained/csharp-OpenAPIClientNet40.yaml b/bin/configs/unmaintained/csharp-OpenAPIClientNet40.yaml
deleted file mode 100644
index bd5d7cf794e..00000000000
--- a/bin/configs/unmaintained/csharp-OpenAPIClientNet40.yaml
+++ /dev/null
@@ -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}'
diff --git a/bin/configs/unmaintained/csharp-OpenAPIClientNetCoreProject.yaml b/bin/configs/unmaintained/csharp-OpenAPIClientNetCoreProject.yaml
deleted file mode 100644
index e9fca548604..00000000000
--- a/bin/configs/unmaintained/csharp-OpenAPIClientNetCoreProject.yaml
+++ /dev/null
@@ -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"
diff --git a/bin/configs/unmaintained/csharp-OpenAPIClientNetStandard.yaml b/bin/configs/unmaintained/csharp-OpenAPIClientNetStandard.yaml
deleted file mode 100644
index b4f72b50b28..00000000000
--- a/bin/configs/unmaintained/csharp-OpenAPIClientNetStandard.yaml
+++ /dev/null
@@ -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}'
diff --git a/bin/configs/unmaintained/csharp-OpenAPIClientWithPropertyChanged.yaml b/bin/configs/unmaintained/csharp-OpenAPIClientWithPropertyChanged.yaml
deleted file mode 100644
index d5e7325510f..00000000000
--- a/bin/configs/unmaintained/csharp-OpenAPIClientWithPropertyChanged.yaml
+++ /dev/null
@@ -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"
diff --git a/docs/generators.md b/docs/generators.md
index c36524639d2..be5dbba7348 100644
--- a/docs/generators.md
+++ b/docs/generators.md
@@ -18,7 +18,6 @@ The following generators are available:
* [cpp-tizen](generators/cpp-tizen.md)
* [cpp-ue4 (beta)](generators/cpp-ue4.md)
* [crystal (beta)](generators/crystal.md)
-* [csharp](generators/csharp.md)
* [csharp-netcore](generators/csharp-netcore.md)
* [dart](generators/dart.md)
* [dart-dio](generators/dart-dio.md)
diff --git a/docs/generators/csharp.md b/docs/generators/csharp.md
deleted file mode 100644
index 54e15181d8b..00000000000
--- a/docs/generators/csharp.md
+++ /dev/null
@@ -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`|
- **v3.5**
- .NET Framework 3.5 compatible
- **v4.0**
- .NET Framework 4.0 compatible
- **v4.5**
- .NET Framework 4.5 compatible
- **v4.5.2**
- .NET Framework 4.5.2+ compatible
- **netstandard1.3**
- .NET Standard 1.3 compatible (DEPRECATED. Please use `csharp-netcore` generator instead)
- **uwp**
- Universal Windows Platform (DEPRECATED. Please use `csharp-netcore` generator instead)
|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
-
-
-- Boolean
-- Collection
-- DateTime
-- DateTime?
-- DateTimeOffset
-- DateTimeOffset?
-- Decimal
-- Dictionary
-- Double
-- Float
-- Guid
-- Guid?
-- ICollection
-- Int32
-- Int64
-- List
-- Object
-- String
-- System.IO.Stream
-- bool
-- bool?
-- byte[]
-- decimal
-- decimal?
-- double
-- double?
-- float
-- float?
-- int
-- int?
-- long
-- long?
-- string
-- uint
-- uint?
-- ulong
-- ulong?
-
-
-## RESERVED WORDS
-
-
-- Client
-- Configuration
-- Version
-- abstract
-- as
-- base
-- bool
-- break
-- byte
-- case
-- catch
-- char
-- checked
-- class
-- client
-- const
-- continue
-- decimal
-- default
-- delegate
-- do
-- double
-- else
-- enum
-- event
-- explicit
-- extern
-- false
-- finally
-- fixed
-- float
-- for
-- foreach
-- goto
-- if
-- implicit
-- in
-- int
-- interface
-- internal
-- is
-- localVarFileParams
-- localVarFormParams
-- localVarHeaderParams
-- localVarHttpContentType
-- localVarHttpContentTypes
-- localVarHttpHeaderAccept
-- localVarHttpHeaderAccepts
-- localVarPath
-- localVarPathParams
-- localVarPostBody
-- localVarQueryParams
-- localVarResponse
-- localVarStatusCode
-- lock
-- long
-- namespace
-- new
-- null
-- object
-- operator
-- out
-- override
-- parameter
-- params
-- private
-- protected
-- public
-- readonly
-- ref
-- return
-- sbyte
-- sealed
-- short
-- sizeof
-- stackalloc
-- static
-- string
-- struct
-- switch
-- this
-- throw
-- true
-- try
-- typeof
-- uint
-- ulong
-- unchecked
-- unsafe
-- ushort
-- using
-- virtual
-- void
-- volatile
-- while
-
-
-## 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
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
deleted file mode 100644
index 4960f7b9219..00000000000
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
+++ /dev/null
@@ -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 regexModifiers;
- protected final Map 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()
- .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();
- 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 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 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 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 modifiers = new ArrayList();
-
- // 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 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 parentModelCodegenProperties = parentCodegenModel.vars;
- List 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 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") + "";
- } 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;
- }
-}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java
index 18d16c858e1..33d8254d40f 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java
@@ -79,7 +79,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
protected static final String NET_70_OR_LATER = "net70OrLater";
@SuppressWarnings("hiding")
- private final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
+ private final Logger LOGGER = LoggerFactory.getLogger(CSharpNetCoreClientCodegen.class);
private static final List frameworkStrategies = Arrays.asList(
FrameworkStrategy.NETSTANDARD_1_3,
FrameworkStrategy.NETSTANDARD_1_4,
@@ -1309,7 +1309,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
@SuppressWarnings("Duplicates")
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") {
};
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreReducedClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreReducedClientCodegen.java
index b8ca9a1169e..5884aa99e48 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreReducedClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreReducedClientCodegen.java
@@ -60,7 +60,7 @@ public class CSharpNetCoreReducedClientCodegen extends AbstractCSharpCodegen {
protected static final String TARGET_FRAMEWORK_VERSION = "targetFrameworkVersion";
@SuppressWarnings("hiding")
- private final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
+ private final Logger LOGGER = LoggerFactory.getLogger(CSharpNetCoreReducedClientCodegen.class);
private static final List frameworkStrategies = Arrays.asList(
FrameworkStrategy.NETSTANDARD_1_3,
FrameworkStrategy.NETSTANDARD_1_4,
@@ -969,7 +969,7 @@ public class CSharpNetCoreReducedClientCodegen extends AbstractCSharpCodegen {
@SuppressWarnings("Duplicates")
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") {
};
diff --git a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig
index 504da19da17..ef5cea24b42 100644
--- a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig
+++ b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig
@@ -20,7 +20,6 @@ org.openapitools.codegen.languages.CppRestSdkClientCodegen
org.openapitools.codegen.languages.CppTinyClientCodegen
org.openapitools.codegen.languages.CppTizenClientCodegen
org.openapitools.codegen.languages.CppUE4ClientCodegen
-org.openapitools.codegen.languages.CSharpClientCodegen
org.openapitools.codegen.languages.CSharpNetCoreClientCodegen
org.openapitools.codegen.languages.CsharpNetcoreFunctionsServerCodegen
org.openapitools.codegen.languages.DartClientCodegen
diff --git a/modules/openapi-generator/src/main/resources/csharp-dotnet2/ApiClient.mustache b/modules/openapi-generator/src/main/resources/csharp-dotnet2/ApiClient.mustache
deleted file mode 100644
index ba509dd1558..00000000000
--- a/modules/openapi-generator/src/main/resources/csharp-dotnet2/ApiClient.mustache
+++ /dev/null
@@ -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}}
-{
- ///
- /// API client is mainly responsible for making the HTTP call to the API backend.
- ///
- public class ApiClient
- {
- private readonly Dictionary _defaultHeaderMap = new Dictionary();
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The base path.
- public ApiClient(String basePath="{{{basePath}}}")
- {
- BasePath = basePath;
- RestClient = new RestClient(BasePath);
- }
-
- ///
- /// Gets or sets the base path.
- ///
- /// The base path
- public string BasePath { get; set; }
-
- ///
- /// Gets or sets the RestClient.
- ///
- /// An instance of the RestClient
- public RestClient RestClient { get; set; }
-
- ///
- /// Gets the default header.
- ///
- public Dictionary DefaultHeader
- {
- get { return _defaultHeaderMap; }
- }
-
- ///
- /// Makes the HTTP request (Sync).
- ///
- /// URL path.
- /// HTTP method.
- /// Query parameters.
- /// HTTP body (POST request).
- /// Header parameters.
- /// Form parameters.
- /// File parameters.
- /// Authentication settings.
- /// Object
- public Object CallApi(String path, RestSharp.Method method, Dictionary queryParams, String postBody,
- Dictionary headerParams, Dictionary formParams,
- Dictionary 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);
-
- }
-
- ///
- /// Add default header.
- ///
- /// Header field name.
- /// Header field value.
- ///
- public void AddDefaultHeader(string key, string value)
- {
- _defaultHeaderMap.Add(key, value);
- }
-
- ///
- /// Escape string (url-encoded).
- ///
- /// String to be escaped.
- /// Escaped string.
- public string EscapeString(string str)
- {
- return RestSharp.Contrib.HttpUtility.UrlEncode(str);
- }
-
- ///
- /// Create FileParameter based on Stream.
- ///
- /// Parameter name.
- /// Input stream.
- /// FileParameter.
- 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");
- }
-
- ///
- /// 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.
- ///
- /// The parameter (header, path, query, form).
- /// Formatted string.
- 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)
- return String.Join(",", (obj as List).ToArray());
- else
- return Convert.ToString (obj);
- }
-
- ///
- /// Deserialize the JSON string into a proper object.
- ///
- /// HTTP body (e.g. string, JSON).
- /// Object type.
- /// HTTP headers.
- /// Object representation of the JSON string.
- public object Deserialize(string content, Type type, IList 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);
- }
- }
-
- ///
- /// Serialize an object into JSON string.
- ///
- /// Object.
- /// JSON string.
- public string Serialize(object obj)
- {
- try
- {
- return obj != null ? JsonConvert.SerializeObject(obj) : null;
- }
- catch (Exception e)
- {
- throw new ApiException(500, e.Message);
- }
- }
-
- ///
- /// Get the API key with prefix.
- ///
- /// API key identifier (authentication scheme).
- /// API key with prefix.
- 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;
- }
-
- ///
- /// Update parameters based on authentication.
- ///
- /// Query parameters.
- /// Header parameters.
- /// Authentication settings.
- public void UpdateParamsForAuth(Dictionary queryParams, Dictionary 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;
- }
- }
- }
-
- ///
- /// Encode string in base64 format.
- ///
- /// String to be encoded.
- /// Encoded string.
- public static string Base64Encode(string text)
- {
- var textByte = System.Text.Encoding.UTF8.GetBytes(text);
- return System.Convert.ToBase64String(textByte);
- }
-
- ///
- /// Dynamically cast the object into target type.
- ///
- /// Object to be casted
- /// Target type
- /// Casted object
- public static Object ConvertType(Object fromObject, Type toObject) {
- return Convert.ChangeType(fromObject, toObject);
- }
-
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/csharp-dotnet2/ApiException.mustache b/modules/openapi-generator/src/main/resources/csharp-dotnet2/ApiException.mustache
deleted file mode 100644
index 1bc6d7c5a6f..00000000000
--- a/modules/openapi-generator/src/main/resources/csharp-dotnet2/ApiException.mustache
+++ /dev/null
@@ -1,47 +0,0 @@
-using System;
-
-namespace {{clientPackage}} {
- ///
- /// API Exception
- ///
- public class ApiException : Exception {
- ///
- /// Gets or sets the error code (HTTP status code)
- ///
- /// The error code (HTTP status code).
- public int ErrorCode { get; set; }
-
- ///
- /// Gets or sets the error content (body json object)
- ///
- /// The error content (Http response body).
- public Object ErrorContent { get; private set; }
-
- ///
- /// Initializes a new instance of the class.
- ///
- public ApiException() {}
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// HTTP status code.
- /// Error message.
- public ApiException(int errorCode, string message) : base(message) {
- this.ErrorCode = errorCode;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// HTTP status code.
- /// Error message.
- /// Error content.
- public ApiException(int errorCode, string message, Object errorContent = null) : base(message) {
- this.ErrorCode = errorCode;
- this.ErrorContent = errorContent;
- }
-
- }
-
-}
diff --git a/modules/openapi-generator/src/main/resources/csharp-dotnet2/Configuration.mustache b/modules/openapi-generator/src/main/resources/csharp-dotnet2/Configuration.mustache
deleted file mode 100644
index 6c0e9a58ad8..00000000000
--- a/modules/openapi-generator/src/main/resources/csharp-dotnet2/Configuration.mustache
+++ /dev/null
@@ -1,138 +0,0 @@
-using System;
-using System.Reflection;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-
-namespace {{clientPackage}}
-{
- ///
- /// Represents a set of configuration settings
- ///
- public class Configuration
- {
-
- ///
- /// Version of the package.
- ///
- /// Version of the package.
- public const string Version = "{{packageVersion}}";
-
- ///
- /// Gets or sets the default API client for making HTTP calls.
- ///
- /// The API client.
- public static ApiClient DefaultApiClient = new ApiClient();
-
- ///
- /// Gets or sets the username (HTTP basic authentication).
- ///
- /// The username.
- public static String Username { get; set; }
-
- ///
- /// Gets or sets the password (HTTP basic authentication).
- ///
- /// The password.
- public static String Password { get; set; }
-
- ///
- /// Gets or sets the access token (Bearer/OAuth authentication).
- ///
- /// The access token.
- public static String AccessToken { get; set; }
-
- ///
- /// Gets or sets the API key based on the authentication name.
- ///
- /// The API key.
- public static Dictionary ApiKey = new Dictionary();
-
- ///
- /// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name.
- ///
- /// The prefix of the API key.
- public static Dictionary ApiKeyPrefix = new Dictionary();
-
- private static string _tempFolderPath = Path.GetTempPath();
-
- ///
- /// Gets or sets the temporary folder path to store the files downloaded from the server.
- ///
- /// Folder path.
- 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;
-
- ///
- /// 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
- ///
- /// The DateTimeFormat string
- 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;
- }
- }
-
- ///
- /// Returns a string with essential information for debugging.
- ///
- 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;
- }
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/csharp-dotnet2/README.mustache b/modules/openapi-generator/src/main/resources/csharp-dotnet2/README.mustache
deleted file mode 100644
index 12f4b1932eb..00000000000
--- a/modules/openapi-generator/src/main/resources/csharp-dotnet2/README.mustache
+++ /dev/null
@@ -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}}
-
-
-## Frameworks supported
-- .NET 2.0
-
-
-## 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
-
-
-## 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}};
-```
-
-## 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}}
-```
-
-
-## 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}}
-
-
-## Documentation for Authorization
-
-{{^authMethods}}Endpoints do not require authorization.{{/authMethods}}
-{{#hasAuthMethods}}Authentication schemes defined for the API:{{/hasAuthMethods}}
-{{#authMethods}}
-
-### {{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}}
diff --git a/modules/openapi-generator/src/main/resources/csharp-dotnet2/api.mustache b/modules/openapi-generator/src/main/resources/csharp-dotnet2/api.mustache
deleted file mode 100644
index 40e59a1ffb6..00000000000
--- a/modules/openapi-generator/src/main/resources/csharp-dotnet2/api.mustache
+++ /dev/null
@@ -1,135 +0,0 @@
-using System;
-using System.Collections.Generic;
-using RestSharp;
-using {{clientPackage}};
-{{#hasImport}}using {{modelPackage}};
-{{/hasImport}}
-
-namespace {{apiPackage}}
-{
- {{#operations}}
- ///
- /// Represents a collection of functions to interact with the API endpoints
- ///
- public interface I{{classname}}
- {
- {{#operation}}
- ///
- /// {{summary}} {{notes}}
- ///
- {{#allParams}}/// {{description}}{{#isDeprecated}} (deprecated){{/isDeprecated}}
- {{/allParams}}/// {{returnType}}
- {{#isDeprecated}}
- [Obsolete]
- {{/isDeprecated}}
- {{{returnType}}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
- {{/operation}}
- }
-
- ///
- /// Represents a collection of functions to interact with the API endpoints
- ///
- public class {{classname}} : I{{classname}}
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// an instance of ApiClient (optional)
- ///
- public {{classname}}(ApiClient apiClient = null)
- {
- if (apiClient == null) // use the default one in Configuration
- this.ApiClient = Configuration.DefaultApiClient;
- else
- this.ApiClient = apiClient;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- ///
- public {{classname}}(String basePath)
- {
- this.ApiClient = new ApiClient(basePath);
- }
-
- ///
- /// Sets the base path of the API client.
- ///
- /// The base path
- /// The base path
- public void SetBasePath(String basePath)
- {
- this.ApiClient.BasePath = basePath;
- }
-
- ///
- /// Gets the base path of the API client.
- ///
- /// The base path
- /// The base path
- public String GetBasePath(String basePath)
- {
- return this.ApiClient.BasePath;
- }
-
- ///
- /// Gets or sets the API client.
- ///
- /// An instance of the ApiClient
- public ApiClient ApiClient {get; set;}
-
- {{#operation}}
- ///
- /// {{summary}} {{notes}}
- ///
- {{#allParams}}/// {{description}}{{#isDeprecated}} (deprecated){{/isDeprecated}}
- {{/allParams}}/// {{returnType}}
- {{#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();
- var headerParams = new Dictionary();
- var formParams = new Dictionary();
- var fileParams = new Dictionary();
- 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}}
-}
diff --git a/modules/openapi-generator/src/main/resources/csharp-dotnet2/api_doc.mustache b/modules/openapi-generator/src/main/resources/csharp-dotnet2/api_doc.mustache
deleted file mode 100644
index 39540efe2a2..00000000000
--- a/modules/openapi-generator/src/main/resources/csharp-dotnet2/api_doc.mustache
+++ /dev/null
@@ -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}}
-
-# **{{{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}}
diff --git a/modules/openapi-generator/src/main/resources/csharp-dotnet2/compile-mono.sh.mustache b/modules/openapi-generator/src/main/resources/csharp-dotnet2/compile-mono.sh.mustache
deleted file mode 100644
index 2287344892a..00000000000
--- a/modules/openapi-generator/src/main/resources/csharp-dotnet2/compile-mono.sh.mustache
+++ /dev/null
@@ -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
diff --git a/modules/openapi-generator/src/main/resources/csharp-dotnet2/gitignore b/modules/openapi-generator/src/main/resources/csharp-dotnet2/gitignore
deleted file mode 100644
index 1ee53850b84..00000000000
--- a/modules/openapi-generator/src/main/resources/csharp-dotnet2/gitignore
+++ /dev/null
@@ -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
diff --git a/modules/openapi-generator/src/main/resources/csharp-dotnet2/model.mustache b/modules/openapi-generator/src/main/resources/csharp-dotnet2/model.mustache
deleted file mode 100644
index 4a642e80e42..00000000000
--- a/modules/openapi-generator/src/main/resources/csharp-dotnet2/model.mustache
+++ /dev/null
@@ -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}} {
-
- ///
- /// {{description}}
- ///
- [DataContract]
- public class {{classname}}{{#parent}} : {{{.}}}{{/parent}} {
- {{#vars}}
- ///
- /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{{description}}}
- /// {{#description}}
- /// {{{.}}}{{/description}}
- [DataMember(Name="{{baseName}}", EmitDefaultValue=false)]
- [JsonProperty(PropertyName = "{{baseName}}")]
- {{#deprecated}}
- [Obsolete]
- {{/deprecated}}
- public {{{dataType}}} {{name}} { get; set; }
-
- {{/vars}}
-
- ///
- /// Get the string presentation of the object
- ///
- /// String presentation of the object
- 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();
- }
-
- ///
- /// Get the JSON string presentation of the object
- ///
- /// JSON string presentation of the object
- public {{#parent}} new {{/parent}}string ToJson() {
- return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
- }
-
-}
-{{/model}}
-{{/models}}
-}
diff --git a/modules/openapi-generator/src/main/resources/csharp-dotnet2/model_doc.mustache b/modules/openapi-generator/src/main/resources/csharp-dotnet2/model_doc.mustache
deleted file mode 100644
index e6f7f2c9b83..00000000000
--- a/modules/openapi-generator/src/main/resources/csharp-dotnet2/model_doc.mustache
+++ /dev/null
@@ -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}}
diff --git a/modules/openapi-generator/src/main/resources/csharp-dotnet2/packages.config.mustache b/modules/openapi-generator/src/main/resources/csharp-dotnet2/packages.config.mustache
deleted file mode 100644
index 7b9cf186303..00000000000
--- a/modules/openapi-generator/src/main/resources/csharp-dotnet2/packages.config.mustache
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/csharp/ApiClient.mustache b/modules/openapi-generator/src/main/resources/csharp/ApiClient.mustache
deleted file mode 100644
index 3b8529e9a75..00000000000
--- a/modules/openapi-generator/src/main/resources/csharp/ApiClient.mustache
+++ /dev/null
@@ -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
-{
- ///
- /// API client is mainly responsible for making the HTTP call to the API backend.
- ///
- {{>visibility}} partial class ApiClient
- {
- public JsonSerializerSettings serializerSettings = new JsonSerializerSettings
- {
- ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor
- };
-
- ///
- /// Allows for extending request processing for generated code.
- ///
- /// The RestSharp request object
- partial void InterceptRequest(IRestRequest request);
-
- ///
- /// Allows for extending response processing for generated code.
- ///
- /// The RestSharp request object
- /// The RestSharp response object
- partial void InterceptResponse(IRestRequest request, IRestResponse response);
-
- ///
- /// Initializes a new instance of the class
- /// with default configuration.
- ///
- public ApiClient()
- {
- Configuration = {{packageName}}.Client.Configuration.Default;
- RestClient = new RestClient("{{{basePath}}}");
- {{#netStandard}}
- RestClient.IgnoreResponseStatusCode = true;
- {{/netStandard}}
- }
-
- ///
- /// Initializes a new instance of the class
- /// with default base path ({{{basePath}}}).
- ///
- /// An instance of Configuration.
- public ApiClient(Configuration config)
- {
- Configuration = config ?? {{packageName}}.Client.Configuration.Default;
-
- RestClient = new RestClient(Configuration.BasePath);
- {{#netStandard}}
- RestClient.IgnoreResponseStatusCode = true;
- {{/netStandard}}
- }
-
- ///
- /// Initializes a new instance of the class
- /// with default configuration.
- ///
- /// The base path.
- 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;
- }
-
- ///
- /// Gets or sets the default API client for making HTTP calls.
- ///
- /// The default API client.
- [Obsolete("ApiClient.Default is deprecated, please use 'Configuration.Default.ApiClient' instead.")]
- public static ApiClient Default;
-
- ///
- /// Gets or sets an instance of the IReadableConfiguration.
- ///
- /// An instance of the IReadableConfiguration.
- ///
- /// helps us to avoid modifying possibly global
- /// configuration values from within a given client. It does not guarantee thread-safety
- /// of the instance in any way.
- ///
- public IReadableConfiguration Configuration { get; set; }
-
- ///
- /// Gets or sets the RestClient.
- ///
- /// An instance of the RestClient
- 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> queryParams, Object postBody,
- Dictionary headerParams, Dictionary formParams,
- Dictionary fileParams, Dictionary 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;
- }
-
- ///
- /// Makes the HTTP request (Sync).
- ///
- /// URL path.
- /// HTTP method.
- /// Query parameters.
- /// HTTP body (POST request).
- /// Header parameters.
- /// Form parameters.
- /// File parameters.
- /// Path parameters.
- /// Content Type of the request
- /// Object
- public Object CallApi(
- String path, {{^netStandard}}RestSharp.{{/netStandard}}Method method, List> queryParams, Object postBody,
- Dictionary headerParams, Dictionary formParams,
- Dictionary fileParams, Dictionary 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}}
- ///
- /// Makes the asynchronous HTTP request.
- ///
- /// URL path.
- /// HTTP method.
- /// Query parameters.
- /// HTTP body (POST request).
- /// Header parameters.
- /// Form parameters.
- /// File parameters.
- /// Path parameters.
- /// Content type.
- /// Cancellation Token.
- /// The Task instance.
- public async System.Threading.Tasks.Task