We’re leveraging OAS3
examples pretty heavily for Prism, and love that we’re getting back response validation within Prism. But, we’d really like to validate our
examples with our Spectral implementation. I seen in Spectral that
example are validated, but not
examples. We took a crack at trying to use the
schemaPath function in a similar fashion, but I suspect that we’re not able to pass in an array of
examples arrays to validate against the general spec. Here’s an example of what we’ve been trying:
examples-responses-are-valid: description: is valid recommended: true severity: error given: "$.components.responses..[?(@property !== 'properties' && @.examples)]" then: function: schemaPath functionOptions: field: "examples" schemaPath: "$.*.schema"
Is this possible with Spectral
schemaPath, or will we need to write our own function to handle this scenario? I suspect it’s the later, since it’s not implemented as a default Spectral rule, but wanted to reach out and see if someone has been able to make this work.
Thanks for taking a look!