{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Optional PKI REST response mapping component, version1",
  "description": "Strict JSON parsing and runtime resource bounds apply. An issued label produces only an untrusted X509 candidate: exact CSR/key, identity, profile, path/trust, purpose and freshness must still be validated. No redirects/5xx success; 4xx cannot produce issued/pending. Each certificate <=32768 DER bytes, at most4 distinct certificates including leaf. Required leaf array cannot be empty. Optional chain can be absent but not null. Order IDs are bounded opaque ASCII components; integer mode requires unsigned canonical decimal notation. Runtime labels are case sensitive.",
  "type": "object",
  "required": [
    "status",
    "certificate"
  ],
  "properties": {
    "status": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "pointer",
            "values",
            "http_statuses"
          ],
          "properties": {
            "pointer": {
              "$ref": "#/$defs/pointer"
            },
            "values": {
              "type": "object",
              "minProperties": 1,
              "maxProperties": 32,
              "additionalProperties": {
                "enum": [
                  "issued",
                  "pending",
                  "rejected"
                ]
              }
            },
            "http_statuses": {
              "type": "array",
              "minItems": 1,
              "maxItems": 32,
              "uniqueItems": true,
              "items": {
                "type": "integer",
                "anyOf": [
                  {
                    "minimum": 200,
                    "maximum": 299
                  },
                  {
                    "minimum": 400,
                    "maximum": 499
                  }
                ]
              }
            }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": [
            "http_values"
          ],
          "properties": {
            "http_values": {
              "type": "object",
              "minProperties": 1,
              "maxProperties": 32,
              "patternProperties": {
                "^2[0-9]{2}$": {
                  "enum": [
                    "issued",
                    "pending",
                    "rejected"
                  ]
                },
                "^4[0-9]{2}$": {
                  "const": "rejected"
                }
              },
              "additionalProperties": false
            }
          },
          "additionalProperties": false
        }
      ]
    },
    "certificate": {
      "$ref": "#/$defs/certificate"
    },
    "chain": {
      "$ref": "#/$defs/certificate"
    },
    "order_id": {
      "type": "object",
      "required": [
        "pointer",
        "type"
      ],
      "properties": {
        "pointer": {
          "$ref": "#/$defs/pointer"
        },
        "type": {
          "enum": [
            "string",
            "integer"
          ]
        }
      },
      "additionalProperties": false
    },
    "errors": {
      "type": "object",
      "required": [
        "pointer",
        "values"
      ],
      "properties": {
        "pointer": {
          "$ref": "#/$defs/pointer"
        },
        "values": {
          "type": "object",
          "minProperties": 1,
          "maxProperties": 32,
          "additionalProperties": {
            "enum": [
              "issuer_rejected",
              "authentication",
              "authorization",
              "profile",
              "unavailable"
            ]
          }
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false,
  "$defs": {
    "pointer": {
      "type": "string",
      "maxLength": 1024,
      "pattern": "^(?:/(?:[^~]|~[01])*)*$",
      "description": "RFC6901 plain pointer, decoded once; at most16segments in runtime. Empty pointer selects root. No URI fragments/JSONPath."
    },
    "certificate": {
      "type": "object",
      "required": [
        "pointer",
        "encoding",
        "shape"
      ],
      "properties": {
        "pointer": {
          "$ref": "#/$defs/pointer"
        },
        "encoding": {
          "enum": [
            "der_base64",
            "pem"
          ]
        },
        "shape": {
          "enum": [
            "single",
            "array",
            "pem_bundle"
          ]
        }
      },
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "shape": {
                "const": "pem_bundle"
              }
            }
          },
          "then": {
            "properties": {
              "encoding": {
                "const": "pem"
              }
            }
          }
        }
      ]
    }
  },
  "x-runtime-limits": {
    "utf8_bytes": 262144,
    "depth": 16,
    "nodes": 4096,
    "string_utf16_units": 65536,
    "number_characters": 128,
    "number_scale_min": -128,
    "number_scale_max": 128,
    "certificate_der_bytes": 32768,
    "certificates": 4
  }
}
