diff --git a/docs/generators/csharp-netcore.md b/docs/generators/csharp-netcore.md index 9bc3a89a41e..12876565076 100644 --- a/docs/generators/csharp-netcore.md +++ b/docs/generators/csharp-netcore.md @@ -22,7 +22,6 @@ sidebar_label: csharp-netcore |optionalMethodArgument|C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).| |true| |optionalAssemblyInfo|Generate AssemblyInfo.cs.| |true| |optionalProjectFile|Generate {PackageName}.csproj.| |true| -|optionalEmitDefaultValues|Set DataMember's EmitDefaultValue.| |false| |nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.| |false| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |netCoreProjectFile|Use the new format (.NET Core) for .NET project files (.csproj).| |false| diff --git a/docs/generators/csharp.md b/docs/generators/csharp.md index ac3f13977a1..6bc0fc3a539 100644 --- a/docs/generators/csharp.md +++ b/docs/generators/csharp.md @@ -22,7 +22,6 @@ sidebar_label: csharp |optionalMethodArgument|C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).| |true| |optionalAssemblyInfo|Generate AssemblyInfo.cs.| |true| |optionalProjectFile|Generate {PackageName}.csproj.| |true| -|optionalEmitDefaultValues|Set DataMember's EmitDefaultValue.| |false| |generatePropertyChanged|Specifies a AssemblyDescription for the .NET Framework global assembly attributes stored in the AssemblyInfo file.| |false| |nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.| |false| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java index d7fc60a63bf..37bb43f333f 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java @@ -191,9 +191,6 @@ public class CodegenConstants { public static final String MODEL_NAME_SUFFIX = "modelNameSuffix"; public static final String MODEL_NAME_SUFFIX_DESC = "Suffix that will be appended to all model names. Default is the empty string."; - public static final String OPTIONAL_EMIT_DEFAULT_VALUES = "optionalEmitDefaultValues"; - public static final String OPTIONAL_EMIT_DEFAULT_VALUES_DESC = "Set DataMember's EmitDefaultValue."; - public static final String GIT_USER_ID = "gitUserId"; public static final String GIT_USER_ID_DESC = "Git user ID, e.g. openapitools."; 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 3a1b061f6c3..ff5cdc474ea 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 @@ -39,7 +39,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co protected boolean optionalAssemblyInfoFlag = true; protected boolean optionalProjectFileFlag = true; - protected boolean optionalEmitDefaultValue = false; protected boolean optionalMethodArgumentFlag = true; protected boolean useDateTimeOffsetFlag = false; protected boolean useCollection = false; @@ -197,10 +196,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co this.returnICollection = returnICollection; } - public void setOptionalEmitDefaultValue(boolean optionalEmitDefaultValue) { - this.optionalEmitDefaultValue = optionalEmitDefaultValue; - } - public void setUseCollection(boolean useCollection) { this.useCollection = useCollection; if (useCollection) { @@ -339,12 +334,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co additionalProperties.put(CodegenConstants.RETURN_ICOLLECTION, returnICollection); } - if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES)) { - setOptionalEmitDefaultValue(convertPropertyToBooleanAndWriteBack(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES)); - } else { - additionalProperties.put(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES, optionalEmitDefaultValue); - } - if (additionalProperties.containsKey(CodegenConstants.NETCORE_PROJECT_FILE)) { setNetCoreProjectFileFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.NETCORE_PROJECT_FILE)); } else { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java index 261bd0d0c55..4b03107e09d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java @@ -170,10 +170,6 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { CodegenConstants.OPTIONAL_PROJECT_FILE_DESC, this.optionalProjectFileFlag); - addSwitch(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES, - CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES_DESC, - this.optionalEmitDefaultValue); - addSwitch(CodegenConstants.GENERATE_PROPERTY_CHANGED, CodegenConstants.PACKAGE_DESCRIPTION_DESC, this.generatePropertyChanged); @@ -330,9 +326,6 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { additionalProperties.put("netStandard", this.netStandard); additionalProperties.put("targetFrameworkNuget", this.targetFrameworkNuget); - // TODO: either remove this and update templates to match the "optionalEmitDefaultValues" property, or rename that property. - additionalProperties.put("emitDefaultValue", optionalEmitDefaultValue); - if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_PROJECT_FILE)) { setOptionalProjectFileFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.OPTIONAL_PROJECT_FILE)); } else { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java index d1e3e9c7ee7..ecb859caae2 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java @@ -184,10 +184,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen { CodegenConstants.OPTIONAL_PROJECT_FILE_DESC, this.optionalProjectFileFlag); - addSwitch(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES, - CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES_DESC, - this.optionalEmitDefaultValue); - // NOTE: This will reduce visibility of all public members in templates. Users can use InternalsVisibleTo // https://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute(v=vs.110).aspx // to expose to shared code if the generated code is not embedded into another project. Otherwise, users of codegen @@ -510,8 +506,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen { syncBooleanProperty(additionalProperties, "netStandard", this::setNetStandard, this.netStandard); - // TODO: either remove this and update templates to match the "optionalEmitDefaultValues" property, or rename that property. - syncBooleanProperty(additionalProperties, "emitDefaultValue", this::setOptionalEmitDefaultValue, optionalEmitDefaultValue); syncBooleanProperty(additionalProperties, CodegenConstants.VALIDATABLE, this::setValidatable, this.validatable); syncBooleanProperty(additionalProperties, CodegenConstants.SUPPORTS_ASYNC, this::setSupportsAsync, this.supportsAsync); syncBooleanProperty(additionalProperties, CodegenConstants.OPTIONAL_PROJECT_FILE, this::setOptionalProjectFileFlag, optionalProjectFileFlag); diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache index 6d0abdd2cd7..c03ea276b1a 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache @@ -33,7 +33,7 @@ {{#description}} /// {{description}} {{/description}} - [DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}{{emitDefaultValue}}{{/isNullable}})] + [DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}})] public {{#complexType}}{{{complexType}}}{{/complexType}}{{^complexType}}{{{datatypeWithEnum}}}{{/complexType}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}} {{name}} { get; set; } {{/isEnum}} {{/vars}} @@ -116,7 +116,7 @@ /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}} /// {{#description}} /// {{description}}{{/description}} - [DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}{{emitDefaultValue}}{{/isNullable}})]{{#isDate}} + [DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}})]{{#isDate}} [JsonConverter(typeof(OpenAPIDateConverter))]{{/isDate}} public {{{dataType}}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; } diff --git a/modules/openapi-generator/src/main/resources/csharp/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/csharp/modelGeneric.mustache index 44e2b0a2da4..ddeb2563e1d 100644 --- a/modules/openapi-generator/src/main/resources/csharp/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/modelGeneric.mustache @@ -31,7 +31,7 @@ {{#description}} /// {{description}} {{/description}} - [DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}{{emitDefaultValue}}{{/isNullable}})] + [DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}})] public {{#complexType}}{{{complexType}}}{{/complexType}}{{^complexType}}{{{datatypeWithEnum}}}{{/complexType}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}} {{name}} { get; set; } {{/isEnum}} {{/vars}} @@ -108,7 +108,7 @@ this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}; /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}} /// {{#description}} /// {{description}}{{/description}} - [DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}{{emitDefaultValue}}{{/isNullable}})]{{#isDate}} + [DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}})]{{#isDate}} [JsonConverter(typeof(OpenAPIDateConverter))]{{/isDate}} public {{{dataType}}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; } {{/isEnum}}