11package utils
22
3- /*
4- This is a temporary reference of the Open Feature schema
5- https://github.com/open-feature/playground/blob/main/schemas/flag.schema.json
6- */
3+ import _ "embed"
4+
5+ //go:embed flagd-definitions.json
6+ var schema string
7+
78func GetSchema () string {
8- return `
9- {
10- "$schema": "https://json-schema.org/draft/2020-12/schema",
11- "$id": "https://openfeature.dev/flag.schema.json",
12- "title": "OpenFeature Feature Flags",
13- "type": "object",
14- "patternProperties": {
15- "^[A-Za-z]+$": {
16- "description": "The flag key that uniquely represents the flag.",
17- "type": "object",
18- "properties": {
19- "name": {
20- "type": "string"
21- },
22- "description": {
23- "type": "string"
24- },
25- "returnType": {
26- "type": "string",
27- "enum": ["boolean", "string", "number", "object"],
28- "default": "boolean"
29- },
30- "variants": {
31- "type": "object",
32- "patternProperties": {
33- "^[A-Za-z]+$": {
34- "properties": {
35- "value": {
36- "type": ["string", "number", "boolean", "object"]
37- }
38- }
39- },
40- "additionalProperties": false
41- },
42- "minProperties": 2,
43- "default": { "enabled": true, "disabled": false }
44- },
45- "defaultVariant": {
46- "type": "string",
47- "default": "enabled"
48- },
49- "state": {
50- "type": "string",
51- "enum": ["enabled", "disabled"],
52- "default": "enabled"
53- },
54- "rules": {
55- "type": "array",
56- "items": {
57- "$ref": "#/$defs/rule"
58- },
59- "default": []
60- }
61- },
62- "required": ["state"],
63- "additionalProperties": false
64- }
65- },
66- "additionalProperties": false,
67-
68- "$defs": {
69- "rule": {
70- "type": "object",
71- "description": "A rule that ",
72- "properties": {
73- "action": {
74- "description": "The action that should be taken if at least one condition evaluates to true.",
75- "type": "object",
76- "properties": {
77- "variant": {
78- "type": "string",
79- "description": "The variant that should be return if one of the conditions evaluates to true."
80- }
81- },
82- "required": ["variant"],
83- "additionalProperties": false
84- },
85- "conditions": {
86- "type": "array",
87- "description": "The conditions that should that be evaluated.",
88- "items": {
89- "type": "object",
90- "properties": {
91- "context": {
92- "type": "string",
93- "description": "The context key that should be evaluated in this condition"
94- },
95- "op": {
96- "type": "string",
97- "description": "The operation that should be performed",
98- "enum": ["equals", "starts_with", "ends_with"]
99- },
100- "value": {
101- "type": "string",
102- "description": "The value that should be evaluated"
103- }
104- },
105- "required": ["context", "op", "value"],
106- "additionalProperties": false
107- }
108- }
109- },
110- "required": ["action", "conditions"],
111- "additionalProperties": false
112- }
113- }
114- }
115- `
116- }
9+ return schema
10+ }
0 commit comments