From fe46ac9c8346fd6e4203c4314b26565b73a4513e Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Fri, 1 Nov 2024 15:24:43 +0000 Subject: [PATCH 1/6] 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/6] 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/6] 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: From 61c91da306942813a059b9846005e90a70ccfe72 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Thu, 5 Dec 2024 19:00:35 +0000 Subject: [PATCH 4/6] renamed flagSetId to id, version must be a string Signed-off-by: Michael Beemer --- json/flags.json | 5 +++-- json/test/flags/positive/with-metadata.json | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/json/flags.json b/json/flags.json index 0a10db4..91cce8b 100644 --- a/json/flags.json +++ b/json/flags.json @@ -54,12 +54,13 @@ "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": { + "id": { "description": "The unique identifier for the flag set.", "type": "string" }, "version": { - "description": "The version of the flag set." + "description": "The version of the flag set.", + "type": "string" } }, "$ref": "#/definitions/metadata" diff --git a/json/test/flags/positive/with-metadata.json b/json/test/flags/positive/with-metadata.json index 1889d91..b54174a 100644 --- a/json/test/flags/positive/with-metadata.json +++ b/json/test/flags/positive/with-metadata.json @@ -11,7 +11,6 @@ "defaultVariant": "red", "state": "ENABLED", "metadata": { - "flagSetId": "blah", "boolean": true, "string": "string", "float": 1.23, @@ -20,7 +19,7 @@ } }, "metadata": { - "flagSetId": "sso/dev", + "id": "sso/dev", "version": "1.0.0", "boolean": true, "string": "string", From a94c4802fb1d2231f79a9bd7a494f02e2f4684b9 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Thu, 5 Dec 2024 19:07:03 +0000 Subject: [PATCH 5/6] regenerate flags.json Signed-off-by: Michael Beemer --- json/flags.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/json/flags.json b/json/flags.json index 91cce8b..0a10db4 100644 --- a/json/flags.json +++ b/json/flags.json @@ -54,13 +54,12 @@ "title": "Flag Set Metadata", "description": "Metadata about the flag set, with keys of type string, and values of type boolean, string, or number.", "properties": { - "id": { + "flagSetId": { "description": "The unique identifier for the flag set.", "type": "string" }, "version": { - "description": "The version of the flag set.", - "type": "string" + "description": "The version of the flag set." } }, "$ref": "#/definitions/metadata" From a5d977b169a8b23d052eab4fb46429a0efa1bc7d Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Thu, 5 Dec 2024 19:23:24 +0000 Subject: [PATCH 6/6] renamed flagSetId to id, version must be a string Signed-off-by: Michael Beemer --- json/flags.json | 5 +++-- json/flags.yaml | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/json/flags.json b/json/flags.json index 0a10db4..91cce8b 100644 --- a/json/flags.json +++ b/json/flags.json @@ -54,12 +54,13 @@ "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": { + "id": { "description": "The unique identifier for the flag set.", "type": "string" }, "version": { - "description": "The version of the flag set." + "description": "The version of the flag set.", + "type": "string" } }, "$ref": "#/definitions/metadata" diff --git a/json/flags.yaml b/json/flags.yaml index d32349d..2c2f8b7 100644 --- a/json/flags.yaml +++ b/json/flags.yaml @@ -40,11 +40,12 @@ properties: 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: + id: description: The unique identifier for the flag set. type: string version: description: The version of the flag set. + type: string $ref: "#/definitions/metadata" definitions: flag: