{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "schema_store input",
  "description": "schema_store input: save, delete.",
  "type": "object",
  "required": [
    "action"
  ],
  "properties": {
    "action": {
      "type": "string",
      "enum": [
        "save",
        "delete"
      ],
      "description": "Choose save, delete."
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "action": {
            "type": "string",
            "const": "save"
          }
        },
        "required": [
          "action"
        ]
      },
      "then": {
        "additionalProperties": false,
        "required": [
          "name",
          "schemaRef"
        ],
        "properties": {
          "action": {
            "type": "string",
            "const": "save"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "pattern": "^[a-zA-Z0-9_-]+$",
            "description": "Saved schema name in slug format (letters, numbers, hyphens, underscores)."
          },
          "schemaRef": {
            "type": "string",
            "minLength": 1,
            "description": "Reference to an in-memory schema produced by design_compose."
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "description": "Optional tags for filtering and discovery."
          },
          "author": {
            "type": "string",
            "minLength": 1,
            "description": "Optional author metadata."
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "action": {
            "type": "string",
            "const": "delete"
          }
        },
        "required": [
          "action"
        ]
      },
      "then": {
        "additionalProperties": false,
        "required": [
          "name"
        ],
        "properties": {
          "action": {
            "type": "string",
            "const": "delete"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "pattern": "^[a-zA-Z0-9_-]+$"
          }
        }
      }
    }
  ]
}
