{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://objectsgrid.com/.well-known/objects-catalog/FeatureFlag/v1/schema.json",
  "title": "FeatureFlag",
  "description": "Objects Grid FeatureFlag Object. A feature toggle of an application, per environment: on or off, for a percentage of users, or for an allow list. Its id is the flag's key, yours, e.g. new-checkout. Apps evaluate it with the documented rule, so every client gives a user the same answer: off unless enabled; on for a user key in allow; else on when the first 4 bytes of sha256(<flag key>:<user key>), as an unsigned number, modulo 100 are below rolloutPercentage. ObjectsGrid's own type. It has no JSON-LD document.",
  "x-objectsgrid-jsonLd": false,
  "type": "object",
  "properties": {
    "at_type": {
      "description": "The object type",
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "FeatureFlag"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "at_id": {
      "description": "This FeatureFlag's ObjectsGrid URL, https://apis.objectsgrid.com/<path>/<id>. Set by the service.",
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "readOnly": true
    },
    "id": {
      "description": "The FeatureFlag's id, chosen by you",
      "type": "string",
      "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,49}$"
    },
    "identifier": {
      "description": "The FeatureFlag's id. Assigned by the server.",
      "type": [
        "string",
        "null"
      ],
      "readOnly": true
    },
    "url": {
      "description": "This FeatureFlag URL. Assigned by the server.",
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "minLength": 1,
      "readOnly": true
    },
    "application": {
      "description": "The application the flag belongs to, e.g. web-shop",
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "description": {
      "description": "What the flag switches",
      "type": [
        "string",
        "null"
      ],
      "maxLength": 1000
    },
    "environments": {
      "description": "Per environment name (e.g. production): whether it is enabled, for what percentage of users, and for which user keys always",
      "type": [
        "object",
        "null"
      ],
      "maxProperties": 50,
      "propertyNames": {
        "pattern": "^[a-z][a-z0-9-]{0,30}$"
      },
      "additionalProperties": {
        "type": "object",
        "properties": {
          "enabled": {
            "description": "Whether the flag is on in the environment",
            "type": "boolean"
          },
          "rolloutPercentage": {
            "description": "When enabled, the share of users it is on for, 0 to 100; 100 when not given",
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 100
          },
          "allow": {
            "description": "User keys it is always on for when enabled, e.g. testers' ids",
            "type": [
              "array",
              "null"
            ],
            "maxItems": 100,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          }
        },
        "required": [
          "enabled"
        ],
        "unevaluatedProperties": false
      }
    },
    "defaultEnabled": {
      "description": "Whether the flag is on in an environment it doesn't name; false when not given",
      "type": [
        "boolean",
        "null"
      ]
    },
    "owner": {
      "description": "Who to ask about the flag",
      "type": [
        "string",
        "null"
      ],
      "maxLength": 200
    },
    "expires": {
      "description": "When the flag should be removed",
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "tags": {
      "description": "Tags an ABAC policy can decide on. A name may repeat; the same name and value appear once. Every stored object has them: created empty when not sent, kept by a replacement (PUT) that does not mention them, unchanged by a patch that does not mention them, cleared by null or [].",
      "type": "array",
      "default": [],
      "uniqueItems": true,
      "maxItems": 50,
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Tag/v1/schema.json"
      }
    },
    "meta": {
      "description": "System-managed metadata for the object (version, audit fields). Assigned by the server.",
      "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ObjectMeta/v1/schema.json",
      "readOnly": true
    }
  },
  "required": [
    "id",
    "application"
  ],
  "unevaluatedProperties": false
}
