Skip to content

Document the validate option and cover its remaining branches - #951

Merged
anttiviljami merged 1 commit into
mainfrom
claude/openapi-backend-pr-828-review-1pmfuo
Jul 29, 2026
Merged

Document the validate option and cover its remaining branches#951
anttiviljami merged 1 commit into
mainfrom
claude/openapi-backend-pr-828-review-1pmfuo

Conversation

@anttiviljami

@anttiviljami anttiviljami commented Jul 29, 2026

Copy link
Copy Markdown
Member

Summary

Docs and test follow-up to #828. That PR fixed validate predicates being coerced to true; this one documents the option and covers the branches it left untested. No behaviour changes here.

Changes

README — new "Controlling when requests get validated" section under Request validation. The option had no prose documentation at all, which is plausibly why the regression sat unnoticed from 5.11.0 onwards. Covers validate: false, the predicate form, and the coerceTypes interaction: coercion runs inside the validation branch of handleRequest, so requests a predicate skips don't get their path/query params coerced either.

Tests — three cases added alongside the two from #828:

  • validation runs by default
  • validation runs when validate is explicitly undefined
  • validate: false skips validation and validator construction (asserts api.validator stays undefined)

The explicitly-undefined case is a genuine regression guard, not just coverage. I verified it by temporarily restoring !!optsWithDefaults.validate and re-running: it fails, because the old code turned validate: undefined into false and silently disabled validation entirely. That's a distinct bug from the predicate coercion and wasn't covered by #828.

JSDocvalidate now mentions the predicate form. coerceTypes previously read "Requires validate to be enabled", which is imprecise now that a predicate can enable it per request.

Testing

Full suite green (299 tests, 4 suites), npm run lint clean, tsc --noEmit clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N2aqJLvFpzQkMSAs7un12V

Follow-up to #828, which fixed predicates being coerced to true but left
the option undocumented and partially covered.

- Document `validate: false` and the predicate form in the README,
  including the coerceTypes interaction: coercion runs as part of
  validation, so requests a predicate skips aren't coerced either.
- Add tests for the default, explicitly-undefined and `false` cases. The
  explicitly-undefined test is a regression guard — it fails against the
  old `!!opts.validate`, which turned `validate: undefined` into false
  and silently disabled validation.
- Assert no Ajv validators are built when validate is false.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N2aqJLvFpzQkMSAs7un12V
@anttiviljami anttiviljami changed the title Add support for conditional request validation via predicate Document the validate option and cover its remaining branches Jul 29, 2026
@anttiviljami
anttiviljami merged commit 7a648e5 into main Jul 29, 2026
16 checks passed
@anttiviljami
anttiviljami deleted the claude/openapi-backend-pr-828-review-1pmfuo branch July 29, 2026 10:57
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.

2 participants