Skip to content

Enforce required on object schemas without properties - #708

Closed
MajdSehwail wants to merge 1 commit into
open-api-spex:masterfrom
MajdSehwail:fix/object-required-without-properties
Closed

Enforce required on object schemas without properties#708
MajdSehwail wants to merge 1 commit into
open-api-spex:masterfrom
MajdSehwail:fix/object-required-without-properties

Conversation

@MajdSehwail

Copy link
Copy Markdown

Fixes #706.

Cast.Object's short-circuit for schemas with neither properties nor additionalProperties returned the value without ever running required. The clause now checks required first. Because no property declarations exist to atomize keys, a required name counts as present when the input carries the atom key or its string form.

This closes the silent either/or failure: anyOf arms written as bare %Schema{type: :object, required: [...]} accepted every body, and the same arms under oneOf rejected every body via the more-than-one-schema-validates rule.

Regression tests: a property-less required schema rejects a missing key and accepts both string- and atom-keyed input.

Full test suite: 9 doctests, 390 tests, 0 failures.

🤖 Generated with Claude Code

Cast.Object short-circuits object schemas that declare neither
properties nor additionalProperties, so their required list never runs.
Either/or arms written as bare required-only object schemas therefore
enforce nothing under anyOf and reject every value under oneOf. The
short-circuit now checks required first; a required name counts as
present when the input carries the atom key or its string form, since
no property declarations exist to atomize keys.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

Cast.Object never enforces required on schemas without properties

1 participant