redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

Rules to disallow usage of vendor extensions

Open kekel87 opened this issue 2 years ago • 1 comments

Hello, I didn't find any ready-made rule to avoid the use of vendor extensions and respect the basic standard. I made this custom one, but the warning doesn't come out on the right line. I think it would be interesting to have a basic rule for that.

Great work on this tool!

Describe the solution you'd like

rules:
  no-vendor-extensions: warn/error

Describe alternatives you've considered

rules:
  assert/no-vendor-extensions:
    severity: warn
    subject:
      type: any
    message: To respect the OpenAPI standard, please do not use vendor extensions
    assertions:
      notPattern: /^x-/

Additional context

kekel87 avatar Mar 16 '23 17:03 kekel87

Hi @kekel87,

Thanks for creating the issue!

However, I'd vote for extending the dissallowed assertion functions to accept RegExps (currently it only accepts arrays). So the rule could be written like this:

rules:
  assert/no-vendor-extensions:
    severity: warn
    subject:
      type: any
    message: To respect the OpenAPI standard, please do not use vendor extensions
    assertions:
      disallowed: /^x-/      

tatomyr avatar Mar 20 '23 10:03 tatomyr