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

optional ignore list for no-unresolved-refs rule

Open jeremyfiel opened this issue 2 years ago • 7 comments

Is your feature request related to a problem? Please describe.

We use the lint command for OpenAPI descriptions throughout separate phases of the design lifecycle.

  • during schema authoring
  • bundling descriptions
  • in our build

We've run into a scenario where we have certain schemas generated during the build which are documented during the design phase. The linter is flagging these references as unresolved, correctly.

Describe the solution you'd like

I'd like the ability to pass an array of patterns or strings to be matched to the ref uri string to ignore in this particular rule. I can't completely turn the rule off because we only use $ref in our descriptions. no in-line schemas are allowed except for very particular exceptions.

Something like no-http-verbs-in-paths optional validation would work great.

rules:
  no-unresolved-refs: 
    severity: warn
    ignored:
      - meta

Describe alternatives you've considered

I've considered duplicating the rule as a custom rule to insert this logic

Additional context

jeremyfiel avatar Sep 27 '23 21:09 jeremyfiel

Hi @jeremyfiel! It might be a good idea to start with a custom rule first until there are more requests for this feature. Frankly, I don't know if this is a common use case. @lornajane what do you think?

tatomyr avatar Sep 28 '23 07:09 tatomyr

A custom plugin seems like a good option - or how about using the ignore files which would give you a set of approved exceptions that don't trigger the linter?

lornajane avatar Sep 28 '23 14:09 lornajane

Afaik, the ignore file can't specify a pattern on a specific property. It can only ignore a particular rule in an API description, outright.

jeremyfiel avatar Sep 28 '23 14:09 jeremyfiel

It ignores a specific rule on a specific element in a specific API description. So a path-level rule is ignored for only that path, without disabling the rule for the whole API. I'm not sure I have enough of a handle on your use case to be sure, but I think it's worth you trying the feature and seeing if it could work.

lornajane avatar Sep 28 '23 14:09 lornajane

@jeremyfiel Let us know if generating an ignore works for you? I can't see us adding the patterns you requested but we're happy to keep discussing options!

lornajane avatar Nov 17 '23 17:11 lornajane

Tbh I haven't tried it yet. Iwill give it a whirl next week and report back

jeremyfiel avatar Nov 18 '23 00:11 jeremyfiel

just a short update...

I've created my ignore-file but this is a one time use thing. It overwrites each time you run it.. Roman had some idea to append this file in this issue https://github.com/Redocly/redocly-cli/issues/689#issuecomment-1128975819

The other issue I have is the ignore file can't be used to filter out my use case where I have some generated schemas at runtime because I have no way of catching any new apis defined with that pattern to add them to the existing ignore file, other than manually adding them.

I've yet to create the rule .. I think I may try to modify the existing no-unresolved-refs rule and add the condition to skip my pattern. No timeline on that yet.

jeremyfiel avatar Nov 21 '23 23:11 jeremyfiel