{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://salmonplays.github.io/oss-signal/schema/json-output.schema.json",
  "title": "oss-signal single repository JSON report",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "tool",
    "version",
    "root",
    "source",
    "generatedAt",
    "score",
    "grade",
    "summary",
    "checks",
    "recommendations"
  ],
  "properties": {
    "tool": {
      "const": "oss-signal"
    },
    "version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
    },
    "root": {
      "type": "string",
      "minLength": 1
    },
    "source": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["type", "location"],
          "properties": {
            "type": {
              "const": "local"
            },
            "location": {
              "type": "string",
              "minLength": 1
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["type", "location", "owner", "repo", "ref", "defaultBranch"],
          "properties": {
            "type": {
              "const": "github"
            },
            "location": {
              "type": "string",
              "format": "uri"
            },
            "owner": {
              "type": "string",
              "minLength": 1
            },
            "repo": {
              "type": "string",
              "minLength": 1
            },
            "ref": {
              "type": "string",
              "minLength": 1
            },
            "defaultBranch": {
              "type": "string",
              "minLength": 1
            },
            "stars": {
              "type": "integer",
              "minimum": 0
            },
            "forks": {
              "type": "integer",
              "minimum": 0
            },
            "openIssues": {
              "type": "integer",
              "minimum": 0
            },
            "healthPercentage": {
              "type": ["integer", "null"],
              "minimum": 0,
              "maximum": 100
            }
          }
        }
      ]
    },
    "generatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "score": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100
    },
    "grade": {
      "type": "string",
      "enum": ["A", "B", "C", "D", "F"]
    },
    "summary": {
      "type": "object",
      "additionalProperties": false,
      "required": ["total", "passed", "failed"],
      "properties": {
        "total": {
          "type": "integer",
          "minimum": 0
        },
        "passed": {
          "type": "integer",
          "minimum": 0
        },
        "failed": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "checks": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/check"
      }
    },
    "recommendations": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/recommendation"
      }
    }
  },
  "$defs": {
    "check": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "label", "weight", "passed", "evidence", "why", "fix"],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "label": {
          "type": "string",
          "minLength": 1
        },
        "weight": {
          "type": "integer",
          "minimum": 0
        },
        "passed": {
          "type": "boolean"
        },
        "evidence": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "why": {
          "type": "string",
          "minLength": 1
        },
        "fix": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "recommendation": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "label", "weight", "why", "fix"],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "label": {
          "type": "string",
          "minLength": 1
        },
        "weight": {
          "type": "integer",
          "minimum": 0
        },
        "why": {
          "type": "string",
          "minLength": 1
        },
        "fix": {
          "type": "string",
          "minLength": 1
        }
      }
    }
  }
}
