redocly-cli
redocly-cli copied to clipboard
optional ignore list for no-unresolved-refs rule
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
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?
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?
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.
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.
@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!
Tbh I haven't tried it yet. Iwill give it a whirl next week and report back
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.