Skip to content

Commit 29ed186

Browse files
committed
minor refactors
1 parent 4b0fbe1 commit 29ed186

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen {
6464
@Setter protected boolean netCoreProjectFileFlag = false;
6565
protected boolean nullReferenceTypesFlag = false;
6666
protected boolean useSourceGeneration = false;
67-
protected boolean patchIsInheritedProperty = false;
67+
protected boolean useLegacyIsInheritedPropertyValue = true;
6868

6969
protected String modelPropertyNaming = CodegenConstants.MODEL_PROPERTY_NAMING_TYPE.PascalCase.name();
7070

@@ -737,7 +737,10 @@ protected void patchProperty(Map<String, CodegenModel> enumRefs, CodegenModel mo
737737
property.isPrimitiveType = true;
738738
}
739739

740-
if (this.patchIsInheritedProperty && model.parentModel != null && model.parentModel.allVars.stream().anyMatch(v -> v.baseName.equals(property.baseName))) {
740+
// the isInherited property is not always correct
741+
// fixing it here causes a breaking change in some generators
742+
// use the useLegacyIsInheritedPropertyValue to only do this in generators that are prepared for the improvement
743+
if (!this.useLegacyIsInheritedPropertyValue && model.parentModel != null && model.parentModel.allVars.stream().anyMatch(v -> v.baseName.equals(property.baseName))) {
741744
property.isInherited = true;
742745
}
743746

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,9 +1593,7 @@ public String toInstantiationType(Schema schema) {
15931593
@Override
15941594
protected void patchProperty(Map<String, CodegenModel> enumRefs, CodegenModel model, CodegenProperty property) {
15951595
if (GENERICHOST.equals(getLibrary())) {
1596-
// the isInherited property is not always correct
1597-
// fixing it here causes a breaking change in some generators
1598-
this.patchIsInheritedProperty = true;
1596+
this.useLegacyIsInheritedPropertyValue = false;
15991597
}
16001598

16011599
super.patchProperty(enumRefs, model, property);

0 commit comments

Comments
 (0)