{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "StepVistaPublicEntitySchema",
  "description": "JSON Schema specification for StepVista machine-readable college entities.",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "canonical_url",
    "institution",
    "historical_data",
    "fees",
    "placements",
    "provenance",
    "data_status"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "description": "Version of the machine-readable schema contract (e.g., '1.0')."
    },
    "generated_at": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp when this response was generated."
    },
    "canonical_url": {
      "type": "string",
      "format": "uri",
      "description": "The primary canonical HTML URL for this institution."
    },
    "data_status": {
      "type": "object",
      "required": [
        "status",
        "as_of"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "current",
            "historical",
            "estimated",
            "partial",
            "pending_verification"
          ]
        },
        "as_of": {
          "type": "string"
        }
      }
    },
    "institution": {
      "type": "object",
      "required": [
        "id",
        "name",
        "city",
        "state",
        "type"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "city": {
          "type": "string"
        },
        "state": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "established": {
          "type": "string"
        },
        "kea_code": {
          "type": [
            "string",
            "null"
          ]
        },
        "comedk_code": {
          "type": [
            "string",
            "null"
          ]
        },
        "official_website": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "historical_data": {
      "type": "object",
      "required": [
        "cutoffs"
      ],
      "properties": {
        "cutoffs": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "course",
              "exam",
              "year",
              "closing_rank",
              "source"
            ],
            "properties": {
              "course": {
                "type": "string"
              },
              "exam": {
                "type": "string"
              },
              "year": {
                "type": "string"
              },
              "round": {
                "type": "string"
              },
              "category": {
                "type": "string"
              },
              "closing_rank": {
                "type": "integer"
              },
              "source": {
                "type": "object",
                "required": [
                  "authority"
                ],
                "properties": {
                  "authority": {
                    "type": "string"
                  },
                  "source_url": {
                    "type": "string"
                  },
                  "cycle": {
                    "type": "string"
                  },
                  "retrieved_at": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "fees": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "program",
          "fee_text",
          "source"
        ],
        "properties": {
          "program": {
            "type": "string"
          },
          "fee_text": {
            "type": "string"
          },
          "source": {
            "type": "object",
            "required": [
              "authority"
            ],
            "properties": {
              "authority": {
                "type": "string"
              },
              "cycle": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "placements": {
      "type": "object",
      "properties": {
        "median_salary": {
          "type": [
            "string",
            "null"
          ]
        },
        "highest_package": {
          "type": [
            "string",
            "null"
          ]
        },
        "placement_rate": {
          "type": [
            "string",
            "null"
          ]
        },
        "source": {
          "type": "object",
          "required": [
            "authority"
          ],
          "properties": {
            "authority": {
              "type": "string"
            },
            "cycle": {
              "type": "string"
            }
          }
        }
      }
    },
    "provenance": {
      "type": "object",
      "required": [
        "last_updated",
        "records"
      ],
      "properties": {
        "last_updated": {
          "type": "string"
        },
        "records": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "field",
              "authority"
            ],
            "properties": {
              "field": {
                "type": "string"
              },
              "authority": {
                "type": "string"
              },
              "source_url": {
                "type": "string"
              },
              "cycle": {
                "type": "string"
              },
              "round": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}