{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/songlinks-io/json-schema/songlinks-io-writers-response-schema.json",
  "title": "WritersResponse",
  "description": "The writers behind a list of IPI name numbers, in the order sent, and how each one's works divide between\ntheir main number and the rest.",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/songlinks-io-openapi.json#/components/schemas/WritersResponse",
  "properties": {
    "writers": {
      "items": {
        "$ref": "#/$defs/WriterAnswer"
      },
      "type": "array",
      "title": "Writers",
      "description": "one entry per distinct number, in the order first sent"
    },
    "summary": {
      "$ref": "#/$defs/WritersSummary",
      "description": "totals over `writers`"
    },
    "rate_limit": {
      "anyOf": [
        {
          "$ref": "#/$defs/RateLimit"
        },
        {
          "type": "null"
        }
      ],
      "description": "your remaining allowance; null when no per-caller limit is in force"
    }
  },
  "type": "object",
  "required": [
    "writers",
    "summary"
  ],
  "$defs": {
    "RateLimit": {
      "properties": {
        "limit": {
          "type": "integer",
          "title": "Limit",
          "description": "requests allowed per window"
        },
        "remaining": {
          "type": "integer",
          "title": "Remaining",
          "description": "requests left in the current window"
        },
        "window_seconds": {
          "type": "integer",
          "title": "Window Seconds",
          "description": "the length of the window, in seconds"
        }
      },
      "type": "object",
      "required": [
        "limit",
        "remaining",
        "window_seconds"
      ],
      "title": "RateLimit",
      "description": "Your remaining allowance under a per-caller limit."
    },
    "WriterAnswer": {
      "properties": {
        "ipi_name_number": {
          "type": "string",
          "title": "Ipi Name Number",
          "description": "the number, as 11 digits with its leading zeros. For an `invalid` entry, the text as sent, cut to 32 characters"
        },
        "status": {
          "type": "string",
          "title": "Status",
          "description": "`person`: one person holds this number. `several`: more than one person holds it, and none is chosen. `none`: no person here holds it; it may belong to a publisher, or its records have not been grouped. `invalid`: not an IPI name number (up to 11 digits; spaces and dashes are ignored)"
        },
        "person_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Person Id",
          "description": "the person's ID, `SLP-XXXX-XXXX-C`; null unless `status` is `person`"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Name",
          "description": "the name to show for the person; null unless `status` is `person`"
        },
        "names": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Names",
          "description": "every distinct name the person's records are registered under, `name` first. Compare a spelling you hold against it: a spelling not in this list is not one this person is registered under. Empty unless `status` is `person`"
        },
        "works": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Works",
          "description": "distinct works across the person's records; null unless `status` is `person`"
        },
        "main_ipi_name_number": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Main Ipi Name Number",
          "description": "the person's main number: the one on the record their ID was created around. It can differ from `ipi_name_number`: the number sent may be a secondary one"
        },
        "works_on_main_ipi": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Works On Main Ipi",
          "description": "distinct works on the records carrying `main_ipi_name_number`"
        },
        "works_elsewhere": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Works Elsewhere",
          "description": "`works` minus `works_on_main_ipi`: works registered only under another spelling of the name or another IPI name number. Null when `works_on_main_ipi` is"
        },
        "persons": {
          "type": "integer",
          "title": "Persons",
          "description": "how many persons hold this number: 1 for `person`, 2 or more for `several`, 0 otherwise",
          "default": 0
        },
        "person_url": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Person Url",
          "description": "the page to open, relative to this site: the person's page, or for `several` the page listing everyone who holds the number"
        }
      },
      "type": "object",
      "required": [
        "ipi_name_number",
        "status"
      ],
      "title": "WriterAnswer",
      "description": "One IPI name number from the list, and the person who holds it."
    },
    "WritersSummary": {
      "properties": {
        "numbers": {
          "type": "integer",
          "title": "Numbers",
          "description": "distinct entries checked, invalid ones included"
        },
        "person": {
          "type": "integer",
          "title": "Person",
          "description": "numbers held by one person"
        },
        "several": {
          "type": "integer",
          "title": "Several",
          "description": "numbers held by more than one person"
        },
        "none": {
          "type": "integer",
          "title": "None",
          "description": "numbers no person here holds"
        },
        "invalid": {
          "type": "integer",
          "title": "Invalid",
          "description": "entries that are not IPI name numbers"
        },
        "persons": {
          "type": "integer",
          "title": "Persons",
          "description": "distinct persons found. Two numbers of one writer count once"
        },
        "with_works_elsewhere": {
          "type": "integer",
          "title": "With Works Elsewhere",
          "description": "of `persons`, how many have `works_elsewhere` above zero: writers with works registered under another spelling or number"
        }
      },
      "type": "object",
      "required": [
        "numbers",
        "person",
        "several",
        "none",
        "invalid",
        "persons",
        "with_works_elsewhere"
      ],
      "title": "WritersSummary",
      "description": "Totals over the list. Each number is counted once, however many times it was sent."
    }
  }
}