Skip to content

Commit fdfdd55

Browse files
committed
doc: Document the schema
1 parent c763f1d commit fdfdd55

File tree

2 files changed

+265
-0
lines changed

2 files changed

+265
-0
lines changed

schema.json

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "TodoList",
4+
"type": "object",
5+
"properties": {
6+
"init": {
7+
"default": true,
8+
"type": "boolean"
9+
},
10+
"sleep": {
11+
"default": null,
12+
"anyOf": [
13+
{
14+
"$ref": "#/definitions/Duration"
15+
},
16+
{
17+
"type": "null"
18+
}
19+
]
20+
},
21+
"author": {
22+
"default": null,
23+
"type": [
24+
"string",
25+
"null"
26+
]
27+
},
28+
"commands": {
29+
"default": [],
30+
"type": "array",
31+
"items": {
32+
"$ref": "#/definitions/Command"
33+
}
34+
}
35+
},
36+
"additionalProperties": false,
37+
"definitions": {
38+
"Duration": {
39+
"type": "object",
40+
"required": [
41+
"nanos",
42+
"secs"
43+
],
44+
"properties": {
45+
"secs": {
46+
"type": "integer",
47+
"format": "uint64",
48+
"minimum": 0.0
49+
},
50+
"nanos": {
51+
"type": "integer",
52+
"format": "uint32",
53+
"minimum": 0.0
54+
}
55+
}
56+
},
57+
"Command": {
58+
"oneOf": [
59+
{
60+
"type": "string",
61+
"enum": [
62+
"head"
63+
]
64+
},
65+
{
66+
"type": "object",
67+
"required": [
68+
"label"
69+
],
70+
"properties": {
71+
"label": {
72+
"type": "string"
73+
}
74+
},
75+
"additionalProperties": false
76+
},
77+
{
78+
"type": "object",
79+
"required": [
80+
"reset"
81+
],
82+
"properties": {
83+
"reset": {
84+
"$ref": "#/definitions/Reference"
85+
}
86+
},
87+
"additionalProperties": false
88+
},
89+
{
90+
"type": "object",
91+
"required": [
92+
"tree"
93+
],
94+
"properties": {
95+
"tree": {
96+
"$ref": "#/definitions/Tree"
97+
}
98+
},
99+
"additionalProperties": false
100+
},
101+
{
102+
"type": "object",
103+
"required": [
104+
"merge"
105+
],
106+
"properties": {
107+
"merge": {
108+
"$ref": "#/definitions/Merge"
109+
}
110+
},
111+
"additionalProperties": false
112+
},
113+
{
114+
"type": "object",
115+
"required": [
116+
"branch"
117+
],
118+
"properties": {
119+
"branch": {
120+
"type": "string"
121+
}
122+
},
123+
"additionalProperties": false
124+
},
125+
{
126+
"type": "object",
127+
"required": [
128+
"tag"
129+
],
130+
"properties": {
131+
"tag": {
132+
"type": "string"
133+
}
134+
},
135+
"additionalProperties": false
136+
}
137+
]
138+
},
139+
"Reference": {
140+
"oneOf": [
141+
{
142+
"type": "object",
143+
"required": [
144+
"branch"
145+
],
146+
"properties": {
147+
"branch": {
148+
"type": "string"
149+
}
150+
},
151+
"additionalProperties": false
152+
},
153+
{
154+
"type": "object",
155+
"required": [
156+
"tag"
157+
],
158+
"properties": {
159+
"tag": {
160+
"type": "string"
161+
}
162+
},
163+
"additionalProperties": false
164+
},
165+
{
166+
"type": "object",
167+
"required": [
168+
"label"
169+
],
170+
"properties": {
171+
"label": {
172+
"type": "string"
173+
}
174+
},
175+
"additionalProperties": false
176+
}
177+
]
178+
},
179+
"Tree": {
180+
"type": "object",
181+
"required": [
182+
"tracked"
183+
],
184+
"properties": {
185+
"tracked": {
186+
"type": "object",
187+
"additionalProperties": {
188+
"$ref": "#/definitions/FileContent"
189+
}
190+
},
191+
"message": {
192+
"default": null,
193+
"type": [
194+
"string",
195+
"null"
196+
]
197+
},
198+
"author": {
199+
"default": null,
200+
"type": [
201+
"string",
202+
"null"
203+
]
204+
}
205+
},
206+
"additionalProperties": false
207+
},
208+
"FileContent": {
209+
"anyOf": [
210+
{
211+
"type": "array",
212+
"items": {
213+
"type": "integer",
214+
"format": "uint8",
215+
"minimum": 0.0
216+
}
217+
},
218+
{
219+
"type": "string"
220+
}
221+
]
222+
},
223+
"Merge": {
224+
"type": "object",
225+
"required": [
226+
"base"
227+
],
228+
"properties": {
229+
"base": {
230+
"type": "array",
231+
"items": {
232+
"$ref": "#/definitions/Reference"
233+
}
234+
},
235+
"message": {
236+
"default": null,
237+
"type": [
238+
"string",
239+
"null"
240+
]
241+
},
242+
"author": {
243+
"default": null,
244+
"type": [
245+
"string",
246+
"null"
247+
]
248+
}
249+
},
250+
"additionalProperties": false
251+
}
252+
}
253+
}

tests/schema.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![cfg(feature = "cli")]
2+
3+
#[test]
4+
fn dump_schema() {
5+
let bin_path = snapbox::cmd::cargo_bin!("git-fixture");
6+
snapbox::cmd::Command::new(bin_path)
7+
.arg("--schema")
8+
.arg("-")
9+
.assert()
10+
.success()
11+
.stdout_eq_path("schema.json");
12+
}

0 commit comments

Comments
 (0)