Skip to content

Commit a707de3

Browse files
Support x-keep-typed-in-additional-properties in Ruby model generator
When a schema sets `x-keep-typed-in-additional-properties: true`, also add typed property keys to `additional_properties` so all fields are accessible from a single map regardless of when they were added to the spec. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 42f8411 commit a707de3

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@
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 %}
8588
end
8689
{%- else %}
8790
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

0 commit comments

Comments
 (0)