feat(validator-speclynx): simplify plugins signature#208
Conversation
Along with that, provide more of convinient deps via toolbox.
📝 WalkthroughWalkthroughRefactors SpecLynx plugin API from a diagnostics-only injection to a toolbox pattern: plugins now receive a toolbox containing Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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 |
There was a problem hiding this comment.
Pull request overview
This PR refactors the plugin system in the SpecLynx OpenAPI validator to simplify the plugin signature. Previously, plugins used a curried function pattern ({diagnostics}) => () => ({...}), and now they accept a single toolbox parameter and return the visitor object directly (toolbox) => ({...}). The toolbox provides both the diagnostics array and a deps object containing external dependencies (vscode-languageserver-types, @speclynx/apidom-* packages), eliminating the need for plugins to import these dependencies directly.
Changes:
- Simplified plugin signature from curried function to direct function accepting toolbox parameter
- Extended toolbox with additional @speclynx/apidom-* dependencies (core, datamodel, json-path, json-pointer, traverse)
- Updated all existing plugins (openapi-document.mjs, version-validator.mjs) and example plugin to use new signature
- Updated documentation in README.md and Python docstrings to reflect the new plugin API
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/jentic-openapi-validator-speclynx/tests/fixtures/plugins/version-validator.mjs | Updated test plugin to use new toolbox signature and access dependencies via deps object |
| packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/resources/speclynx.mjs | Added new dependency imports, updated createToolbox to include deps object, changed plugin invocation to pass plugins directly with toolboxCreator |
| packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/resources/plugins/openapi-document.mjs | Updated built-in plugin to use new toolbox signature and access dependencies via deps object |
| packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/resources/plugins/example-plugin.mjs.sample | Updated example plugin template to demonstrate new toolbox signature with improved documentation |
| packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/init.py | Updated Python docstring to document new plugin toolbox structure |
| packages/jentic-openapi-validator-speclynx/README.md | Updated plugin documentation with corrected example using toolbox signature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...tic/apitools/openapi/validator/backends/speclynx/resources/plugins/example-plugin.mjs.sample
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In
`@packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/__init__.py`:
- Around line 62-64: The docstring for plugin toolbox plugins currently lists an
incomplete set of deps; update the docstring in __init__.py so the toolbox.deps
description matches the actual keys exported by speclynx.mjs (the toolbox built
in speclynx.mjs lines ~145–152): include `@speclynx/apidom-core`,
`@speclynx/apidom-datamodel`, `@speclynx/apidom-json-path`,
`@speclynx/apidom-json-pointer`, and `@speclynx/apidom-traverse` in addition to
vscode-languageserver-types and `@speclynx/apidom-reference`, and mention that
built-in plugins like openapi-document.mjs rely on `@speclynx/apidom-core`.
In
`@packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/resources/plugins/example-plugin.mjs.sample`:
- Around line 8-18: Update the JSDoc for the default plugin function to
accurately list the dependencies available on toolbox.deps (notably including
'@speclynx/apidom-core' which provides toValue used in the example); modify the
`@param` lines so toolbox.deps documents all relevant packages used in the sample
(e.g., 'vscode-languageserver-types', '@speclynx/apidom-reference',
'@speclynx/apidom-core' etc.), referencing the concrete symbol toValue and the
toolbox.deps object so readers can locate the import in
example-plugin.mjs.sample.
In
`@packages/jentic-openapi-validator-speclynx/tests/fixtures/plugins/version-validator.mjs`:
- Around line 3-6: The JSDoc for the plugin lists `@speclynx/apidom-reference` but
the code actually destructures toValue from deps['@speclynx/apidom-core'];
update the JSDoc to accurately reflect the dependencies used (add
`@speclynx/apidom-core` or list all available deps) so consumers of the fixture
know to expect toValue from '@speclynx/apidom-core' when using the plugin (refer
to the destructuring of toValue in the plugin code).
Along with that, provide more of convinient deps
via toolbox.
Summary by CodeRabbit
Documentation
Refactor