Skip to content

Commit b24263c

Browse files
fix: copy typed fields into additional_properties after coercion, not before
The previous approach stored the raw pre-coercion hash value. After setters run, self.attr_name holds the coerced value. We now copy post-coercion so both access paths return consistent types. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a707de3 commit b24263c

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

.generator/src/generator/templates/model_generic.j2

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@
8282
self.additional_properties[k.to_sym] = v
8383
else
8484
h[k.to_sym] = v
85-
{%- if model.get("x-keep-typed-in-additional-properties") %}
86-
self.additional_properties[k.to_sym] = v
87-
{%- endif %}
8885
end
8986
{%- else %}
9087
fail ArgumentError, "`#{k}` is not a valid attribute in `{{ module_name }}::{{ version|upper }}::{{ name }}`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
@@ -104,6 +101,11 @@
104101
{%- endif %}
105102
end
106103
{%- endfor %}
104+
{%- if model.get("x-keep-typed-in-additional-properties") %}
105+
{%- for attr, definition in model.get("properties", {}).items() %}
106+
self.additional_properties[:'{{ attr|attribute_name }}'] = self.{{ attr|attribute_name }} if attributes.key?(:'{{ attr|attribute_name }}')
107+
{%- endfor %}
108+
{%- endif %}
107109
end
108110

109111
{%- set ns = namespace(hasValidation=False) %}

0 commit comments

Comments
 (0)