{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pdfmd-dev/json-schema/pdfmd-dev-ocr-result-schema.json",
  "title": "OcrResult",
  "description": "A converted document plus the OCR fields. Returned when `output` is `markdown`.",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/pdfmd-dev-api-openapi.json#/components/schemas/OcrResult",
  "allOf": [
    {
      "$ref": "#/$defs/ConvertResult"
    },
    {
      "type": "object",
      "required": [
        "operation",
        "output",
        "language",
        "ocrPages"
      ],
      "properties": {
        "operation": {
          "type": "string",
          "enum": [
            "ocr"
          ]
        },
        "output": {
          "type": "string",
          "enum": [
            "markdown"
          ]
        },
        "language": {
          "type": "string",
          "enum": [
            "eng"
          ],
          "description": "English printed text only."
        },
        "ocrPages": {
          "type": "integer",
          "minimum": 0,
          "description": "Image-only pages that OCR read."
        }
      }
    }
  ],
  "$defs": {
    "ConvertResult": {
      "type": "object",
      "description": "A converted document. Counted in pages, one page credit per page, whatever the format. Depending on `format`, `markdown`, `html` or both are present: always at least one of them.",
      "required": [
        "id",
        "parserVersion",
        "title",
        "pages",
        "scannedPages",
        "tables",
        "chars",
        "ms",
        "pageBreaks"
      ],
      "properties": {
        "id": {
          "type": "string",
          "description": "A prefix of the SHA-256 of the file."
        },
        "parserVersion": {
          "type": "string",
          "description": "The parser version that read the file."
        },
        "title": {
          "type": "string"
        },
        "pages": {
          "type": "integer",
          "minimum": 1,
          "maximum": 400
        },
        "scannedPages": {
          "type": "integer",
          "minimum": 0,
          "description": "Pages with no text layer. The Markdown endpoint counts them and does not read their image text. Use /api/v1/ocr for that."
        },
        "tables": {
          "type": "integer",
          "minimum": 0
        },
        "chars": {
          "type": "integer",
          "minimum": 0
        },
        "ms": {
          "type": "integer",
          "minimum": 0,
          "description": "Conversion time in milliseconds."
        },
        "pageBreaks": {
          "type": "array",
          "items": {
            "type": "integer",
            "minimum": 0
          },
          "description": "Character offsets in the Markdown where each page starts. They stay when `format` is `html`, which does not return the Markdown they point into."
        },
        "warnings": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Warning"
          },
          "description": "Parser 0.1.2 and later. A response from an earlier parser has no `warnings` field."
        },
        "markdown": {
          "type": "string",
          "description": "The document as Markdown. Present when `format` is `markdown` (the default) or `both`."
        },
        "html": {
          "type": "string",
          "description": "The document as an HTML fragment with no `<html>` or `<body>`, ready to embed: GitHub-flavoured tables, headings, lists, code blocks and links. Scripts, event handlers, iframes, styles and `javascript:` links are removed. The warnings that close a page in the Markdown as comments are not in the HTML; read `warnings`. Present when `format` is `html` or `both`."
        }
      },
      "additionalProperties": true
    },
    "Warning": {
      "type": "object",
      "description": "A value the parser could not settle. The same message closes its page in the Markdown as an HTML comment.",
      "required": [
        "page",
        "kind",
        "message"
      ],
      "properties": {
        "page": {
          "type": "integer",
          "minimum": 1
        },
        "kind": {
          "type": "string",
          "enum": [
            "raised_mark_unresolved",
            "table_value_not_in_source"
          ]
        },
        "message": {
          "type": "string"
        },
        "values": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "table_value_not_in_source: the values that the page does not print."
        }
      },
      "additionalProperties": true
    }
  }
}