schema


schema is a function that takes a JSON Schema definition, and validates that an object looked up via JSON Path matches that schema. If the object does not exist, the function will trigger a rule violation

How do I use this function?

This function is configured by the following functionOptions

NAME DESCRIPTION TYPE REQUIRED?
schema The schema you want to evaluate JSON Schema yes

Example ruleset configuration

openapi-tags:
  description: Global tags should exist, and be an array
  type: validation
  recommended: false
  given: "$"
  then:
    field: "tags"
    function: "schema"
    functionOptions:
      schema:
        type: "array"
        items:
          type: "object"
          minItems: 1
        uniqueItems: true

View Spectral Equivalent


View Function Source