From fe46ac9c8346fd6e4203c4314b26565b73a4513e Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Fri, 1 Nov 2024 15:24:43 +0000 Subject: [PATCH 1/3] afeat: add flag set and flag metadata to schema Signed-off-by: Michael Beemer --- json/flags.json | 31 +++++++++++++++++++ json/flags.yaml | 24 ++++++++++++++ .../negative/with-invalid-flag-metadata.json | 16 ++++++++++ .../with-invalid-flag-set-metadata.json | 16 ++++++++++ json/test/flags/positive/with-metadata.json | 30 ++++++++++++++++++ 5 files changed, 117 insertions(+) create mode 100644 json/test/flags/negative/with-invalid-flag-metadata.json create mode 100644 json/test/flags/negative/with-invalid-flag-set-metadata.json create mode 100644 json/test/flags/positive/with-metadata.json diff --git a/json/flags.json b/json/flags.json index b440b36..82d16cc 100644 --- a/json/flags.json +++ b/json/flags.json @@ -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": { @@ -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": [ @@ -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 } } } diff --git a/json/flags.yaml b/json/flags.yaml index 04a3dc1..44783b5 100644 --- a/json/flags.yaml +++ b/json/flags.yaml @@ -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, @@ -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 @@ -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: diff --git a/json/test/flags/negative/with-invalid-flag-metadata.json b/json/test/flags/negative/with-invalid-flag-metadata.json new file mode 100644 index 0000000..bb5c393 --- /dev/null +++ b/json/test/flags/negative/with-invalid-flag-metadata.json @@ -0,0 +1,16 @@ +{ + "$schema": "../../../flags.json", + "flags": { + "myBoolFlag": { + "state": "ENABLED", + "variants": { + "on": true, + "off": false + }, + "defaultVariant": "on", + "metadata": { + "invalid": { "key": "value" } + } + } + } +} diff --git a/json/test/flags/negative/with-invalid-flag-set-metadata.json b/json/test/flags/negative/with-invalid-flag-set-metadata.json new file mode 100644 index 0000000..7aae9a2 --- /dev/null +++ b/json/test/flags/negative/with-invalid-flag-set-metadata.json @@ -0,0 +1,16 @@ +{ + "$schema": "../../../flags.json", + "flags": { + "myBoolFlag": { + "state": "ENABLED", + "variants": { + "on": true, + "off": false + }, + "defaultVariant": "on" + } + }, + "metadata": { + "invalid": { "key": "value" } + } +} diff --git a/json/test/flags/positive/with-metadata.json b/json/test/flags/positive/with-metadata.json new file mode 100644 index 0000000..1889d91 --- /dev/null +++ b/json/test/flags/positive/with-metadata.json @@ -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 + } +} From fba502ea2d3c09204e3f862495135de1289aac49 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Fri, 1 Nov 2024 15:28:40 +0000 Subject: [PATCH 2/3] fix metadata requirement Signed-off-by: Michael Beemer --- json/flags.json | 2 +- json/flags.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/json/flags.json b/json/flags.json index 82d16cc..942506c 100644 --- a/json/flags.json +++ b/json/flags.json @@ -209,7 +209,7 @@ "boolean" ] }, - "required": null + "required": [] } } } diff --git a/json/flags.yaml b/json/flags.yaml index 44783b5..8a07c6e 100644 --- a/json/flags.yaml +++ b/json/flags.yaml @@ -139,4 +139,4 @@ definitions: - number - boolean # Metadata is optional - required: + required: [] From 68fe93e7fd0246eb5209059e41b6758360356143 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Fri, 1 Nov 2024 15:33:35 +0000 Subject: [PATCH 3/3] replace name with title Signed-off-by: Michael Beemer --- json/flags.json | 2 +- json/flags.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/json/flags.json b/json/flags.json index 942506c..0a10db4 100644 --- a/json/flags.json +++ b/json/flags.json @@ -51,7 +51,7 @@ } }, "metadata": { - "name": "Flag Set Metadata", + "title": "Flag Set Metadata", "description": "Metadata about the flag set, with keys of type string, and values of type boolean, string, or number.", "properties": { "flagSetId": { diff --git a/json/flags.yaml b/json/flags.yaml index 8a07c6e..d32349d 100644 --- a/json/flags.yaml +++ b/json/flags.yaml @@ -37,7 +37,7 @@ properties: dir, or available on the same HTTP path $ref: "./targeting.json" metadata: - name: Flag Set Metadata + title: Flag Set Metadata description: Metadata about the flag set, with keys of type string, and values of type boolean, string, or number. properties: flagSetId: