Skip to content

Commit 41e3d71

Browse files
committed
fixup: validate top-level object in targeting.json
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
1 parent 2b9fb80 commit 41e3d71

24 files changed

+487
-471
lines changed

json/flags.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$id": "https://flagd.dev/schema/v0/flags.json",
33
"$schema": "http://json-schema.org/draft-07/schema#",
44
"title": "flagd Flag Configuration",
5-
"description": "Defines flags for use in flagd, including typed variants and rules",
5+
"description": "Defines flags for use in flagd, including typed variants and rules.",
66
"type": "object",
77
"properties": {
88
"flags": {
@@ -46,7 +46,7 @@
4646
"patternProperties": {
4747
"^.{1,}$": {
4848
"$comment": "this relative ref means that targeting.json MUST be in the same dir, or available on the same HTTP path",
49-
"$ref": "./targeting.json#/definitions/targeting"
49+
"$ref": "./targeting.json"
5050
}
5151
}
5252
}
@@ -71,7 +71,7 @@
7171
"type": "string"
7272
},
7373
"targeting": {
74-
"$ref": "./targeting.json#/definitions/targeting"
74+
"$ref": "./targeting.json"
7575
}
7676
},
7777
"required": [

json/flags.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
$id: "https://flagd.dev/schema/v0/flags.json"
22
$schema: http://json-schema.org/draft-07/schema#
33
title: flagd Flag Configuration
4-
description: Defines flags for use in flagd, including typed variants and rules
4+
description: Defines flags for use in flagd, including typed variants and rules.
55
type: object
66
properties:
77
flags:
@@ -35,7 +35,7 @@ properties:
3535
"^.{1,}$":
3636
$comment: this relative ref means that targeting.json MUST be in the same
3737
dir, or available on the same HTTP path
38-
$ref: "./targeting.json#/definitions/targeting"
38+
$ref: "./targeting.json"
3939
definitions:
4040
flag:
4141
$comment: base flag object; no title/description here, allows for better UX,
@@ -56,7 +56,7 @@ definitions:
5656
if the targeting returns null).
5757
type: string
5858
targeting:
59-
$ref: "./targeting.json#/definitions/targeting"
59+
$ref: "./targeting.json"
6060
required:
6161
- state
6262
- defaultVariant

json/targeting.json

+11-20
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,20 @@
22
"$id": "https://flagd.dev/schema/v0/targeting.json",
33
"$schema": "http://json-schema.org/draft-07/schema#",
44
"title": "flagd Targeting",
5-
"description": "Defines targeting logic for flagd; a extension of JSONLogic, including purpose-built feature-flagging operations.",
5+
"description": "Defines targeting logic for flagd; a extension of JSONLogic, including purpose-built feature-flagging operations. Note that this schema applies to top-level objects; no additional properties are supported, including \"$schema\", which means built-in JSON-schema support is not possible in editors. Please use flags.json (which imports this schema) for a rich editor experience.",
66
"type": "object",
7-
"properties": {
8-
"targeting": {
9-
"$ref": "#/definitions/targeting"
7+
"anyOf": [
8+
{
9+
"$comment": "we need this to support empty targeting",
10+
"type": "object",
11+
"additionalProperties": false,
12+
"properties": {}
13+
},
14+
{
15+
"$ref": "#/definitions/anyRule"
1016
}
11-
},
17+
],
1218
"definitions": {
13-
"targeting": {
14-
"title": "Targeting",
15-
"description": "An expression returning a value which is coerced to a string to be used as a targeting key, or null (to fall back to defaultVariant). If targeting returns a value which is not a variant key, it's considered an error.",
16-
"anyOf": [
17-
{
18-
"$comment": "we need this to support empty targeting",
19-
"type": "object",
20-
"additionalProperties": false,
21-
"properties": {}
22-
},
23-
{
24-
"$ref": "#/definitions/anyRule"
25-
}
26-
]
27-
},
2819
"primitive": {
2920
"oneOf": [
3021
{

0 commit comments

Comments
 (0)