feat: add reference property to context.report() for external docs links#2734
feat: add reference property to context.report() for external docs links#2734mvanhorn wants to merge 3 commits intoRedocly:mainfrom
Conversation
🦋 Changeset detectedLatest commit: b4437dc The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Could you add a E2E or a unit test that demonstrates how the output will look like? And please do not modify our PR template. |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@mvanhorn the checks are failing, I'm converting your PR to draft. |
Adds a github-actions format test case that asserts the `Reference:` suffix is appended to the message when a problem carries a `reference` URL. Also adds a changeset under @redocly/openapi-core.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b4437dc. Configure here.
| const message = | ||
| problem.message + | ||
| (suggest !== '' ? '\n\n' + suggest : '') + | ||
| (reference !== '' ? '\n\n' + reference : ''); |
There was a problem hiding this comment.
Extra double-newline when suggest and reference both present
Low Severity
In the github-actions formatter, when both suggestions and a reference are present, formatDidYouMean returns a string already ending with \n\n, and then '\n\n' + reference is appended, producing four consecutive newlines between the two sections. The codeframe formatter avoids this by directly concatenating without the extra \n\n prefix. The test only covers the case with an empty suggest array, so this inconsistency goes undetected.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit b4437dc. Configure here.
|
@tatomyr thanks for the pushback - addressed in b4437dc:
Marked the PR ready again - hoping the required checks go green this time. |


What/Why/How?
Custom rules currently can't link users to external documentation explaining the design decision behind a rule. This PR adds a
reference?: stringproperty tocontext.report()that gets rendered beneath the message in bothstylish(codeframe) andgithub-actionsoutput formats.Example usage from a plugin rule:
Stylish output:
GitHub Actions output:
The property is carried through by the existing
...optsspread in the normalization path, so no wiring was needed beyond the type additions inwalk.tsand the renderer branches informat.ts.Reference
Fixes #1052
Testing
packages/core/src/__tests__/format.test.tsadds a github-actions format case asserting theReference:suffix renders correctly.Screenshots (optional)
N/A - output is purely textual and covered by the new test.
Check yourself
Security
Note
Low Risk
Small additive change limited to problem types and output formatting; primary risk is minor output/annotation string changes affecting consumers relying on exact formatting.
Overview
Custom rules can now attach an optional
referenceURL when callingcontext.report(), which is carried through problem normalization.Formatting is updated to render
Reference: <url>beneath the message incodeframe/stylish output and appended togithub-actionsannotations, with a new test covering the GitHub Actions format and a changeset bumping@redocly/openapi-coreminor.Reviewed by Cursor Bugbot for commit b4437dc. Bugbot is set up for automated code reviews on this repo. Configure here.