architecture-as-code icon indicating copy to clipboard operation
architecture-as-code copied to clipboard

Spectral ruleset to validate pattern files

Open willosborne opened this issue 1 year ago • 2 comments

Feature Request

Add a new ruleset to validate pattern files, with the same functionality as the existing one (which only supports instantiations).

Description of problem

Currently we have no spectral rulesets to validate pattern files

Potential solutions

Make new ruleset to validate patterns with same checks as existing ruleset.

willosborne avatar Apr 03 '24 09:04 willosborne

I've run into a wall with this. Spectral aggressively follows $ref files, treating them as actual objects in the document, rather than as an indication the schema for section of the document. This means that if you run into a $ref it just immediately resolves the reference from the meta schema and tries to validate that - which is obviously not what we want to do. I can't seem to disable this - see https://github.com/stoplightio/spectral/issues/2195

Not quite sure how to proceed; one option would be to trim $ref links from the document before validation, which we'd need to do in the CLI. @lbulanti-ms what do you think about this?

willosborne avatar Apr 12 '24 13:04 willosborne

I've run into a wall with this. Spectral aggressively follows $ref files, treating them as actual objects in the document, rather than as an indication the schema for section of the document. This means that if you run into a $ref it just immediately resolves the reference from the meta schema and tries to validate that - which is obviously not what we want to do. I can't seem to disable this - see stoplightio/spectral#2195

Not quite sure how to proceed; one option would be to trim $ref links from the document before validation, which we'd need to do in the CLI. @lbulanti-ms what do you think about this?

@willosborne and I have been looking into this and we think that removing the $refs at validation time is a good work around. We managed to achieve that with a script, we are planning to use the same approach in the cli. This means that we won't be able to validate the patterns directly from spectral but we will need to use the calm cli.

lbulanti-ms avatar Apr 12 '24 14:04 lbulanti-ms

This is done. We solved this problem by stripping $refs when validating patterns in the CLI, and including a script to do the same for CI tools.

willosborne avatar Jul 23 '24 16:07 willosborne