I’d like to switch us over to spectral for OpenAPI spec validation of our many API specs and I think the custom validation rules are a very compelling feature - but I am struggling to get a simple example working. In this case, I would like to ensure that our parameter names contain no more than one underscore.
From https://stoplight.io/p/docs/gh/stoplightio/spectral/docs/guides/custom-functions.md I have created a
spectral.yml which does get picked up because I’m also disabling some rules that we don’t comply with (not all the operations have descriptions and some of our examples seem to be the wrong datatype!). I’m completely unclear:
- how to tell if the rule is even getting called
- how to tell it to run on
- what the function should return, for both success and for failure
- whether I should be able to see console.log output in my custom function when I’m trying to debug things
Any help is appreciated and I’ll try to blog what I come up with as well once it’s all sorted - this would be a superpower if I could make it work