fix(export): use physicalName as field name in jsonschema and avro exports (#1494) - #1555
Merged
jschoedl merged 2 commits intoSep 2, 2026
Conversation
…ports (datacontract#1494) The JSON Schema and Avro exporters emitted each field using its logical `name` and never consulted `physicalName`. Apply the established `prop.physicalName or prop.name` idiom so the physical field name is used when set, falling back to the logical name otherwise. Co-Authored-By: Claude <noreply@anthropic.com>
…tract#1494) Also fixes the JSON Schema exporter's patternProperties heuristic, which read the logical name while the key it classified came from physicalName.
Collaborator
|
Thanks, LGTM! I used the opportunity to fix a similar issue with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes #1494.
datacontract export jsonschemaanddatacontract export avroemitted each field using its logicalnameand never consultedphysicalName. A property withname: "Equipment Name"andphysicalName: "name"was exported as"Equipment Name"instead of"name". This also affecteddatacontract testflows that validate JSON against a generated JSON Schema.Change
Apply the established
prop.physicalName or prop.nameidiom (already used by the SQL, BigQuery, and SodaCL exporters) so the physical field name is used when set, falling back to the logical name otherwise:datacontract/export/jsonschema_exporter.py—to_properties(property key) andto_required(required entry); nested objects recurse through the same functions, so they're covered too.datacontract/export/avro_exporter.py—to_avro_fieldfield name.Left untouched (deliberately): Avro nested-record/enum names and JSON Schema
patternPropertiesdetection — those are type identifiers / regex heuristics, not field names.Tests
Added a focused test to
tests/test_export_jsonschema.pyandtests/test_export_avro.pyassertingphysicalNamewins andnameis the fallback when it is unset.🤖 Generated with Claude Code