Skip to content

fix: retain root type and enum on primitive compositions - #378

Merged
rowkav09 merged 1 commit into
mainfrom
fix/composition-root-constraints
Oct 5, 2026
Merged

rowkav09 merged 1 commit into
mainfrom
fix/composition-root-constraints

Conversation

@rowkav09

@rowkav09 rowkav09 commented Oct 5, 2026

Copy link
Copy Markdown
Member

When a primitive anyOf or oneOf parameter also had a sibling type or enum, only the branches made it into the input schema, so the branches could widen the contract and accept values the root enum should reject. I now keep the root type and enum next to the composition.

This tightens schemas that were wrongly accepting values, for example type: string, enum: ['a', null] now rejects null, as 3.1 says. An array-valued type with anyOf is still widened, the same as before.

The new tests cover path, query, header and cookie parameters, and check the schema keeps type and enum and that the validator rejects a value outside the root enum. They fail on main and pass with the change. Full suite passes, typecheck passes.

Closes #377.

I keep sibling type and enum constraints when adapting primitive anyOf
and oneOf parameter schemas, so branch alternatives cannot widen the
root contract.

I added fail-first regressions for path, query, header and cookie inputs.
@rowkav09
rowkav09 merged commit 970fdd3 into main Oct 5, 2026
4 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.

Primitive anyOf/oneOf parameters drop the sibling type and enum

1 participant