Skip to content

Commit d7eb645

Browse files
Add: update definition schema with new structure and validation rules
1 parent f56a5b7 commit d7eb645

File tree

1 file changed

+270
-34
lines changed

1 file changed

+270
-34
lines changed

src/schema/v1/definition.json

Lines changed: 270 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,255 @@
11
{
22
"$id": "https://static.dicebear.com/schema/v1/definition.json",
33
"$schema": "https://json-schema.org/draft/2020-12/schema",
4-
"title": "DiceBear definition schema",
4+
"$defs": {
5+
"name": {
6+
"type": "string",
7+
"pattern": "^[a-zA-Z0-9]+$"
8+
},
9+
"element": {
10+
"type": "object",
11+
"properties": {
12+
"name": {
13+
"type": "string",
14+
"enum": [
15+
"#text",
16+
"circle",
17+
"clipPath",
18+
"defs",
19+
"desc",
20+
"ellipse",
21+
"feBlend",
22+
"feColorMatrix",
23+
"feComponentTransfer",
24+
"feComposite",
25+
"feConvolveMatrix",
26+
"feDiffuseLighting",
27+
"feDisplacementMap",
28+
"feDistantLight",
29+
"feDropShadow",
30+
"feFlood",
31+
"feFuncA",
32+
"feFuncB",
33+
"feFuncG",
34+
"feFuncR",
35+
"feGaussianBlur",
36+
"feImage",
37+
"feMerge",
38+
"feMergeNode",
39+
"feMorphology",
40+
"feOffset",
41+
"fePointLight",
42+
"feSpecularLighting",
43+
"feSpotLight",
44+
"feTile",
45+
"feTurbulence",
46+
"filter",
47+
"g",
48+
"image",
49+
"line",
50+
"linearGradient",
51+
"marker",
52+
"mask",
53+
"metadata",
54+
"mpath",
55+
"path",
56+
"pattern",
57+
"polygon",
58+
"polyline",
59+
"radialGradient",
60+
"rect",
61+
"stop",
62+
"style",
63+
"svg",
64+
"switch",
65+
"symbol",
66+
"text",
67+
"textPath",
68+
"title",
69+
"tspan",
70+
"use",
71+
"view"
72+
]
73+
},
74+
"value": {
75+
"type": "string"
76+
},
77+
"attributes": {
78+
"$ref": "#/$defs/attributes"
79+
},
80+
"children": {
81+
"type": "array",
82+
"items": {
83+
"$ref": "#"
84+
}
85+
}
86+
},
87+
"required": ["name"]
88+
},
89+
"attributes": {
90+
"type": "object",
91+
"properties": {
92+
"alignment-baseline": { "type": "string" },
93+
"amplitude": { "type": "string" },
94+
"azimuth": { "type": "string" },
95+
"baseFrequency": { "type": "string" },
96+
"baseline-shift": { "type": "string" },
97+
"bias": { "type": "string" },
98+
"class": { "type": "string" },
99+
"clipPathUnits": { "type": "string" },
100+
"clip-path": { "type": "string" },
101+
"clip-rule": { "type": "string" },
102+
"color": { "type": "string" },
103+
"color-interpolation": { "type": "string" },
104+
"color-interpolation-filters": { "type": "string" },
105+
"crossorigin": { "type": "string" },
106+
"cx": { "type": "string" },
107+
"cy": { "type": "string" },
108+
"d": { "type": "string" },
109+
"decoding": { "type": "string" },
110+
"diffuseConstant": { "type": "string" },
111+
"direction": { "type": "string" },
112+
"display": { "type": "string" },
113+
"divisor": { "type": "string" },
114+
"dx": { "type": "string" },
115+
"dy": { "type": "string" },
116+
"edgeMode": { "type": "string" },
117+
"elevation": { "type": "string" },
118+
"exponent": { "type": "string" },
119+
"fill": { "type": "string" },
120+
"fill-opacity": { "type": "string" },
121+
"fill-rule": { "type": "string" },
122+
"filter": { "type": "string" },
123+
"filterUnits": { "type": "string" },
124+
"flood-color": { "type": "string" },
125+
"flood-opacity": { "type": "string" },
126+
"font-family": { "type": "string" },
127+
"font-size": { "type": "string" },
128+
"font-size-adjust": { "type": "string" },
129+
"font-style": { "type": "string" },
130+
"font-variant": { "type": "string" },
131+
"font-weight": { "type": "string" },
132+
"fx": { "type": "string" },
133+
"fy": { "type": "string" },
134+
"gradientTransform": { "type": "string" },
135+
"gradientUnits": { "type": "string" },
136+
"height": { "type": "string" },
137+
"href": {
138+
"anyOf": [
139+
{
140+
"type": "string",
141+
"pattern": "^#[a-zA-Z0-9]+$"
142+
},
143+
{
144+
"type": "string",
145+
"pattern": "^data:img/(png|gif|jpg|jpeg|webp|avif);base64,[a-zA-Z0-9+/=]+$"
146+
}
147+
]
148+
},
149+
"id": { "type": "string" },
150+
"image-rendering": { "type": "string" },
151+
"in": { "type": "string" },
152+
"in2": { "type": "string" },
153+
"intercept": { "type": "string" },
154+
"k1": { "type": "string" },
155+
"k2": { "type": "string" },
156+
"k3": { "type": "string" },
157+
"k4": { "type": "string" },
158+
"kernelMatrix": { "type": "string" },
159+
"kernelUnitLength": { "type": "string" },
160+
"lang": { "type": "string" },
161+
"lengthAdjust": { "type": "string" },
162+
"letter-spacing": { "type": "string" },
163+
"lighting-color": { "type": "string" },
164+
"marker-end": { "type": "string" },
165+
"marker-mid": { "type": "string" },
166+
"marker-start": { "type": "string" },
167+
"markerHeight": { "type": "string" },
168+
"markerUnits": { "type": "string" },
169+
"markerWidth": { "type": "string" },
170+
"mask": { "type": "string" },
171+
"maskContentUnits": { "type": "string" },
172+
"maskUnits": { "type": "string" },
173+
"media": { "type": "string" },
174+
"method": { "type": "string" },
175+
"mode": { "type": "string" },
176+
"numOctaves": { "type": "string" },
177+
"offset": { "type": "string" },
178+
"opacity": { "type": "string" },
179+
"operator": { "type": "string" },
180+
"order": { "type": "string" },
181+
"orient": { "type": "string" },
182+
"overflow": { "type": "string" },
183+
"paint-order": { "type": "string" },
184+
"path": { "type": "string" },
185+
"pathLength": { "type": "string" },
186+
"patternContentUnits": { "type": "string" },
187+
"patternTransform": { "type": "string" },
188+
"patternUnits": { "type": "string" },
189+
"points": { "type": "string" },
190+
"preserveAlpha": { "type": "string" },
191+
"preserveAspectRatio": { "type": "string" },
192+
"primitiveUnits": { "type": "string" },
193+
"r": { "type": "string" },
194+
"radius": { "type": "string" },
195+
"refX": { "type": "string" },
196+
"refY": { "type": "string" },
197+
"result": { "type": "string" },
198+
"rx": { "type": "string" },
199+
"ry": { "type": "string" },
200+
"scale": { "type": "string" },
201+
"seed": { "type": "string" },
202+
"shape-rendering": { "type": "string" },
203+
"slope": { "type": "string" },
204+
"specularConstant": { "type": "string" },
205+
"specularExponent": { "type": "string" },
206+
"spreadMethod": { "type": "string" },
207+
"startOffset": { "type": "string" },
208+
"stdDeviation": { "type": "string" },
209+
"stitchTiles": { "type": "string" },
210+
"stop-color": { "type": "string" },
211+
"stop-opacity": { "type": "string" },
212+
"stroke": { "type": "string" },
213+
"stroke-dasharray": { "type": "string" },
214+
"stroke-dashoffset": { "type": "string" },
215+
"stroke-linecap": { "type": "string" },
216+
"stroke-linejoin": { "type": "string" },
217+
"stroke-miterlimit": { "type": "string" },
218+
"stroke-opacity": { "type": "string" },
219+
"stroke-width": { "type": "string" },
220+
"style": { "type": "string" },
221+
"surfaceScale": { "type": "string" },
222+
"systemLanguage": { "type": "string" },
223+
"tabindex": { "type": "string" },
224+
"tableValues": { "type": "string" },
225+
"targetX": { "type": "string" },
226+
"targetY": { "type": "string" },
227+
"text-anchor": { "type": "string" },
228+
"text-decoration": { "type": "string" },
229+
"text-rendering": { "type": "string" },
230+
"textLength": { "type": "string" },
231+
"transform": { "type": "string" },
232+
"transform-origin": { "type": "string" },
233+
"type": { "type": "string" },
234+
"values": { "type": "string" },
235+
"viewBox": { "type": "string" },
236+
"visibility": { "type": "string" },
237+
"width": { "type": "string" },
238+
"word-spacing": { "type": "string" },
239+
"writing-mode": { "type": "string" },
240+
"x": { "type": "string" },
241+
"x1": { "type": "string" },
242+
"x2": { "type": "string" },
243+
"xChannelSelector": { "type": "string" },
244+
"y": { "type": "string" },
245+
"y1": { "type": "string" },
246+
"y2": { "type": "string" },
247+
"yChannelSelector": { "type": "string" },
248+
"z": { "type": "string" }
249+
},
250+
"additionalProperties": false
251+
}
252+
},
5253
"type": "object",
6254
"properties": {
7255
"meta": {
@@ -46,25 +294,13 @@
46294
}
47295
},
48296
"attributes": {
49-
"type": "array",
50-
"items": {
51-
"type": "object",
52-
"properties": {
53-
"name": {
54-
"type": "string"
55-
},
56-
"value": {
57-
"type": "string"
58-
}
59-
},
60-
"required": ["name", "value"]
61-
}
297+
"$ref": "#/$defs/attributes"
62298
},
63299
"body": {
64300
"type": "object",
65301
"properties": {
66-
"content": {
67-
"type": "string"
302+
"element": {
303+
"$ref": "#/$defs/element"
68304
},
69305
"width": {
70306
"type": "number",
@@ -77,17 +313,17 @@
77313
"minimum": 1
78314
}
79315
},
80-
"required": ["content", "width", "height"]
316+
"required": ["element", "width", "height"]
81317
},
82318
"components": {
83319
"type": "array",
84-
"description": "Specifies the components of the avatar. The PRNG randomly selects a component from each component group.",
320+
"description": "Specifies the components of the avatar. The PRNG randomly selects a component variant from each component.",
85321
"items": {
86322
"type": "object",
87323
"properties": {
88324
"name": {
89-
"type": "string",
90-
"description": "The alpha-numeric name of the component group."
325+
"$ref": "#/$defs/name",
326+
"description": "The alpha-numeric name of the component."
91327
},
92328
"width": {
93329
"type": "number",
@@ -99,7 +335,7 @@
99335
},
100336
"probability": {
101337
"type": "number",
102-
"description": "The probability of this component group to be displayed in the avatar. If not set, the component group is always displayed.",
338+
"description": "The probability of this component to be displayed in the avatar. If not set, the component is always displayed.",
103339
"minimum": 0,
104340
"maximum": 100
105341
},
@@ -132,19 +368,19 @@
132368
},
133369
"variants": {
134370
"type": "array",
135-
"description": "Specifies the component variants for this component group.",
371+
"description": "Specifies the component variants for this component.",
136372
"items": {
137373
"type": "object",
138374
"properties": {
139375
"name": {
140-
"type": "string",
141-
"description": "The alpha-numeric name of the component option."
376+
"$ref": "#/$defs/name",
377+
"description": "The alpha-numeric name of the component variant."
142378
},
143379
"default": {
144380
"type": "boolean"
145381
},
146-
"content": {
147-
"type": "string"
382+
"element": {
383+
"$ref": "#/$defs/element"
148384
}
149385
},
150386
"required": ["name", "content"]
@@ -156,32 +392,32 @@
156392
},
157393
"colors": {
158394
"type": "array",
159-
"description": "Specifies color options for the avatar. The PRNG randomly selects a color from each color option.",
395+
"description": "Specifies colors for the avatar. The PRNG randomly selects a color from each color.",
160396
"items": {
161397
"type": "object",
162398
"properties": {
163399
"name": {
164-
"type": "string",
165-
"description": "The alpha-numeric name of the color option."
400+
"$ref": "#/$defs/name",
401+
"description": "The alpha-numeric name of the color."
166402
},
167403
"values": {
168404
"type": "array",
169-
"description": "An array of default hexadecimal color values for this color option.",
405+
"description": "An array of default hexadecimal color values for this color.",
170406
"items": {
171407
"type": "string",
172408
"pattern": "^#?([a-fA-F0-9]{3}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$"
173409
}
174410
},
175411
"notEqualTo": {
176412
"type": "array",
177-
"description": "If set, the color randomly selected by the PRNG should be different from this color options.",
413+
"description": "If set, the color randomly selected by the PRNG should be different from this color.",
178414
"items": {
179-
"type": "string"
415+
"$ref": "#/$defs/name"
180416
}
181417
},
182418
"contrastTo": {
183-
"type": "string",
184-
"description": "If set, a color is selected from the values that have the highest contrast to this color option. If the value is not set, the color is selected randomly by the PRNG."
419+
"$ref": "#/$defs/name",
420+
"description": "If set, a color is selected from the values that have the highest contrast to this color. If the value is not set, the color is selected randomly by the PRNG."
185421
}
186422
},
187423
"required": ["name", "values"]

0 commit comments

Comments
 (0)