forked from loafle/openapi-generator-original
[csharp-netcore]For conditionalSerialization do not initialize the default value. (#10551)
* added allowDefaultValue flag for conditionSerialization * update doc * club the allowDefaultValue flag with ConditionSerialzation. * fixed the tabs space. * fixed the tabs space. * fixed the tabs space. * update samples, docs Co-authored-by: William Cheng <wing328hk@gmail.com>
This commit is contained in:
@@ -266,7 +266,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
||||
addSwitch(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES,
|
||||
CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES_DESC,
|
||||
this.optionalEmitDefaultValuesFlag);
|
||||
|
||||
|
||||
addSwitch(CodegenConstants.OPTIONAL_CONDITIONAL_SERIALIZATION,
|
||||
CodegenConstants.OPTIONAL_CONDITIONAL_SERIALIZATION_DESC,
|
||||
this.conditionalSerialization);
|
||||
|
||||
@@ -162,6 +162,7 @@
|
||||
{{^isReadOnly}}
|
||||
{{^required}}
|
||||
{{#defaultValue}}
|
||||
{{^conditionalSerialization}}
|
||||
{{^vendorExtensions.x-csharp-value-type}}
|
||||
// use default value if no "{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}" provided
|
||||
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} ?? {{{defaultValue}}};
|
||||
@@ -169,6 +170,7 @@
|
||||
{{#vendorExtensions.x-csharp-value-type}}
|
||||
this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||
{{/vendorExtensions.x-csharp-value-type}}
|
||||
{{/conditionalSerialization}}
|
||||
{{/defaultValue}}
|
||||
{{^defaultValue}}
|
||||
{{^conditionalSerialization}}
|
||||
|
||||
@@ -56,8 +56,6 @@ namespace Org.OpenAPITools.Model
|
||||
throw new ArgumentNullException("className is a required property for Animal and cannot be null");
|
||||
}
|
||||
this._ClassName = className;
|
||||
// use default value if no "color" provided
|
||||
this.Color = color ?? "red";
|
||||
this.AdditionalProperties = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,6 @@ namespace Org.OpenAPITools.Model
|
||||
public ChildCatAllOf(string name = default(string), PetTypeEnum? petType = PetTypeEnum.ChildCat)
|
||||
{
|
||||
this._Name = name;
|
||||
this.PetType = petType;
|
||||
this.AdditionalProperties = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,6 @@ namespace Org.OpenAPITools.Model
|
||||
/// <param name="bar">bar (default to "bar").</param>
|
||||
public Foo(string bar = "bar")
|
||||
{
|
||||
// use default value if no "bar" provided
|
||||
this.Bar = bar ?? "bar";
|
||||
this.AdditionalProperties = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,6 @@ namespace Org.OpenAPITools.Model
|
||||
this._Quantity = quantity;
|
||||
this._ShipDate = shipDate;
|
||||
this._Status = status;
|
||||
this.Complete = complete;
|
||||
this.AdditionalProperties = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user