function operationsApiSchema()

in packages/rulesets/src/spectral/functions/operations-api-schema.ts [8:38]


function operationsApiSchema(schema: any, options: any, { path }: { path: JsonPath }): IFunctionResult[] {
  if (schema === null || typeof schema !== "object") {
    return [] as IFunctionResult[]
  }
  const errors: IFunctionResult[] = []
  let isValid = true
  const value = getProperty(schema, "value")
  const items = value?.items

  if (value && items) {
    const name = getProperty(items, "name")
    const display = getProperty(items, "display")
    const isDataAction = getProperty(items, "isDataAction")
    if (!name || !isDataAction || !display) {
      isValid = false
    } else {
      if (["description", "provider", "operation", "resource"].some((e) => !getProperty(display, e))) {
        isValid = false
      }
    }
  } else {
    isValid = false
  }
  if (!isValid) {
    errors.push({
      message: path[1] as string,
      path,
    })
  }
  return errors
}