Skip to content

Commit bd9f46e

Browse files
fix more issues
1 parent 04a29d1 commit bd9f46e

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3167,12 +3167,15 @@ public CodegenModel fromModel(String name, Schema schema) {
31673167
parentSchema = allDefinitions.get(m.parentSchema);
31683168
}
31693169

3170+
Map<String, Schema> parentProperties = new LinkedHashMap<>();
3171+
if (parentSchema != null) {
3172+
addProperties(parentProperties, new ArrayList<>(), parentSchema, new HashSet<>());
3173+
}
3174+
31703175
Set<String> parentReadOnlyNames = new HashSet<>();
3171-
if (parentSchema != null && parentSchema.getProperties() != null) {
3172-
for (Map.Entry<String, Schema> entry : ((Map<String, Schema>) parentSchema.getProperties()).entrySet()) {
3173-
if (Boolean.TRUE.equals(entry.getValue().getReadOnly())) {
3174-
parentReadOnlyNames.add(entry.getKey());
3175-
}
3176+
for (Map.Entry<String, Schema> entry : parentProperties.entrySet()) {
3177+
if (Boolean.TRUE.equals(entry.getValue().getReadOnly())) {
3178+
parentReadOnlyNames.add(entry.getKey());
31763179
}
31773180
}
31783181

modules/openapi-generator/src/main/resources/Java/libraries/native/pojo.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
9595
) {
9696
this();
9797
{{#readOnlyVars}}
98-
{{#vendorExtensions.x-is-inherited-readonly}}this.set{{nameInPascalCase}}({{name}});{{/vendorExtensions.x-is-inherited-readonly}}{{^vendorExtensions.x-is-inherited-readonly}}this.{{name}} = {{#vendorExtensions.x-is-jackson-optional-nullable}}{{name}} == null ? JsonNullable.<{{{datatypeWithEnum}}}>undefined() : JsonNullable.of({{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{name}}{{/vendorExtensions.x-is-jackson-optional-nullable}};{{/vendorExtensions.x-is-inherited-readonly}}
98+
{{#vendorExtensions.x-is-inherited-readonly}}this.{{setter}}({{name}});{{/vendorExtensions.x-is-inherited-readonly}}{{^vendorExtensions.x-is-inherited-readonly}}this.{{name}} = {{#vendorExtensions.x-is-jackson-optional-nullable}}{{name}} == null ? JsonNullable.<{{{datatypeWithEnum}}}>undefined() : JsonNullable.of({{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{name}}{{/vendorExtensions.x-is-jackson-optional-nullable}};{{/vendorExtensions.x-is-inherited-readonly}}
9999
{{/readOnlyVars}}
100100
}{{/withXml}}{{/vendorExtensions.x-has-readonly-properties}}
101101
{{#vars}}

0 commit comments

Comments
 (0)