{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/openrewrite-resource/latest.json",
  "title": "OpenRewrite Resource",
  "description": "Contains OpenRewrite resource descriptors like recipes and styles",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/openrewrite/rewrite/main/rewrite-core/openrewrite.json",
    "sourceSha256": "adb7b44d3999c2687157c3e3dbc8c695bc94c2f8ff46289da1eced687d836a2b",
    "fileMatch": [
      "**/META-INF/rewrite/*.yml"
    ],
    "parsers": [
      "yaml"
    ]
  },
  "type": "object",
  "properties": {
    "type": {
      "description": "Identifies the resource type",
      "enum": [
        "specs.openrewrite.org/v1beta/recipe",
        "specs.openrewrite.org/v1beta/style",
        "specs.openrewrite.org/v1beta/category",
        "specs.openrewrite.org/v1beta/example"
      ],
      "default": "specs.openrewrite.org/v1beta/recipe"
    }
  },
  "required": [
    "type"
  ],
  "$defs": {
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "recipeList": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/recipe"
      }
    },
    "recipe": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "object"
        }
      ]
    },
    "style": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "object"
        }
      ]
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "type": {
            "const": "specs.openrewrite.org/v1beta/recipe"
          }
        }
      },
      "then": {
        "properties": {
          "type": {
            "const": "specs.openrewrite.org/v1beta/recipe"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "displayName": {
            "type": "string"
          },
          "tags": {
            "$ref": "#/$defs/tags"
          },
          "estimatedEffortPerOccurrence": {
            "type": "string",
            "format": "duration"
          },
          "causesAnotherCycle": {
            "type": "boolean",
            "default": false
          },
          "preconditions": {
            "$ref": "#/$defs/recipeList"
          },
          "recipeList": {
            "$ref": "#/$defs/recipeList"
          }
        },
        "required": [
          "name"
        ],
        "additionalProperties": false,
        "type": "object"
      }
    },
    {
      "if": {
        "properties": {
          "type": {
            "const": "specs.openrewrite.org/v1beta/category"
          }
        }
      },
      "then": {
        "properties": {
          "type": {
            "const": "specs.openrewrite.org/v1beta/category"
          },
          "name": {
            "type": "string"
          },
          "packageName": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "tags": {
            "$ref": "#/$defs/tags"
          },
          "root": {
            "type": "boolean",
            "default": false
          },
          "priority": {
            "type": "integer",
            "default": 0
          }
        },
        "required": [
          "packageName"
        ],
        "additionalProperties": false,
        "type": "object"
      }
    },
    {
      "if": {
        "properties": {
          "type": {
            "const": "specs.openrewrite.org/v1beta/style"
          }
        }
      },
      "then": {
        "properties": {
          "type": {
            "const": "specs.openrewrite.org/v1beta/style"
          },
          "name": {
            "type": "string"
          },
          "displayName": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "tags": {
            "$ref": "#/$defs/tags"
          },
          "styleConfigs": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/style"
            }
          }
        },
        "required": [
          "name"
        ],
        "additionalProperties": false,
        "type": "object"
      }
    },
    {
      "if": {
        "properties": {
          "type": {
            "const": "specs.openrewrite.org/v1beta/example"
          }
        }
      },
      "then": {
        "properties": {
          "type": {
            "const": "specs.openrewrite.org/v1beta/example"
          },
          "recipe": {
            "type": "string"
          },
          "before": {
            "type": "string"
          },
          "after": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "type": "object"
      }
    }
  ]
}
