Skip to content

Commit 7e1b078

Browse files
SaadArdatiBirjuVachhani
authored andcommitted
Create two json schemas.
1 parent 72f13ed commit 7e1b078

File tree

2 files changed

+217
-0
lines changed

2 files changed

+217
-0
lines changed

schema/base_node.json

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "A node from the Codelessly API",
4+
"type": "object",
5+
"properties": {
6+
"type": {
7+
"type": "string",
8+
"description": "The type of the node can be anything. But the most notable types is 'rowColumn' as it represents a row or column in the editor."
9+
},
10+
"id": {
11+
"type": "string",
12+
"description": "The unique ID of the node. This is used to identify the node in the editor programmatically."
13+
},
14+
"name": {
15+
"type": "string",
16+
"description": "The user-friendly name of the node. This is used to identify the node in the editor."
17+
},
18+
"horizontalFit": {
19+
"type": "string",
20+
"enum": [
21+
"locked",
22+
"fixed",
23+
"expanded",
24+
"flexible",
25+
"shrinkWrap"
26+
],
27+
"description": "Represents the type of sizing method this node has on the horizontal axis."
28+
},
29+
"verticalFit": {
30+
"type": "string",
31+
"enum": [
32+
"locked",
33+
"fixed",
34+
"expanded",
35+
"flexible",
36+
"shrinkWrap"
37+
],
38+
"description": "Represents the type of sizing method this node has on the vertical axis."
39+
},
40+
"alignment": {
41+
"type": "object",
42+
"properties": {
43+
"data": {
44+
"type": "array",
45+
"description": "The alignment data of the node. The first number is the x alignment, the second number is the y alignment. The x alignment can be -1 (left), 0 (center), or 1 (right). The y alignment can be -1 (top), 0 (center), or 1 (bottom).",
46+
"items": {
47+
"type": "number"
48+
}
49+
}
50+
},
51+
"required": [
52+
"data"
53+
],
54+
"description": "The alignment of the node. If this node is not aligned, it will be omitted and the basic box is used as an absolute position."
55+
},
56+
"edgePins": {
57+
"type": "object",
58+
"description": "Represents the edge pins of a node to its parent. This is omitted if the node has standard EdgePins (default positioning is top-left relative using the rect property), or is in a row or column or responsive with SizeFits that aren't fixed.",
59+
"properties": {
60+
"left": {
61+
"type": [
62+
"number",
63+
"null"
64+
],
65+
"description": "Distance between node's left edge and its parent's left edge."
66+
},
67+
"top": {
68+
"type": [
69+
"number",
70+
"null"
71+
],
72+
"description": "Distance between node's top edge and its parent's top edge."
73+
},
74+
"right": {
75+
"type": [
76+
"number",
77+
"null"
78+
],
79+
"description": "Distance between node's right edge and its parent's right edge."
80+
},
81+
"bottom": {
82+
"type": [
83+
"number",
84+
"null"
85+
],
86+
"description": "Distance between node's bottom edge and its parent's bottom edge."
87+
}
88+
},
89+
"required": [
90+
"left",
91+
"top",
92+
"right",
93+
"bottom"
94+
]
95+
},
96+
"rect": {
97+
"type": "array",
98+
"items": {
99+
"type": "number"
100+
},
101+
"description": "The rect of the node. Defines the x and y absolute coordinates of this node relative to its parent, as well as the width and height of this node."
102+
},
103+
"children": {
104+
"type": "array",
105+
"items": {
106+
"type": "string"
107+
},
108+
"description": "The IDs of the children inside of this node. This is omitted if this node does not have children or does not support having children."
109+
},
110+
"rowColumnType": {
111+
"type": "string",
112+
"enum": [
113+
"row",
114+
"column"
115+
],
116+
"description": "Required if the node is of type 'rowColumn'. Represents if the node is a row or column."
117+
},
118+
"margin": {
119+
"type": "array",
120+
"items": {
121+
"type": "number"
122+
},
123+
"description": "The outer spacing to this node. If the array has 4 numbers, they represents LTRB. If the array has 2 numbers, they represent TB and LR. If the array has 1 number, it represents all sides."
124+
},
125+
"padding": {
126+
"type": "array",
127+
"items": {
128+
"type": "number"
129+
},
130+
"description": "The inner spacing to this node. If the array has 4 numbers, they represents LTRB. If the array has 2 numbers, they represent TB and LR. If the array has 1 number, it represents all sides."
131+
},
132+
"constraints": {
133+
"type": "object",
134+
"properties": {
135+
"minWidth": {
136+
"type": [
137+
"number",
138+
"null"
139+
]
140+
},
141+
"maxWidth": {
142+
"type": [
143+
"number",
144+
"null"
145+
]
146+
},
147+
"minHeight": {
148+
"type": [
149+
"number",
150+
"null"
151+
]
152+
},
153+
"maxHeight": {
154+
"type": [
155+
"number",
156+
"null"
157+
]
158+
}
159+
}
160+
}
161+
},
162+
"required": [
163+
"type",
164+
"id",
165+
"name",
166+
"horizontalFit",
167+
"verticalFit",
168+
"rect"
169+
]
170+
}

schema/copied_nodes.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "A node structure copied to the clipboard",
4+
"type": "object",
5+
"properties": {
6+
"copiedNodes": {
7+
"type": "object",
8+
"patternProperties": {
9+
"^[0-9a-zA-Z_]+$": {
10+
"type": "object",
11+
"$ref": "base_node.json",
12+
}
13+
}
14+
},
15+
"width": {
16+
"type": "number"
17+
},
18+
"height": {
19+
"type": "number"
20+
},
21+
"version": {
22+
"type": "number"
23+
},
24+
"variables": {
25+
"type": "object",
26+
"properties": {},
27+
"required": []
28+
},
29+
"conditions": {
30+
"type": "object",
31+
"properties": {},
32+
"required": []
33+
},
34+
"dataType": {
35+
"type": "string"
36+
}
37+
},
38+
"required": [
39+
"copiedNodes",
40+
"width",
41+
"height",
42+
"version",
43+
"variables",
44+
"conditions",
45+
"dataType"
46+
]
47+
}

0 commit comments

Comments
 (0)