feat: Implement JSON Schema boolean schemas (true/false)#43
Merged
Conversation
Covers the remaining piece of Wave 1 #4: bare true / false as a schema. Adds AlwaysSchema and NeverSchema records, changes the parser entry to accept Object, and wires two validator branches. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three-task plan: schema records + parser change, validator branches, integration test. Mirrors the schema-booleans design spec. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
JSON Schema 2020-12 allows a bare true or false where a schema is expected: true accepts any value, false rejects every value. Add the two new sealed-hierarchy records and change SchemaParser.parse to accept Object so boolean values dispatch to the new records. Recursive callers (parseObject, parseArray, parseList, NotSchema) and external callers in Spec.java drop their Map casts. AdditionalProperties keeps its existing Boolean handling. DefaultValidator gets minimal switch branches for the two new types. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Align NeverSchema validator stub with the spec: keyword is now "false" and the rejected value is passed through via fail() instead of require() - Drop residual Map cast in parseAdditionalProperties; parse(value) accepts Object directly so no unchecked cast is needed - Static-import assertThatThrownBy in SchemaParserTest for consistency with the existing assertThat static import - Add parsesArrayWithBooleanFalseItems test covering items: false -> NeverSchema - Add rejectsNullRawSchema test covering null raw input -> IllegalArgumentException Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pins the existing case branches (added in Task 1 to keep the sealed switch compiling) with seven new unit tests covering pass/reject across string / integer / object / null inputs for both AlwaysSchema and NeverSchema. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Pin the exact NeverSchema failure message with isEqualTo instead of contains - Assert that pointer round-trips into the ValidationError - Assert the rejected value is captured, closing the Task 1 review's require vs fail regression risk Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Extend the OpenAPI fixture with a /gates endpoint whose request body uses properties.open: true (any value accepted) and properties.blocked: false (any presence rejected). Two IT cases verify a body with only 'open' returns 200 and a body containing 'blocked' returns 400 with keyword "false" in the problem detail. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Bring all tests in OpenApiServerIT into pure-camelCase form, matching the project convention applied on feat/combinators. Also flip the remaining final-verification items in the schema-booleans plan to [x] now that the branch is verified end to end. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
d422309 to
e045336
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



No description provided.