Skip to content

Commit 13c34c1

Browse files
committed
Fix getter methods for Java model with additionalProperties
When a model class is configured with additionalProperties, getters for non-dynamic properties always return null because values have been set as properties of the map instead of the class. As a workaround, this commit ensures that we these values are available in getters as well. This fixes #4970, fixes #5259, and fixes #5187
1 parent faf1c93 commit 13c34c1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

modules/swagger-codegen/src/main/resources/Java/pojo.mustache

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,12 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela
140140
{{{vendorExtensions.extraAnnotation}}}
141141
{{/vendorExtensions.extraAnnotation}}
142142
public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
143+
{{#parent}}
144+
return {{name}} == null ? ({{{datatypeWithEnum}}}) this.get("{{name}}") : {{name}};
145+
{{/parent}}
146+
{{^parent}}
143147
return {{name}};
148+
{{/parent}}
144149
}
145150
{{^isReadOnly}}
146151

0 commit comments

Comments
 (0)