Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint plugins not supported? #73

Open
duncanbeevers opened this issue Nov 7, 2024 · 10 comments
Open

Lint plugins not supported? #73

duncanbeevers opened this issue Nov 7, 2024 · 10 comments

Comments

@duncanbeevers
Copy link

duncanbeevers commented Nov 7, 2024

What happened?

First, the preconditions:

  • I created a sample OpenAPI document with a single operation, no operationId defined
  • Using a redocly.yaml configured with no plugins / custom lint rules, and no extends; I enforced a single rule operation-operationId: error
  • I linted the file using redocly-cli; redocly lint and 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.yaml to 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 operationId error and the custom rule's error were reported
  • I opened the file in VS Code and verified neither the original operationId error 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
No plugin With plugin
Image

Using @redocly/cli @ 1.25.11
Using redocly-vs-code @ 0.5.1

@tatomyr
Copy link
Contributor

tatomyr commented Nov 12, 2024

This is a regression bug. Thanks for reporting it! Meanwhile you can use a version prior to v0.5.

@tatomyr tatomyr added the p1 label Nov 12, 2024
@jeremyfiel
Copy link

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'

@tatomyr tatomyr self-assigned this Nov 19, 2024
@tatomyr
Copy link
Contributor

tatomyr commented Nov 20, 2024

@duncanbeevers @jeremyfiel could you confirm it is fixed in v0.5.3?

@duncanbeevers
Copy link
Author

@tatomyr I verified this is fixed for me in 0.5.3.

Image

@jeremyfiel
Copy link

@duncanbeevers which extension provides the inline errors?

@jeremyfiel
Copy link

not fixed for me

I'm on windows 11

Image

@tatomyr
Copy link
Contributor

tatomyr commented Nov 20, 2024

Hmm, that's strange. What version did it start failing on Windows?

@tatomyr tatomyr reopened this Nov 20, 2024
@jeremyfiel
Copy link

not sure. i can try loading prior versions to narrow it down.. will let you know

@jeremyfiel
Copy link

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.

@tatomyr
Copy link
Contributor

tatomyr commented Nov 21, 2024

Thanks. Will look into that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants