Skip to content

feat(avro): add --format avsc option to export Avro JSON Schema - #570

Open
DavidMatzek wants to merge 2 commits into
COVESA:masterfrom
DavidMatzek:feat/avro-format-avsc
Open

DavidMatzek wants to merge 2 commits into
COVESA:masterfrom
DavidMatzek:feat/avro-format-avsc

Conversation

@DavidMatzek

Copy link
Copy Markdown

Summary

Adds a --format [idl|avsc] option to the avro exporter (default idl, existing behavior unchanged). With --format avsc, the exporter writes native Avro JSON Schema (.avsc) files directly, one self-contained file per top-level struct. Users no longer need to export .avdl and convert it with avro-tools idl2schemata.

Changes

  • --format idl|avsc option (case-insensitive, default idl).
  • AVSC renderer reusing the existing struct, enum and dependency-resolution helpers, so both formats describe the same types.
  • Records and enums are embedded where first referenced and referenced by bare name afterwards, since Avro allows a named type to be defined only once.
  • Every field is a ["null", T] union, matching the IDL union { null, T }.
  • Enums list UNKNOWN first and set "default": "UNKNOWN" (IDL: = UNKNOWN).
  • --include-array-record produces a <Struct>Array root record wrapping the struct.
  • --file-prefix applies to .avsc filenames.

Documentation

  • docs/avro.md: new "Output formats" section (IDL vs AVSC comparison, AVSC embedding rules, examples) and --format in the options table.
  • CHANGELOG.md: entry under Unreleased.

Tests

  • Unit tests for the AVSC generator (fields, enums, nested and referenced structs, array wrapper).
  • Structural tests: every named type is defined exactly once and before use, for all test structs with and without the array record. IDL and AVSC declare the same record and enum names.
  • New Device test struct: an enum inside a nested struct, and a record referenced three times.
  • CLI tests: default output stays .avdl, --format avsc, case-insensitive format, invalid format rejected, file prefix, array record, valid JSON output.

Compatibility

No behavior change for existing users; idl remains the default and its output is unchanged.

q420386 added 2 commits October 9, 2026 12:12
Signed-off-by: q420386 <david.dm.matzek@bmw.de>
Add Output formats section to docs/avro.md, set enum default UNKNOWN in AVSC for parity with IDL, and add tests for shared records/enums, spec-order validity and CLI options.

Signed-off-by: q420386 <david.dm.matzek@bmw.de>
@DavidMatzek
DavidMatzek force-pushed the feat/avro-format-avsc branch from d0ab459 to 7288723 Compare October 9, 2026 10:13
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.

1 participant