Skip to content

Commit

Permalink
afeat: add flag set and flag metadata to schema
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
  • Loading branch information
beeme1mr committed Nov 1, 2024
1 parent 76d611f commit fe46ac9
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 0 deletions.
31 changes: 31 additions & 0 deletions json/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@
"$ref": "./targeting.json"
}
}
},
"metadata": {
"name": "Flag Set Metadata",
"description": "Metadata about the flag set, with keys of type string, and values of type boolean, string, or number.",
"properties": {
"flagSetId": {
"description": "The unique identifier for the flag set.",
"type": "string"
},
"version": {
"description": "The version of the flag set."
}
},
"$ref": "#/definitions/metadata"
}
},
"definitions": {
Expand All @@ -72,6 +86,11 @@
},
"targeting": {
"$ref": "./targeting.json"
},
"metadata": {
"title": "Flag Metadata",
"description": "Metadata about an individual feature flag, with keys of type string, and values of type boolean, string, or number.",
"$ref": "#/definitions/metadata"
}
},
"required": [
Expand Down Expand Up @@ -179,6 +198,18 @@
"$ref": "#/definitions/objectVariants"
}
]
},
"metadata": {
"type": "object",
"additionalProperties": {
"description": "Any additional key/value pair with value of type boolean, string, or number.",
"type": [
"string",
"number",
"boolean"
]
},
"required": null
}
}
}
24 changes: 24 additions & 0 deletions json/flags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ properties:
$comment: this relative ref means that targeting.json MUST be in the same
dir, or available on the same HTTP path
$ref: "./targeting.json"
metadata:
name: Flag Set Metadata
description: Metadata about the flag set, with keys of type string, and values of type boolean, string, or number.
properties:
flagSetId:
description: The unique identifier for the flag set.
type: string
version:
description: The version of the flag set.
$ref: "#/definitions/metadata"
definitions:
flag:
$comment: base flag object; no title/description here, allows for better UX,
Expand All @@ -57,6 +67,10 @@ definitions:
type: string
targeting:
$ref: "./targeting.json"
metadata:
title: Flag Metadata
description: Metadata about an individual feature flag, with keys of type string, and values of type boolean, string, or number.
$ref: "#/definitions/metadata"
required:
- state
- defaultVariant
Expand Down Expand Up @@ -116,3 +130,13 @@ definitions:
allOf:
- $ref: "#/definitions/flag"
- $ref: "#/definitions/objectVariants"
metadata:
type: object
additionalProperties:
description: Any additional key/value pair with value of type boolean, string, or number.
type:
- string
- number
- boolean
# Metadata is optional
required:
16 changes: 16 additions & 0 deletions json/test/flags/negative/with-invalid-flag-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "../../../flags.json",
"flags": {
"myBoolFlag": {
"state": "ENABLED",
"variants": {
"on": true,
"off": false
},
"defaultVariant": "on",
"metadata": {
"invalid": { "key": "value" }
}
}
}
}
16 changes: 16 additions & 0 deletions json/test/flags/negative/with-invalid-flag-set-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "../../../flags.json",
"flags": {
"myBoolFlag": {
"state": "ENABLED",
"variants": {
"on": true,
"off": false
},
"defaultVariant": "on"
}
},
"metadata": {
"invalid": { "key": "value" }
}
}
30 changes: 30 additions & 0 deletions json/test/flags/positive/with-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "../../../flags.json",
"flags": {
"headerColor": {
"variants": {
"red": "#FF0000",
"blue": "#0000FF",
"green": "#00FF00",
"yellow": "#FFFF00"
},
"defaultVariant": "red",
"state": "ENABLED",
"metadata": {
"flagSetId": "blah",
"boolean": true,
"string": "string",
"float": 1.23,
"int": 1
}
}
},
"metadata": {
"flagSetId": "sso/dev",
"version": "1.0.0",
"boolean": true,
"string": "string",
"float": 1.23,
"int": 1
}
}

0 comments on commit fe46ac9

Please sign in to comment.