{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:junexis:schema:registry-download:0.1",
  "title": "Odpowiedź pobrania Junexis Registry 0.1",
  "oneOf": [
    { "$ref": "#/$defs/downloaded" },
    { "$ref": "#/$defs/notModified" }
  ],
  "$defs": {
    "downloaded": {
      "type": "object",
      "additionalProperties": false,
      "required": ["schemaVersion", "status", "artifactType", "id", "version", "mediaType", "contentLength", "sha256", "etag"],
      "properties": {
        "schemaVersion": { "const": "junexis.registry-download/0.1" },
        "status": { "const": 200 },
        "artifactType": { "enum": ["package", "provider"] },
        "id": { "$ref": "#/$defs/artifactId" },
        "version": { "$ref": "#/$defs/semver" },
        "mediaType": { "$ref": "#/$defs/mediaType" },
        "contentLength": { "type": "integer", "minimum": 1, "maximum": 1073741824 },
        "sha256": { "$ref": "#/$defs/sha256" },
        "etag": { "$ref": "#/$defs/etag" }
      }
    },
    "notModified": {
      "type": "object",
      "additionalProperties": false,
      "required": ["schemaVersion", "status", "etag"],
      "properties": {
        "schemaVersion": { "const": "junexis.registry-download/0.1" },
        "status": { "const": 304 },
        "etag": { "$ref": "#/$defs/etag" }
      }
    },
    "artifactId": { "type": "string", "pattern": "^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*(?![\\s\\S])" },
    "mediaType": { "type": "string", "maxLength": 127, "pattern": "^[a-z0-9][a-z0-9!#$&^_.+-]*/[a-z0-9][a-z0-9!#$&^_.+-]*(?![\\s\\S])" },
    "semver": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:-((?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?![\\s\\S])"
    },
    "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}(?![\\s\\S])" },
    "etag": { "type": "string", "pattern": "^\\\"[0-9a-f]{64}\\\"(?![\\s\\S])" }
  }
}