{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://jabbertoon.com/schemas/errors.schema.json",
 "title": "Jabbertoon error codes",
 "description": "The catalog of the codes Jabbertoon's checks give (https://jabbertoon.com/schemas/errors.json): for each code, what it means in plain words, how to fix it, its page, and what a suggestion is drawn from. An error a tool returns is {code, where, says, fix, url} with did_you_mean and patch when the fix is certain.",
 "type": "object",
 "required": [
  "version",
  "codes"
 ],
 "additionalProperties": false,
 "properties": {
  "version": {
   "const": 1,
   "description": "The catalog format: always 1."
  },
  "codes": {
   "type": "object",
   "description": "One entry per code. A code is lower-case words joined by underscores, e.g. unknown_move.",
   "propertyNames": {
    "pattern": "^[a-z][a-z0-9]*(_[a-z0-9]+)*$",
    "maxLength": 64
   },
   "additionalProperties": {
    "$ref": "#/$defs/entry"
   }
  }
 },
 "$defs": {
  "entry": {
   "type": "object",
   "required": [
    "says",
    "fix",
    "url"
   ],
   "additionalProperties": false,
   "properties": {
    "says": {
     "type": "string",
     "minLength": 1,
     "description": "What is wrong, in plain words."
    },
    "fix": {
     "type": "string",
     "minLength": 1,
     "description": "How to fix it, written by hand."
    },
    "url": {
     "type": "string",
     "pattern": "^https://jabbertoon\\.com/docs/errors/#[a-z][a-z0-9_]*$",
     "description": "The code's place on the error page."
    },
    "suggest_from": {
     "enum": [
      "moves",
      "names",
      "fields",
      "voices",
      "looks",
      "templates",
      "places"
     ],
     "description": "The list a did_you_mean suggestion is taken from."
    },
    "patchable": {
     "type": "boolean",
     "description": "True when the fix is certain enough to be given as a JSON Patch."
    },
    "level": {
     "enum": [
      "error",
      "warning"
     ],
     "description": "Whether the check refuses the program or only warns."
    },
    "example": {
     "type": "object",
     "description": "A program that gets this code, and what the check says about it: shown under the code on https://jabbertoon.com/docs/errors/. It has says and at least one of program and text.",
     "required": [
      "says"
     ],
     "minProperties": 2,
     "additionalProperties": false,
     "properties": {
      "program": {
       "type": "object",
       "description": "The program (or the smallest part of one) that gets the code, as JSON."
      },
      "text": {
       "type": "string",
       "minLength": 1,
       "description": "The same, as screenplay text, when the code is about the text form."
      },
      "says": {
       "type": "string",
       "minLength": 1,
       "description": "What the check says about it, exactly as it says it."
      }
     }
    }
   }
  }
 }
}
