Skip to content

Commit 7e893c3

Browse files
Support x-keep-typed-in-additional-properties in Java model generator
When a schema sets `x-keep-typed-in-additional-properties: true`, each typed property setter also calls putAdditionalProperty so all fields are accessible via getAdditionalProperties() alongside untyped fields. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fe164ca commit 7e893c3

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

.generator/src/generator/templates/modelSimple.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ public class {{ name }} {%- if model.get("x-generate-alias-as-model") %} extends
258258
{%- else %}
259259
this.{{ variableName }} = {{ variableName }};
260260
{%- endif %}
261+
{%- if model.get("x-keep-typed-in-additional-properties") %}
262+
putAdditionalProperty(JSON_PROPERTY_{{ attr|snake_case|upper }}, {%- if not isRequired and isNullable %} this.{{ variableName }}.orElse(null){%- else %} {{ variableName }}{%- endif %});
263+
{%- endif %}
261264
}
262265
{%- endif %}
263266
{%- endfor %}

0 commit comments

Comments
 (0)