{
  "openapi": "3.1.1",
  "info": {
    "title": "Codeharbor Diff API",
    "version": "1.0.0",
    "summary": "Compare two texts line by line and get a unified diff with added and removed lines.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://codeharbordiff.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Compare two texts line by line and get a unified diff with added and removed lines.",
        "description": "Paste an original and a changed version of a file to see which lines were added, removed or kept, grouped into hunks with context, as a unified diff like git diff or diff -u — the same comparison Codeharbor uses for snapshots and commits.\n\nMethodology:\n- Both texts are split into lines (CRLF is treated as LF). Lines common to the start and end are set aside, then Myers’ O(ND) algorithm finds a shortest edit script between the rest: the fewest added plus removed lines.\n- Changes are grouped into hunks with the chosen number of unchanged context lines; hunks closer than twice the context are joined. The unified format shows “@@ -start,count +start,count @@” headers and lines starting with “-”, “+” or a space.\n- Similarity = 2 × unchanged lines ÷ (lines of both texts). With “ignore whitespace”, runs of spaces become one space and lines are trimmed before comparing.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "codeharbor_diff",
        "x-owner-app": "codeharbor",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CodeharborDiffInput"
              },
              "examples": {
                "example1": {
                  "summary": "Two versions of a deployment file",
                  "value": {
                    "original": "service: harbour-api\nreplicas: 2\nimage:\n  name: registry.example.org/harbour-api\n  tag: \"1.3.2\"\nresources:\n  memory: 256Mi\n",
                    "changed": "service: harbour-api\nreplicas: 3\nimage:\n  name: registry.example.org/harbour-api\n  tag: \"1.4.0\"\nresources:\n  memory: 256Mi\n  cpu: 0.5\n",
                    "originalName": "deploy.yaml (v1.3.2)",
                    "changedName": "deploy.yaml (v1.4.0)"
                  }
                },
                "example2": {
                  "summary": "Re-indented code with whitespace ignored",
                  "value": {
                    "original": "function hi() {\n  return 1;\n}\n",
                    "changed": "function hi() {\n    return 1;\n}\n",
                    "ignoreWhitespace": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CodeharborDiffResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "CodeharborDiffInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "original": {
            "title": "Original",
            "type": "string",
            "maxLength": 1000000,
            "default": ""
          },
          "changed": {
            "title": "Changed",
            "type": "string",
            "maxLength": 1000000,
            "default": ""
          },
          "originalName": {
            "title": "Name of the original (optional)",
            "type": "string",
            "maxLength": 200,
            "default": "original"
          },
          "changedName": {
            "title": "Name of the changed version (optional)",
            "type": "string",
            "maxLength": 200,
            "default": "changed"
          },
          "context": {
            "title": "Context lines around changes",
            "type": "number",
            "minimum": 0,
            "maximum": 20,
            "default": 3
          },
          "ignoreWhitespace": {
            "title": "Ignore differences in spaces and indentation",
            "type": "boolean",
            "default": false
          }
        },
        "required": []
      },
      "CodeharborDiffResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object"
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}