diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java index c0c24b50e4e7ebf403efbaf0b21185289ab3a844..bc39b898fa8f72fa007aaf2ff278e5409c3ae812 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java @@ -19,6 +19,8 @@ package org.openapitools.codegen.languages; import com.google.common.collect.ImmutableMap; import com.samskivert.mustache.Mustache.Lambda; +import com.samskivert.mustache.Mustache; +import com.samskivert.mustache.Template; import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.Schema; @@ -36,6 +38,7 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; +import java.io.Writer; import java.util.*; import static org.openapitools.codegen.utils.StringUtils.camelize; @@ -399,6 +402,18 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co // This either updates additionalProperties with the above fixes, or sets the default if the option was not specified. additionalProperties.put(CodegenConstants.INTERFACE_PREFIX, interfacePrefix); + + // add lambda for mustache templates + additionalProperties.put("lambdaCref", new Mustache.Lambda() { + @Override + public void execute(Template.Fragment fragment, Writer writer) throws IOException { + String content = fragment.execute(); + content = content.trim().replace("<", "{"); + content = content.replace(">", "}"); + content = content.replace("{string}", "{String}"); + writer.write(content); + } + }); } @Override diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/modelAnyOf.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/modelAnyOf.mustache index f216a991130956434a0adf1024230af6cbf61c93..d889a3e1fda681f8e0bc44d0e9b5b109eecb1415 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/modelAnyOf.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/modelAnyOf.mustache @@ -19,7 +19,7 @@ {{#anyOf}} /// <summary> /// Initializes a new instance of the <see cref="{{classname}}" /> class - /// with the <see cref="{{{.}}}" /> class + /// with the <see cref="{{#lambdaCref}}{{{.}}}{{/lambdaCref}}" /> class /// </summary> /// <param name="actualInstance">An instance of {{{.}}}.</param> public {{classname}}({{{.}}} actualInstance) diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/modelOneOf.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/modelOneOf.mustache index 2a22ad4925990789b51851303c83c3c9b1d9fd31..272b6cf93181922c83366e5e9488d583a171d668 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/modelOneOf.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/modelOneOf.mustache @@ -21,7 +21,7 @@ {{^isNull}} /// <summary> /// Initializes a new instance of the <see cref="{{classname}}" /> class - /// with the <see cref="{{dataType}}" /> class + /// with the <see cref="{{#lambdaCref}}{{{dataType}}}{{/lambdaCref}}" /> class /// </summary> /// <param name="actualInstance">An instance of {{dataType}}.</param> public {{classname}}({{{dataType}}} actualInstance) @@ -277,4 +277,4 @@ return false; } } -{{/model}} \ No newline at end of file +{{/model}} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 553857009b32cb45ecd647800920b94f892f214f..0ce4e18eb2eacc2bc5f2489ca91f2c28b71766be 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -72,7 +72,7 @@ namespace Org.OpenAPITools.Model /// <summary> /// Initializes a new instance of the <see cref="PolymorphicProperty" /> class - /// with the <see cref="List<string>" /> class + /// with the <see cref="List{String}" /> class /// </summary> /// <param name="actualInstance">An instance of List<string>.</param> public PolymorphicProperty(List<string> actualInstance) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 383dcdde8594b09ed60c09c3c9dec069b79905d0..4e8c938e2e97056bc8d1d49383c7c3cab6d2110d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -73,7 +73,7 @@ namespace Org.OpenAPITools.Model /// <summary> /// Initializes a new instance of the <see cref="PolymorphicProperty" /> class - /// with the <see cref="List<string>" /> class + /// with the <see cref="List{String}" /> class /// </summary> /// <param name="actualInstance">An instance of List<string>.</param> public PolymorphicProperty(List<string> actualInstance) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 553857009b32cb45ecd647800920b94f892f214f..0ce4e18eb2eacc2bc5f2489ca91f2c28b71766be 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -72,7 +72,7 @@ namespace Org.OpenAPITools.Model /// <summary> /// Initializes a new instance of the <see cref="PolymorphicProperty" /> class - /// with the <see cref="List<string>" /> class + /// with the <see cref="List{String}" /> class /// </summary> /// <param name="actualInstance">An instance of List<string>.</param> public PolymorphicProperty(List<string> actualInstance) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 553857009b32cb45ecd647800920b94f892f214f..0ce4e18eb2eacc2bc5f2489ca91f2c28b71766be 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -72,7 +72,7 @@ namespace Org.OpenAPITools.Model /// <summary> /// Initializes a new instance of the <see cref="PolymorphicProperty" /> class - /// with the <see cref="List<string>" /> class + /// with the <see cref="List{String}" /> class /// </summary> /// <param name="actualInstance">An instance of List<string>.</param> public PolymorphicProperty(List<string> actualInstance) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 553857009b32cb45ecd647800920b94f892f214f..0ce4e18eb2eacc2bc5f2489ca91f2c28b71766be 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -72,7 +72,7 @@ namespace Org.OpenAPITools.Model /// <summary> /// Initializes a new instance of the <see cref="PolymorphicProperty" /> class - /// with the <see cref="List<string>" /> class + /// with the <see cref="List{String}" /> class /// </summary> /// <param name="actualInstance">An instance of List<string>.</param> public PolymorphicProperty(List<string> actualInstance) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 553857009b32cb45ecd647800920b94f892f214f..0ce4e18eb2eacc2bc5f2489ca91f2c28b71766be 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -72,7 +72,7 @@ namespace Org.OpenAPITools.Model /// <summary> /// Initializes a new instance of the <see cref="PolymorphicProperty" /> class - /// with the <see cref="List<string>" /> class + /// with the <see cref="List{String}" /> class /// </summary> /// <param name="actualInstance">An instance of List<string>.</param> public PolymorphicProperty(List<string> actualInstance)