fix warning in cref for list (#12096)

This commit is contained in:
William Cheng 2022-04-10 09:37:09 +08:00 committed by GitHub
parent 4374a63a4c
commit 4e82b74cd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 24 additions and 9 deletions

View File

@ -19,6 +19,8 @@ package org.openapitools.codegen.languages;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache.Lambda; 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.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
@ -36,6 +38,7 @@ import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.Writer;
import java.util.*; import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize; 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. // This either updates additionalProperties with the above fixes, or sets the default if the option was not specified.
additionalProperties.put(CodegenConstants.INTERFACE_PREFIX, interfacePrefix); 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 @Override

View File

@ -19,7 +19,7 @@
{{#anyOf}} {{#anyOf}}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="{{classname}}" /> class /// Initializes a new instance of the <see cref="{{classname}}" /> class
/// with the <see cref="{{{.}}}" /> class /// with the <see cref="{{#lambdaCref}}{{{.}}}{{/lambdaCref}}" /> class
/// </summary> /// </summary>
/// <param name="actualInstance">An instance of {{{.}}}.</param> /// <param name="actualInstance">An instance of {{{.}}}.</param>
public {{classname}}({{{.}}} actualInstance) public {{classname}}({{{.}}} actualInstance)

View File

@ -21,7 +21,7 @@
{{^isNull}} {{^isNull}}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="{{classname}}" /> class /// 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> /// </summary>
/// <param name="actualInstance">An instance of {{dataType}}.</param> /// <param name="actualInstance">An instance of {{dataType}}.</param>
public {{classname}}({{{dataType}}} actualInstance) public {{classname}}({{{dataType}}} actualInstance)

View File

@ -72,7 +72,7 @@ namespace Org.OpenAPITools.Model
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class /// Initializes a new instance of the <see cref="PolymorphicProperty" /> class
/// with the <see cref="List&lt;string&gt;" /> class /// with the <see cref="List{String}" /> class
/// </summary> /// </summary>
/// <param name="actualInstance">An instance of List&lt;string&gt;.</param> /// <param name="actualInstance">An instance of List&lt;string&gt;.</param>
public PolymorphicProperty(List<string> actualInstance) public PolymorphicProperty(List<string> actualInstance)

View File

@ -73,7 +73,7 @@ namespace Org.OpenAPITools.Model
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class /// Initializes a new instance of the <see cref="PolymorphicProperty" /> class
/// with the <see cref="List&lt;string&gt;" /> class /// with the <see cref="List{String}" /> class
/// </summary> /// </summary>
/// <param name="actualInstance">An instance of List&lt;string&gt;.</param> /// <param name="actualInstance">An instance of List&lt;string&gt;.</param>
public PolymorphicProperty(List<string> actualInstance) public PolymorphicProperty(List<string> actualInstance)

View File

@ -72,7 +72,7 @@ namespace Org.OpenAPITools.Model
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class /// Initializes a new instance of the <see cref="PolymorphicProperty" /> class
/// with the <see cref="List&lt;string&gt;" /> class /// with the <see cref="List{String}" /> class
/// </summary> /// </summary>
/// <param name="actualInstance">An instance of List&lt;string&gt;.</param> /// <param name="actualInstance">An instance of List&lt;string&gt;.</param>
public PolymorphicProperty(List<string> actualInstance) public PolymorphicProperty(List<string> actualInstance)

View File

@ -72,7 +72,7 @@ namespace Org.OpenAPITools.Model
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class /// Initializes a new instance of the <see cref="PolymorphicProperty" /> class
/// with the <see cref="List&lt;string&gt;" /> class /// with the <see cref="List{String}" /> class
/// </summary> /// </summary>
/// <param name="actualInstance">An instance of List&lt;string&gt;.</param> /// <param name="actualInstance">An instance of List&lt;string&gt;.</param>
public PolymorphicProperty(List<string> actualInstance) public PolymorphicProperty(List<string> actualInstance)

View File

@ -72,7 +72,7 @@ namespace Org.OpenAPITools.Model
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class /// Initializes a new instance of the <see cref="PolymorphicProperty" /> class
/// with the <see cref="List&lt;string&gt;" /> class /// with the <see cref="List{String}" /> class
/// </summary> /// </summary>
/// <param name="actualInstance">An instance of List&lt;string&gt;.</param> /// <param name="actualInstance">An instance of List&lt;string&gt;.</param>
public PolymorphicProperty(List<string> actualInstance) public PolymorphicProperty(List<string> actualInstance)

View File

@ -72,7 +72,7 @@ namespace Org.OpenAPITools.Model
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PolymorphicProperty" /> class /// Initializes a new instance of the <see cref="PolymorphicProperty" /> class
/// with the <see cref="List&lt;string&gt;" /> class /// with the <see cref="List{String}" /> class
/// </summary> /// </summary>
/// <param name="actualInstance">An instance of List&lt;string&gt;.</param> /// <param name="actualInstance">An instance of List&lt;string&gt;.</param>
public PolymorphicProperty(List<string> actualInstance) public PolymorphicProperty(List<string> actualInstance)