From 029b9fbaa5d975af216908efe55fe97e3cbaa427 Mon Sep 17 00:00:00 2001 From: Charlie Zhang Date: Mon, 8 Jun 2026 09:47:27 -0400 Subject: [PATCH 1/2] Support x-keep-typed-in-additional-properties in Python model generator When a schema sets `x-keep-typed-in-additional-properties: true`, emit a `_keep_typed_in_additional_properties = True` class attribute. In Python all fields are already stored in `_data_store` and accessible via `model["key"]` regardless of type; this marker makes the intent explicit for tooling. Co-Authored-By: Claude Sonnet 4.6 --- .generator/src/generator/templates/model_generic.j2 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.generator/src/generator/templates/model_generic.j2 b/.generator/src/generator/templates/model_generic.j2 index 5bf20ea66c..7284a0ad01 100644 --- a/.generator/src/generator/templates/model_generic.j2 +++ b/.generator/src/generator/templates/model_generic.j2 @@ -74,6 +74,9 @@ class {{ name }}(ModelNormal): {%- if model.nullable %} _nullable = True {%- endif %} +{%- if model.get("x-keep-typed-in-additional-properties") %} + _keep_typed_in_additional_properties = True +{%- endif %} {%- if model.properties %} @cached_property From e032471aaf5cb41e7a307d28afe2572e74df0e64 Mon Sep 17 00:00:00 2001 From: Charlie Zhang Date: Mon, 8 Jun 2026 10:11:07 -0400 Subject: [PATCH 2/2] docs: annotate _keep_typed_in_additional_properties as a cross-SDK semantic marker In Python, typed fields are already reachable via bracket notation through _data_store, so no runtime behaviour change is required. The marker makes the flag visible for introspection and aligns semantics with other language SDKs. Co-Authored-By: Claude Sonnet 4.6 --- .generator/src/generator/templates/model_generic.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.generator/src/generator/templates/model_generic.j2 b/.generator/src/generator/templates/model_generic.j2 index 7284a0ad01..5200780d34 100644 --- a/.generator/src/generator/templates/model_generic.j2 +++ b/.generator/src/generator/templates/model_generic.j2 @@ -75,6 +75,8 @@ class {{ name }}(ModelNormal): _nullable = True {%- endif %} {%- if model.get("x-keep-typed-in-additional-properties") %} + # Cross-SDK semantic marker. In Python, typed fields are already accessible via + # bracket notation (model["key"]) through _data_store, so no runtime change is needed. _keep_typed_in_additional_properties = True {%- endif %}