Closed teake closed 2 years ago
Thanks for the detailed issue report! I'm marking this as an enhancement request.
Custom tags are a behavior of the YAML parser (ruamel.yaml
for check-jsonschema
), so there is a framework for this to be supported. But it will require some work. The steps we need are
!reference
tag, especially the nested reference behavior!reference
tag support to the YAML parser instance in check-jsonschema
as an optional behavior--data-transform
for azure-pipelines?)I'm interested in pursuing this, but it will take some time to work out.
In particular, I need to see how the !reference
resolution gets hooked into YAML parsing and make sure we give it the right behavior. Once that's done, the various other bits should fall into place pretty easily.
The !reference
parsing behavior will also, by the look of it, rely upon logic to read and evaluate gitlab-ci's include
config.
In terms of additional info, the thing I'm missing the most is the "how" regarding ruamel.yaml
. That will take some reading, but if anyone has helpful tips I'm all ears!
Great, thanks for picking this up!
To be clear though, I am only interested in getting check-jsonschema
to not trip up over !reference
tags. I don't care if they're recursively parsed. In fact, in general you cannot parse them because they can refer to snippets that come from include
statements pointing to other GitLab projects -- projects that you cannot access locally when you're outside of GitLab.
So if check-jsonschema
can just treat the value of !reference
tags as a sequence of strings (as specified in GitLab's JSON schema) I'd be happy.
This information is extremely useful, thank you! I was thinking we needed to process local include
directives and wasn't aware of the fact that the includes could point at other repositories.
I think the basic outline / approach is still the same, though it will be quite a bit easier. I need to figure out how to instruct the YAML parser that a !reference
should become an array of strings.
This should be working now in v0.17.0. Please let me know if you see any issues with it!
If I enable the --data-transform gitlab-ci
switch it works. Thanks!
I can't get custom YaML tags to work in check-jsonschema. In particular, the GitLab CI schema defines a custom
!reference
tag that raises an uncaught exception when attempting to validate it with check-jsonschema. Here's an example.gitlab-ci.yml
(taken from the GitLab docs):Validating it throws an exception:
This is against check-jsonschema 0.16.1 and jsonschema 4.6.0.
The GitLab documentation says to add a custom tag to the validator, but I'm not sure how to do that with check-jsonschema / jsonschema. Since the web editor of GitLab does support it since GitLab 15.1 (issue / MR) I was hoping check-jsonschema would be able to support is as well.