Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correctly handle allOf #561

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

rChaoz
Copy link

@rChaoz rChaoz commented Jan 30, 2025

When a schema has allOf, the current schemaInfo() implementation merges the info from all the allOf branches. However, this excludes the schema itself. This means that in a schema like this one:

{
    type: string
    allOf: [{ pattern: "abc" }]
}

the info will fail to figure out the type, as it only considers the inner schema.

This PR changes the info of a schema that contains anyOf from merge(...allOfBranches.map(info)) to merge(info(schema), ...allOfBranches.map(info)), essentially adding the missing/lost information.

Fixes #560

Copy link

vercel bot commented Jan 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
superforms ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 30, 2025 6:50pm

@ciscoheat
Copy link
Owner

Thank you! Will merge for the next release if I don't find anything unexpected when testing.

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.

Default value/schemaInfo() fails with anyOf
2 participants