forked from loafle/openapi-generator-original
Updated mustache templates, generator and docs (#12848)
This commit is contained in:
parent
83473eb735
commit
d2294d2eca
@ -41,6 +41,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|packageName|C# package name (convention: Title.Case).| |Org.OpenAPITools|
|
||||
|packageTitle|Specifies an AssemblyTitle for the .NET Framework global assembly attributes stored in the AssemblyInfo file.| |OpenAPI Library|
|
||||
|packageVersion|C# package version.| |1.0.0|
|
||||
|pocoModels|Build POCO Models| |false|
|
||||
|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|
|
||||
|
@ -43,6 +43,7 @@ import static java.util.UUID.randomUUID;
|
||||
public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
|
||||
public static final String USE_SWASHBUCKLE = "useSwashbuckle";
|
||||
public static final String MODEL_POCOMODE = "pocoModels";
|
||||
public static final String ASPNET_CORE_VERSION = "aspnetCoreVersion";
|
||||
public static final String SWASHBUCKLE_VERSION = "swashbuckleVersion";
|
||||
public static final String CLASS_MODIFIER = "classModifier";
|
||||
@ -70,6 +71,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
protected final Logger LOGGER = LoggerFactory.getLogger(AspNetCoreServerCodegen.class);
|
||||
|
||||
private boolean useSwashbuckle = true;
|
||||
private boolean pocoModels = false;
|
||||
protected int serverPort = 8080;
|
||||
protected String serverHost = "0.0.0.0";
|
||||
protected CliOption swashbuckleVersion = new CliOption(SWASHBUCKLE_VERSION, "Swashbuckle version: 3.0.0, 4.0.0, 5.0.0, 6.0.0");
|
||||
@ -238,6 +240,10 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
"Uses the Swashbuckle.AspNetCore NuGet package for documentation.",
|
||||
useSwashbuckle);
|
||||
|
||||
addSwitch(MODEL_POCOMODE,
|
||||
"Build POCO Models",
|
||||
pocoModels);
|
||||
|
||||
addSwitch(IS_LIBRARY,
|
||||
"Is the build a library",
|
||||
isLibrary);
|
||||
@ -360,6 +366,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
setClassModifier();
|
||||
setOperationModifier();
|
||||
setModelClassModifier();
|
||||
setPocoModels();
|
||||
setUseSwashbuckle();
|
||||
setOperationIsAsync();
|
||||
|
||||
@ -656,6 +663,14 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
private void setPocoModels() {
|
||||
if (additionalProperties.containsKey(MODEL_POCOMODE)) {
|
||||
pocoModels = convertPropertyToBooleanAndWriteBack(MODEL_POCOMODE);
|
||||
} else {
|
||||
additionalProperties.put(MODEL_POCOMODE, pocoModels);
|
||||
}
|
||||
}
|
||||
|
||||
private void setUseSwashbuckle() {
|
||||
if (isLibrary) {
|
||||
LOGGER.warn("isLibrary is true so changing default useSwashbuckle to false");
|
||||
|
@ -15,7 +15,7 @@ namespace {{packageName}}.Models
|
||||
/// {{description}}
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public partial class {{classname}} : {{#parent}}{{{.}}}, {{/parent}}IEquatable<{{classname}}>
|
||||
public partial class {{classname}} {{#parent}}: {{{.}}}{{^pocoModels}}, {{/pocoModels}}{{/parent}}{{^pocoModels}}{{^parent}}: {{/parent}}IEquatable<{{classname}}>{{/pocoModels}}
|
||||
{
|
||||
{{#vars}}
|
||||
{{#items.isEnum}}
|
||||
|
@ -17,7 +17,7 @@ namespace {{modelPackage}}
|
||||
/// {{description}}
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public {{#modelClassModifier}}{{.}} {{/modelClassModifier}}class {{classname}} : {{#parent}}{{{.}}}, {{/parent}}IEquatable<{{classname}}>
|
||||
public {{#modelClassModifier}}{{.}} {{/modelClassModifier}}class {{classname}} {{#parent}}: {{{.}}}{{^pocoModels}}, {{/pocoModels}}{{/parent}}{{^pocoModels}}{{^parent}}: {{/parent}}IEquatable<{{classname}}>{{/pocoModels}}
|
||||
{
|
||||
{{#vars}}
|
||||
{{#items.isEnum}}
|
||||
|
@ -30,7 +30,7 @@ namespace {{modelPackage}}
|
||||
[JsonSubtypes.KnownSubType(typeof({{{modelName}}}), "{{^vendorExtensions.x-discriminator-value}}{{{mappingName}}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{.}}}{{/vendorExtensions.x-discriminator-value}}")]
|
||||
{{/mappedModels}}
|
||||
{{/discriminator}}
|
||||
public {{#modelClassModifier}}{{.}} {{/modelClassModifier}}class {{classname}} : {{#parent}}{{{.}}}, {{/parent}}IEquatable<{{classname}}>
|
||||
public {{#modelClassModifier}}{{.}} {{/modelClassModifier}}class {{classname}} {{#parent}}: {{{.}}}{{^pocoModels}}, {{/pocoModels}}{{/parent}}{{^pocoModels}}{{^parent}}: {{/parent}}IEquatable<{{classname}}>{{/pocoModels}}
|
||||
{
|
||||
{{#vars}}
|
||||
{{#items.isEnum}}
|
||||
@ -67,6 +67,7 @@ namespace {{modelPackage}}
|
||||
{{/-last}}
|
||||
{{/vars}}
|
||||
|
||||
{{^pocoModels}}
|
||||
/// <summary>
|
||||
/// Returns the string presentation of the object
|
||||
/// </summary>
|
||||
@ -160,6 +161,7 @@ namespace {{modelPackage}}
|
||||
|
||||
#pragma warning restore 1591
|
||||
#endregion Operators
|
||||
{{/pocoModels}}
|
||||
}
|
||||
{{/isEnum}}
|
||||
{{/model}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user