Skip to content

fix(export): use physicalName as field name in jsonschema and avro exports (#1494) - #1555

Merged
jschoedl merged 2 commits into
datacontract:mainfrom
philipp-lutz:fix/1494-physicalname-jsonschema-avro
Sep 2, 2026
Merged

jschoedl merged 2 commits into
datacontract:mainfrom
philipp-lutz:fix/1494-physicalname-jsonschema-avro

Conversation

@philipp-lutz

Copy link
Copy Markdown
Contributor

What

Fixes #1494.

datacontract export jsonschema and datacontract export avro emitted each field using its logical name and never consulted physicalName. A property with name: "Equipment Name" and physicalName: "name" was exported as "Equipment Name" instead of "name". This also affected datacontract test flows that validate JSON against a generated JSON Schema.

Change

Apply the established prop.physicalName or prop.name idiom (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.pyto_properties (property key) and to_required (required entry); nested objects recurse through the same functions, so they're covered too.
  • datacontract/export/avro_exporter.pyto_avro_field field name.

Left untouched (deliberately): Avro nested-record/enum names and JSON Schema patternProperties detection — those are type identifiers / regex heuristics, not field names.

Tests

Added a focused test to tests/test_export_jsonschema.py and tests/test_export_avro.py asserting physicalName wins and name is the fallback when it is unset.

🤖 Generated with Claude Code

philipplutzsiemens and others added 2 commits September 2, 2026 09:54
…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.
@jschoedl

jschoedl commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Thanks, LGTM! I used the opportunity to fix a similar issue with datacontract test for local files.

@jschoedl
jschoedl merged commit a9f8a65 into datacontract:main Sep 2, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

physicalName being ignored when exporting to jsonschema and avro

3 participants