Forum Discussion

Stoplight's avatar
Community Manager
3 months ago

spectrals javascript api always returns an empty array

Originally posted by user tobiasneubert to the Stoplight Community on 05/26/2023 at 10:37 ET.

Hi everyone, I hope I am at the right place here. If not, my apologies.

I try to use spectrals javascript api to unit test my rules. But whatever I try, always returns with an empty array, even if I broke my rules. I posted a question on stackoverflow:

I don't know how to add code blocks here and I think there is no need in duplicating the question 🙂 It would be great if someone could help.

  • Jakub_R (Staff) [05/30/2023 - 12:30 ET]

    Hey! Try using the following ruleset

        severity: warn
        message: "Resource names should generally be plural"
        given: "$.paths"
          field: "@key"
          function: pattern
            match: "^hello$"

2 Replies