{
  "openapi": "3.1.0",
  "info": {
    "title": "Structured PR Reviewer API",
    "version": "1.0.0",
    "description": "Deterministic, rule-based review of a supplied unified diff. Submitted code is analyzed as text and is never executed."
  },
  "servers": [
    {
      "url": "https://agent-structured-pr-review-api.constalabs.com"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "operationId": "health",
        "responses": {
          "200": {
            "description": "Service is ready",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "const": "ok"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/review": {
      "post": {
        "operationId": "reviewDiff",
        "summary": "Review a unified diff",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReviewRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Review completed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReviewResponse"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON or invalid diff",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request exceeds the 2 MB limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Content-Type is not application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/review/sarif": {
      "post": {
        "operationId": "reviewDiffAsSarif",
        "summary": "Review a unified diff and return SARIF 2.1.0",
        "description": "Analyzes the supplied diff as text only; submitted code is never executed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReviewRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "SARIF 2.1.0 document",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SarifDocument"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON or invalid diff",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request exceeds the 2 MB limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Content-Type is not application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ReviewRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "diff"
        ],
        "properties": {
          "diff": {
            "type": "string",
            "minLength": 1,
            "description": "A unified Git diff"
          }
        }
      },
      "ReviewResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "verdict",
          "review_markdown",
          "input_bytes",
          "deterministic"
        ],
        "properties": {
          "verdict": {
            "type": "string",
            "enum": [
              "APPROVE",
              "COMMENT",
              "REQUEST_CHANGES"
            ]
          },
          "review_markdown": {
            "type": "string"
          },
          "input_bytes": {
            "type": "integer",
            "minimum": 1
          },
          "deterministic": {
            "const": true
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "limit_bytes": {
            "type": "integer"
          }
        }
      },
      "SarifDocument": {
        "type": "object",
        "required": [
          "version",
          "$schema",
          "runs"
        ],
        "properties": {
          "version": {
            "const": "2.1.0"
          },
          "$schema": {
            "type": "string"
          },
          "runs": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object"
            }
          }
        }
      }
    }
  }
}
