Skip to content

Improve AvroSchemaViewer nested type resolution and enum handling#2201

Open
seanmcilvenna wants to merge 2 commits intoevent-catalog:mainfrom
seanmcilvenna:avro-schema-viewer-fix
Open

Improve AvroSchemaViewer nested type resolution and enum handling#2201
seanmcilvenna wants to merge 2 commits intoevent-catalog:mainfrom
seanmcilvenna:avro-schema-viewer-fix

Conversation

@seanmcilvenna
Copy link
Copy Markdown

Problem

The AvroSchemaViewer component had limited support for nested types. It could only expand fields that were direct record types at the top level. If a field was an array, a map, or a union containing a record (e.g., ["null", "record"]), the component:

  1. Failed to show the "expand" toggle.
  2. Failed to render nested fields even if they existed.
  3. Failed to display enum symbols if they were wrapped in complex types.

Solution

Refactored AvroSchemaViewer.tsx to recursively resolve nested types and correctly identify nestable structures regardless of how many levels of unions, arrays, or maps wrap them.
Key Changes:

  • Recursive Nesting Detection: Refactored hasNestedFields to be recursive. It now correctly returns true if a type is a record, an array/map containing a nestable type, or a union containing any nestable type.
  • Deep Type Extraction: Introduced a robust getNestedType(type, target) helper function. This replaces limited logic and can drill through any combination of array, map, and union to find a specific target type (either 'record' or 'enum').
  • Enhanced AvroField Logic:
    • Uses getNestedType(field.type, 'record') to identify if there are child fields to render.
    • Uses getNestedType(field.type, 'enum') to identify if there are enum symbols to display.
    • The "Expand" button visibility is now driven by the enhanced recursive hasNestedFields.
  • Recursive Prop Propagation: Updated the recursive rendering of child fields to pass down expand and showRequired props, ensuring the expanded/collapsed state and visibility settings are maintained throughout the schema hierarchy.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 21, 2026

🦋 Changeset detected

Latest commit: c2cb143

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@eventcatalog/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 21, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ boyney123
❌ seanmcilvenna
You have signed the CLA already but the status is still pending? Let us recheck it.

@boyney123
Copy link
Copy Markdown
Collaborator

Thanks @seanmcilvenna happy to get this in, if you could review the license/cla, and once thats signed we can merge it. thanks for the contribution!

@mumundum
Copy link
Copy Markdown
Contributor

mumundum commented Feb 25, 2026

@seanmcilvenna, thanks for working on this!

Fixes #1848

@seanmcilvenna
Copy link
Copy Markdown
Author

Do you need me to do anything more to merge this PR? I see the Lint check failing, but I think it's an issue with the Lint configuration, not with actual code quality/syntax/format... unless I'm reading the logs wrong.

@boyney123
Copy link
Copy Markdown
Collaborator

Hi @seanmcilvenna

Just need to review and sign https://cla-assistant.io/event-catalog/eventcatalog?pullRequest=2201, then we can merge it :)

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.

4 participants