{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/go-feature-flag-flag-configuration/latest.json",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/thomaspoignant/go-feature-flag/main/.schema/flag-schema.json",
    "sourceSha256": "dc7432536d0425999839aca7a27845fe802d8a4e254b9c7b85ccb7887ad601fb",
    "fileMatch": [
      "*.goff.yml",
      "*.goff.yaml",
      "*.goff.json",
      "*.goff.toml"
    ],
    "parsers": [
      "json",
      "toml",
      "yaml"
    ]
  },
  "type": "object",
  "additionalProperties": {
    "$ref": "#/$defs/DTO"
  },
  "$defs": {
    "DTO": {
      "properties": {
        "trackEvents": {
          "type": "boolean"
        },
        "disable": {
          "type": "boolean"
        },
        "version": {
          "type": "string"
        },
        "converter": {
          "type": "string"
        },
        "variations": {
          "description": "All the variations available for this flag. You need at least 2 variations and it is a key value pair. All the variations should have the same type.",
          "type": "object",
          "title": "variations",
          "additionalProperties": true
        },
        "targeting": {
          "items": {
            "$ref": "#/$defs/Rule"
          },
          "type": "array",
          "title": "targeting",
          "description": "List of rule to target a subset of the users based on the evaluation context."
        },
        "bucketingKey": {
          "type": "string"
        },
        "defaultRule": {
          "$ref": "#/$defs/Rule",
          "title": "defaultRule",
          "description": "How do we evaluate the flag if the user is not part of any of the targeting rule."
        },
        "scheduledRollout": {
          "items": {
            "$ref": "#/$defs/ScheduledStep"
          },
          "type": "array",
          "title": "scheduledRollout",
          "description": "Configure an update on some fields of your flag over time."
        },
        "experimentation": {
          "$ref": "#/$defs/ExperimentationDto",
          "title": "experimentation",
          "description": "Configure an experimentation. It will allow you to configure a start date and an end date for your flag."
        },
        "metadata": {
          "type": "object",
          "title": "metadata",
          "description": "A field containing information about your flag such as an issue tracker link a description etc..."
        }
      },
      "required": [
        "variations",
        "defaultRule"
      ],
      "type": "object",
      "additionalProperties": false
    },
    "ExperimentationDto": {
      "properties": {
        "start": {
          "type": "string",
          "format": "date-time",
          "title": "start",
          "description": "Time of the start of the experimentation."
        },
        "end": {
          "type": "string",
          "format": "date-time",
          "title": "start",
          "description": "Time of the end of the experimentation."
        }
      },
      "required": [
        "start",
        "end"
      ],
      "type": "object",
      "additionalProperties": false
    },
    "ExperimentationRollout": {
      "properties": {
        "start": {
          "type": "string",
          "format": "date-time"
        },
        "end": {
          "type": "string",
          "format": "date-time"
        }
      },
      "type": "object",
      "additionalProperties": false
    },
    "ProgressiveRollout": {
      "properties": {
        "initial": {
          "$ref": "#/$defs/ProgressiveRolloutStep",
          "title": "initial",
          "description": "A description of the initial state of the rollout."
        },
        "end": {
          "$ref": "#/$defs/ProgressiveRolloutStep",
          "title": "initial",
          "description": "A description of the end state of the rollout."
        }
      },
      "type": "object",
      "additionalProperties": false
    },
    "ProgressiveRolloutStep": {
      "properties": {
        "variation": {
          "type": "string",
          "title": "variation",
          "description": "Name of the variation to apply."
        },
        "percentage": {
          "type": "number",
          "title": "percentage",
          "description": "The percentage (initial or end) for the progressive rollout."
        },
        "date": {
          "type": "string",
          "format": "date-time",
          "title": "date",
          "description": "Date is the time it starts or ends."
        }
      },
      "required": [
        "variation",
        "percentage",
        "date"
      ],
      "type": "object",
      "additionalProperties": false
    },
    "Rule": {
      "properties": {
        "name": {
          "type": "string",
          "title": "name",
          "description": "Name is the name of the rule. This field is mandatory if you want to update the rule during scheduled rollout."
        },
        "query": {
          "type": "string",
          "title": "query",
          "description": "The query that allow to check in the evaluation context match. Note: in the defaultRule field query is ignored."
        },
        "variation": {
          "type": "string",
          "title": "variation",
          "description": "The variation name to use if the rule apply for the user. In case we have a percentage field in the config this field is ignored"
        },
        "percentage": {
          "description": "Represents the percentage we should give to each variation.",
          "type": "object",
          "title": "percentage",
          "additionalProperties": {
            "type": "number"
          }
        },
        "progressiveRollout": {
          "$ref": "#/$defs/ProgressiveRollout",
          "title": "progressiveRollout",
          "description": "Configure a progressive rollout deployment of your flag."
        },
        "disable": {
          "type": "boolean",
          "title": "disable",
          "description": "Indicates that this rule is disabled."
        }
      },
      "type": "object",
      "additionalProperties": false
    },
    "ScheduledStep": {
      "properties": {
        "variations": {
          "type": "object",
          "additionalProperties": true
        },
        "targeting": {
          "items": {
            "$ref": "#/$defs/Rule"
          },
          "type": "array"
        },
        "bucketingKey": {
          "type": "string"
        },
        "defaultRule": {
          "$ref": "#/$defs/Rule"
        },
        "experimentation": {
          "$ref": "#/$defs/ExperimentationRollout"
        },
        "scheduledRollout": {
          "items": {
            "$ref": "#/$defs/ScheduledStep"
          },
          "type": "array"
        },
        "trackEvents": {
          "type": "boolean"
        },
        "disable": {
          "type": "boolean"
        },
        "version": {
          "type": "string"
        },
        "metadata": {
          "type": "object"
        },
        "date": {
          "type": "string",
          "format": "date-time"
        }
      },
      "type": "object",
      "additionalProperties": false
    }
  }
}
