redocly-vs-code
redocly-vs-code copied to clipboard
Lint plugins not supported?
What happened?
First, the preconditions:
- I created a sample OpenAPI document with a single operation, no
operationIddefined - Using a
redocly.yamlconfigured with no plugins / custom lint rules, and noextends; I enforced a single ruleoperation-operationId: error - I linted the file using redocly-cli;
redocly lintand verified the single error was reported - I opened the file in VS Code and verified the single error was reported & highlighted
Second, the error:
- I modified the
redocly.yamlto load a single custom plugin, and to use a single rule defined by the plugin - I linted the file using redocly-cli, and verified the
operationIderror and the custom rule's error were reported - I opened the file in VS Code and verified neither the original
operationIderror nor the custom rule's error were reported
I checked the Extension Host logs and didn't see any output for redocly-vs-code.
What should have happened instead?
Custom rules should be honored.
Minimal reproducible OpenAPI snippet
# api.yaml
openapi: 3.0.2
info:
title: Example Schema
version: '1.0'
paths:
/user:
get:
responses:
'200':
description: OK
# redocly.yaml
apis:
example:
root: ./api.yaml
plugins:
- .redocly/rules.js
rules:
operation-operationId: error
custom/operation-eov-operation-handler: error
// .redocly/rules.js
const operationEovHandler = () => {
return {
Operation: {
enter: (operation, context) => {
if (!operation['x-eov-operation-handler']) {
context.report({
message: 'Operation must have x-eov-operation-handler',
});
}
}
}
};
};
module.exports = function () {
return {
id: 'custom',
rules: {
oas3: {
'operation-eov-operation-handler': operationEovHandler
}
}
};
};
Screenshots
| No plugin | With plugin |
|---|---|
Using @redocly/cli @ 1.25.11 Using redocly-vs-code @ 0.5.1
This is a regression bug. Thanks for reporting it! Meanwhile you can use a version prior to v0.5.
here's my contribution of the error log from vsc.
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: Failed to load plugin "./linting/plugins/index.js": Cannot find module './linting/plugins/index.js'
Require stack:
- c:\Users\fieljere\.vscode\extensions\redocly.openapi-vs-code-0.5.2\out\server\src\server.js
Error: Cannot find module './linting/plugins/index.js'
Require stack:
- c:\Users\fieljere\.vscode\extensions\redocly.openapi-vs-code-0.5.2\out\server\src\server.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1232:15)
at Function.resolve (node:internal/modules/helpers:190:19)
at r (c:\Users\fieljere\.vscode\extensions\redocly.openapi-vs-code-0.5.2\out\server\src\server.js:129:922)
at c:\Users\fieljere\.vscode\extensions\redocly.openapi-vs-code-0.5.2\out\server\src\server.js:132:274
at Array.map (<anonymous>)
at SM (c:\Users\fieljere\.vscode\extensions\redocly.openapi-vs-code-0.5.2\out\server\src\server.js:132:97)
at PM (c:\Users\fieljere\.vscode\extensions\redocly.openapi-vs-code-0.5.2\out\server\src\server.js:132:3410)
at R7 (c:\Users\fieljere\.vscode\extensions\redocly.openapi-vs-code-0.5.2\out\server\src\server.js:132:4245)
at Fye (c:\Users\fieljere\.vscode\extensions\redocly.openapi-vs-code-0.5.2\out\server\src\server.js:129:582)
at r (c:\Users\fieljere\.vscode\extensions\redocly.openapi-vs-code-0.5.2\out\server\src\server.js:130:78)
at c:\Users\fieljere\.vscode\extensions\redocly.openapi-vs-code-0.5.2\out\server\src\server.js:132:274
at Array.map (<anonymous>)
at SM (c:\Users\fieljere\.vscode\extensions\redocly.openapi-vs-code-0.5.2\out\server\src\server.js:132:97)
at PM (c:\Users\fieljere\.vscode\extensions\redocly.openapi-vs-code-0.5.2\out\server\src\server.js:132:3410)
at R7 (c:\Users\fieljere\.vscode\extensions\redocly.openapi-vs-code-0.5.2\out\server\src\server.js:132:4245)
at Fye (c:\Users\fieljere\.vscode\extensions\redocly.openapi-vs-code-0.5.2\out\server\src\server.js:129:582)
| .redocly.lint-ignore.yaml
| redocly.yaml
|
+---linting
| \---plugins
| | index.js
| |
| \---rules
| ...
# redocly.yaml
plugins:
- './linting/plugins/index.js'
@duncanbeevers @jeremyfiel could you confirm it is fixed in v0.5.3?
@tatomyr I verified this is fixed for me in 0.5.3.
@duncanbeevers which extension provides the inline errors?
not fixed for me
I'm on windows 11
Hmm, that's strange. What version did it start failing on Windows?
not sure. i can try loading prior versions to narrow it down.. will let you know
seems to start with 0.5.0
Release 0.5.0 (2024-10-23) Features Reused the @redocly/openapi-language-server package. Updated the openapi-core package to 1.25.8.
Thanks. Will look into that.
Still need help for windows users.
gentle reminder for Windows users.
- should be tested for both plugins and extends keywords.
Cool. will check it out
Should be fixed in v0.6.2.