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|
|
|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|
|
|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|
|
|packageVersion|C# package version.| |1.0.0|
|
||||||
|
|pocoModels|Build POCO Models| |false|
|
||||||
|returnICollection|Return ICollection<T> instead of the concrete type.| |false|
|
|returnICollection|Return ICollection<T> instead of the concrete type.| |false|
|
||||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||||
|sourceFolder|source folder for generated code| |src|
|
|sourceFolder|source folder for generated code| |src|
|
||||||
|
@ -43,6 +43,7 @@ import static java.util.UUID.randomUUID;
|
|||||||
public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||||
|
|
||||||
public static final String USE_SWASHBUCKLE = "useSwashbuckle";
|
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 ASPNET_CORE_VERSION = "aspnetCoreVersion";
|
||||||
public static final String SWASHBUCKLE_VERSION = "swashbuckleVersion";
|
public static final String SWASHBUCKLE_VERSION = "swashbuckleVersion";
|
||||||
public static final String CLASS_MODIFIER = "classModifier";
|
public static final String CLASS_MODIFIER = "classModifier";
|
||||||
@ -70,6 +71,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
|||||||
protected final Logger LOGGER = LoggerFactory.getLogger(AspNetCoreServerCodegen.class);
|
protected final Logger LOGGER = LoggerFactory.getLogger(AspNetCoreServerCodegen.class);
|
||||||
|
|
||||||
private boolean useSwashbuckle = true;
|
private boolean useSwashbuckle = true;
|
||||||
|
private boolean pocoModels = false;
|
||||||
protected int serverPort = 8080;
|
protected int serverPort = 8080;
|
||||||
protected String serverHost = "0.0.0.0";
|
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");
|
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.",
|
"Uses the Swashbuckle.AspNetCore NuGet package for documentation.",
|
||||||
useSwashbuckle);
|
useSwashbuckle);
|
||||||
|
|
||||||
|
addSwitch(MODEL_POCOMODE,
|
||||||
|
"Build POCO Models",
|
||||||
|
pocoModels);
|
||||||
|
|
||||||
addSwitch(IS_LIBRARY,
|
addSwitch(IS_LIBRARY,
|
||||||
"Is the build a library",
|
"Is the build a library",
|
||||||
isLibrary);
|
isLibrary);
|
||||||
@ -360,6 +366,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
|||||||
setClassModifier();
|
setClassModifier();
|
||||||
setOperationModifier();
|
setOperationModifier();
|
||||||
setModelClassModifier();
|
setModelClassModifier();
|
||||||
|
setPocoModels();
|
||||||
setUseSwashbuckle();
|
setUseSwashbuckle();
|
||||||
setOperationIsAsync();
|
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() {
|
private void setUseSwashbuckle() {
|
||||||
if (isLibrary) {
|
if (isLibrary) {
|
||||||
LOGGER.warn("isLibrary is true so changing default useSwashbuckle to false");
|
LOGGER.warn("isLibrary is true so changing default useSwashbuckle to false");
|
||||||
|
@ -15,7 +15,7 @@ namespace {{packageName}}.Models
|
|||||||
/// {{description}}
|
/// {{description}}
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataContract]
|
[DataContract]
|
||||||
public partial class {{classname}} : {{#parent}}{{{.}}}, {{/parent}}IEquatable<{{classname}}>
|
public partial class {{classname}} {{#parent}}: {{{.}}}{{^pocoModels}}, {{/pocoModels}}{{/parent}}{{^pocoModels}}{{^parent}}: {{/parent}}IEquatable<{{classname}}>{{/pocoModels}}
|
||||||
{
|
{
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{#items.isEnum}}
|
{{#items.isEnum}}
|
||||||
|
@ -17,7 +17,7 @@ namespace {{modelPackage}}
|
|||||||
/// {{description}}
|
/// {{description}}
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataContract]
|
[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}}
|
{{#vars}}
|
||||||
{{#items.isEnum}}
|
{{#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}}")]
|
[JsonSubtypes.KnownSubType(typeof({{{modelName}}}), "{{^vendorExtensions.x-discriminator-value}}{{{mappingName}}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{.}}}{{/vendorExtensions.x-discriminator-value}}")]
|
||||||
{{/mappedModels}}
|
{{/mappedModels}}
|
||||||
{{/discriminator}}
|
{{/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}}
|
{{#vars}}
|
||||||
{{#items.isEnum}}
|
{{#items.isEnum}}
|
||||||
@ -67,6 +67,7 @@ namespace {{modelPackage}}
|
|||||||
{{/-last}}
|
{{/-last}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
|
||||||
|
{{^pocoModels}}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the string presentation of the object
|
/// Returns the string presentation of the object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -160,6 +161,7 @@ namespace {{modelPackage}}
|
|||||||
|
|
||||||
#pragma warning restore 1591
|
#pragma warning restore 1591
|
||||||
#endregion Operators
|
#endregion Operators
|
||||||
|
{{/pocoModels}}
|
||||||
}
|
}
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{/model}}
|
{{/model}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user