feat(config): add additionalProperties support to generated config models (#5131)
* add additional_properties support to generated config models Schema types with additionalProperties (Sampler, SpanExporter, TextMapPropagator, ExperimentalResourceDetector, etc.) now capture unknown keyword arguments in an additional_properties dict field. This enables plugin/custom component names to flow through typed dataclasses without modifying the codegen tool. Implementation: - _additional_properties_support decorator in _common.py wraps the dataclass __init__ to route unknown kwargs into additional_properties - Custom dataclass.jinja2 template for datamodel-codegen conditionally applies the decorator and field when additionalPropertiesType is set - pyproject.toml updated with custom-template-dir and additional-imports - models.py regenerated via tox -e generate-config-from-jsonschema Assisted-by: Claude Opus 4.6 * update CHANGELOG with PR number #5131 * fix CI: plain assignment, pylint suppression for intentional unknown kwargs - Replace object.__setattr__ with plain self.additional_properties = extra (no frozen dataclasses, simpler and more Pythonic) - Add pylint disable=unexpected-keyword-arg on test lines that intentionally pass unknown kwargs to verify the decorator captures them - Add comment explaining setattr usage for __signature__ (pyright workaround) Assisted-by: Claude Opus 4.6 * use ClassVar annotation instead of dataclass field for additional_properties ClassVar tells type checkers the attribute exists without creating a dataclass field. This means additional_properties doesn't appear in __init__ signature, dataclasses.fields(), asdict(), or repr() — only schema-defined fields show up. The decorator sets it as a plain instance attribute at runtime. Assisted-by: Claude Opus 4.6 * rename _additional_properties_support to _additional_properties Shorter name, aligns with the attribute it creates. Assisted-by: Claude Opus 4.6 --------- Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
M
Mike Goldsmith committed
dc28b950e0e94677aa8fdb707715ed8b593947f4
Parent: 44d8911
Committed by GitHub <noreply@github.com>
on 4/24/2026, 2:26:32 PM