{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/codefmt-dev/json-schema/codefmt-dev-format-response-schema.json",
  "title": "FormatResponse",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/codefmt-dev-openapi.yml#/components/schemas/FormatResponse",
  "type": "object",
  "required": [
    "code",
    "diagnostics",
    "duration"
  ],
  "properties": {
    "code": {
      "type": "string",
      "description": "Formatted source."
    },
    "diagnostics": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Diagnostic"
      }
    },
    "diagnosticsFrame": {
      "type": "string",
      "enum": [
        "input",
        "output"
      ],
      "description": "Which text diagnostic positions refer to: the code you sent (HubL) or the formatted output (JavaScript, Python). Absent when diagnostics is empty by construction."
    },
    "error": {
      "type": "string",
      "description": "Present only on partial failure; omitted entirely on success."
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Present only when the request carried a top-level language that was not applied (unrecognised, conflicting with platformVariants, or python on hubl), saying what happened."
    },
    "duration": {
      "type": "integer",
      "description": "Server processing time in milliseconds."
    }
  },
  "$defs": {
    "Diagnostic": {
      "type": "object",
      "required": [
        "line",
        "column",
        "message",
        "severity",
        "rule"
      ],
      "properties": {
        "line": {
          "type": "integer",
          "description": "1-based."
        },
        "column": {
          "type": "integer",
          "description": "1-based."
        },
        "endLine": {
          "type": "integer"
        },
        "endColumn": {
          "type": "integer"
        },
        "severity": {
          "type": "string",
          "enum": [
            "error",
            "warning",
            "info"
          ],
          "description": "info comes from the HubL unknown filter/global/function checks."
        },
        "message": {
          "type": "string"
        },
        "rule": {
          "type": "string"
        },
        "fix": {
          "$ref": "#/$defs/Fix"
        }
      }
    },
    "Edit": {
      "type": "object",
      "required": [
        "start",
        "end",
        "replacement"
      ],
      "properties": {
        "start": {
          "$ref": "#/$defs/Position"
        },
        "end": {
          "$ref": "#/$defs/Position"
        },
        "replacement": {
          "type": "string"
        }
      }
    },
    "Fix": {
      "type": "object",
      "required": [
        "description",
        "safety",
        "edits"
      ],
      "properties": {
        "description": {
          "type": "string"
        },
        "safety": {
          "type": "string",
          "enum": [
            "safe",
            "unsafe"
          ]
        },
        "edits": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Edit"
          }
        }
      }
    },
    "Position": {
      "type": "object",
      "required": [
        "line",
        "column"
      ],
      "properties": {
        "line": {
          "type": "integer"
        },
        "column": {
          "type": "integer"
        }
      }
    }
  }
}