feat(fixer): repair path parameters missing required: true - #390
Merged
Conversation
Fixes #381. #378 added the OAS 2.0 `required: true` check for path parameters and made the defect visible in both validators. It did not make it fixable — there was no corresponding FixType, and `oastools fix` left every one of those errors behind. ## The fix `FixTypePathParameterNotRequired` ("path-parameter-not-required") sets `required: true` on any `in: path` parameter that omits it. The spec permits no other value, so there is no judgment call, nothing to configure, and no information to lose. It runs at the three sites the validator reports the defect, with paths that match the validator's exactly: | Site | Reported path | |---|---| | OAS 2.0 root-level `parameters` | `parameters.{name}` | | OAS 3.x `components.parameters` | `components.parameters.{name}` | | Path item and operation, both versions | `paths.{path}[.{method}].parameters[{i}]` | Both constraints carried over from #378 hold: parameters that are a `$ref` are skipped so the definition they name is repaired once instead of at every use site, and the path-item pass runs once per path item rather than inside the per-operation loop. ## Keeping the validator and fixer aligned Rather than duplicate the traversal, the *defect test* moved to `paramutil.NeedsRequiredTrue` and both packages now call it. That collapsed four copies of the condition into one and fixed a latent inconsistency along the way: `validator/oas3.go` compared against a bare `"path"` literal while `oas2.go` used `parser.ParamInPath`. `TestFixPathParamsRequired_ResolvesValidatorErrors` is the guard: it validates a defective spec, asserts the error is reported, fixes, re-validates, and asserts no `required: true` error survives — for both OAS versions, including through `$ref` use sites. If the two sides ever drift, this fails. ## Enabled by default The issue's complaint was that `oastools fix` could not repair this, so leaving the fix opt-in would have needed a new flag to actually resolve it. It joins `FixTypeMissingPathParameter` in the always-on set via a new exported `fixer.DefaultEnabledFixes()`, which the CLI and MCP server now call instead of each hardcoding their own copy of the list. Corpus impact is nil: DigitalOcean, Asana, Plaid, and GitHub each produce 0 fixes with unchanged validation error counts — none of them exhibit this defect. ## Notes - Honors `DryRun` (records the fix, leaves the document alone), which `FixTypeMissingPathParameter` currently does not. - `webhooks` path items are untouched, matching the validator, which does not check them for this rule either. - Docs updated: package docs, fixer/deep_dive.md, CLI `--help` and cli-reference.md, MCP tool description and mcp-server.md, whitepaper. Verified with `make check` (green: lint + 8861 tests) and gopls diagnostics (clean), plus an end-to-end CLI round trip in both versions: validate reports the errors, fix repairs them, validate then passes.
📝 WalkthroughWalkthroughAdds a default-enabled fixer for existing OpenAPI path parameters missing ChangesPath parameter requiredness
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant OpenAPI document
participant Validator
participant Fixer
Validator->>OpenAPI document: Report path parameters missing required true
Fixer->>OpenAPI document: Set required true on repairable parameters
Fixer-->>Validator: Revalidate the updated document
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #390 +/- ##
==========================================
+ Coverage 85.02% 85.05% +0.03%
==========================================
Files 194 196 +2
Lines 27666 27739 +73
==========================================
+ Hits 23522 23593 +71
- Misses 2812 2813 +1
- Partials 1332 1333 +1
🚀 New features to boost your workflow:
|
erraggy
added a commit
that referenced
this pull request
Jul 27, 2026
* chore: pre-release doc accuracy and examples for v1.56.0 Release-prep review found statements that #390 made false, plus the one gap in godoc example coverage. ## Statements the new default fix made false - plugin/skills/fix-spec/SKILL.md named a single default fix - examples/workflows/fixer-showcase/README.md said only FixTypeMissingPathParameter was enabled by default - fixer/deep_dive.md's "start with defaults" named one fix type All three now name both members of DefaultEnabledFixes(). ## Exhaustiveness claims softened fixer-showcase claimed to demonstrate every fix type but covers 6 of 8 — stale since v1.46.0 for FixTypeStubMissingRef, and now missing FixTypePathParameterNotRequired as well. Rather than extend an example program on a release branch, the claim is now "common fix types" in main.go (package comment, printed header, footer list) and across the four READMEs that repeated it. Extending the showcase to all 8 is filed as a follow-up. Also corrected that README's stale "Found 4 validation errors" to 5. The extra error is the component-name check added in v1.54.0, which had gone unrecorded here for four releases. ## godoc examples fixer/example_test.go gains Example_pathParameterNotRequired, which was the only FixType of the eight without an example, and ExampleDefaultEnabledFixes for the newly exported helper. 8861 -> 8863 tests. ## Lint config markdownlint globbed agent worktrees under .claude/worktrees/, where a full checkout defeats every path exclusion above it: docs/plans/ is excluded, but .claude/worktrees/<name>/docs/plans/ was not, so an intentionally-skipped file failed the lint through its worktree path. Excluding that directory fixes `make lint-md` for anyone with a worktree open. Verified with make check: 0 golangci-lint issues, 0 markdownlint issues, 8863 tests. * chore: bump plugin version to 1.56.0 * chore: add benchmark results for v1.56.0 Generated by CI benchmark workflow on chore/v1.56.0-release-prep 🤖 Generated automatically --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This was referenced Jul 28, 2026
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.
Fixes #381.
#378 added the OAS 2.0
required: truecheck for path parameters and made the defect visible in both validators. It did not make it fixable — there was no corresponding FixType, andoastools fixleft every one of those errors behind.The fix
FixTypePathParameterNotRequired("path-parameter-not-required") setsrequired: trueon anyin: pathparameter that omits it. The spec permits no other value, so there is no judgment call, nothing to configure, and no information to lose.It runs at the three sites the validator reports the defect, with paths that match the validator's exactly:
parametersparameters.{name}Both constraints carried over from #378 hold: parameters that are a
$refare skipped so the definition they name is repaired once instead of at every use site, and the path-item pass runs once per path item rather than inside the per-operation loop.Keeping the validator and fixer aligned
Rather than duplicate the traversal, the defect test moved to
paramutil.NeedsRequiredTrueand both packages now call it. That collapsed four copies of the condition into one and fixed a latent inconsistency along the way:validator/oas3.gocompared against a bare"path"literal whileoas2.gousedparser.ParamInPath.TestFixPathParamsRequired_ResolvesValidatorErrorsis the guard: it validates a defective spec, asserts the error is reported, fixes, re-validates, and asserts norequired: trueerror survives — for both OAS versions, including through$refuse sites. If the two sides ever drift, this fails.Enabled by default
The issue's complaint was that
oastools fixcould not repair this, so leaving the fix opt-in would have needed a new flag to actually resolve it. It joinsFixTypeMissingPathParameterin the always-on set via a new exportedfixer.DefaultEnabledFixes(), which the CLI and MCP server now call instead of each hardcoding their own copy of the list.Corpus impact is nil: DigitalOcean, Asana, Plaid, and GitHub each produce 0 fixes with unchanged validation error counts; none of them exhibit this defect.
Notes
DryRun(records the fix, leaves the document alone), whichFixTypeMissingPathParametercurrently does not.webhookspath items are untouched, matching the validator, which does not check them for this rule either.--helpand cli-reference.md, MCP tool description and mcp-server.md, whitepaper.Verified with
make check(green: lint + 8861 tests) and gopls diagnostics (clean), plus an end-to-end CLI round trip in both versions: validate reports the errors, fix repairs them, validate then passes.