Skip to content

Commit 808c903

Browse files
authored
feat(config): Add JSON schema files for configs (#2703)
1 parent 0793342 commit 808c903

File tree

12 files changed

+877
-19
lines changed

12 files changed

+877
-19
lines changed

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ require (
2020
github.com/riza-io/grpc-go v0.2.0
2121
github.com/spf13/cobra v1.7.0
2222
github.com/spf13/pflag v1.0.5
23+
github.com/xeipuuv/gojsonschema v1.2.0
2324
golang.org/x/sync v0.3.0
2425
google.golang.org/grpc v1.57.0
2526
google.golang.org/protobuf v1.31.0
@@ -29,6 +30,8 @@ require (
2930
require (
3031
github.com/benbjohnson/clock v1.3.5 // indirect
3132
github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c // indirect
33+
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
34+
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
3235
google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5 // indirect
3336
google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 // indirect
3437
)

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
183183
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
184184
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
185185
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
186+
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
187+
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
188+
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
189+
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
190+
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
191+
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
186192
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
187193
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
188194
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=

internal/config/v_one.json

Lines changed: 334 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,334 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"type": "object",
4+
"required": [
5+
"version"
6+
],
7+
"properties": {
8+
"version": {
9+
"const": "1"
10+
},
11+
"project": {
12+
"type": "object",
13+
"properties": {
14+
"id": {
15+
"type": "string"
16+
}
17+
}
18+
},
19+
"cloud": {
20+
"type": "object",
21+
"properties": {
22+
"organization": {
23+
"type": "string"
24+
},
25+
"project": {
26+
"type": "string"
27+
},
28+
"hostname": {
29+
"type": "string"
30+
}
31+
}
32+
},
33+
"packages": {
34+
"type": "array",
35+
"minItems": 1,
36+
"items": {
37+
"type": "object",
38+
"required": [
39+
"engine"
40+
],
41+
"properties": {
42+
"engine": {
43+
"enum": [
44+
"postgresql",
45+
"mysql",
46+
"sqlite"
47+
]
48+
},
49+
"schema": {
50+
"oneOf": [
51+
{
52+
"type": "string"
53+
},
54+
{
55+
"type": "array",
56+
"items": {
57+
"type": "string"
58+
}
59+
}
60+
]
61+
},
62+
"queries": {
63+
"oneOf": [
64+
{
65+
"type": "string"
66+
},
67+
{
68+
"type": "array",
69+
"items": {
70+
"type": "string"
71+
}
72+
}
73+
]
74+
},
75+
"database": {
76+
"type": "object",
77+
"properties": {
78+
"uri": {
79+
"type": "string"
80+
}
81+
}
82+
},
83+
"strict_function_checks": {
84+
"type": "boolean"
85+
},
86+
"strict_order_by": {
87+
"type": "boolean"
88+
},
89+
"emit_interface": {
90+
"type": "boolean"
91+
},
92+
"emit_json_tags": {
93+
"type": "boolean"
94+
},
95+
"json_tags_id_uppercase": {
96+
"type": "boolean"
97+
},
98+
"emit_db_tags": {
99+
"type": "boolean"
100+
},
101+
"emit_prepared_queries": {
102+
"type": "boolean"
103+
},
104+
"emit_exact_table_names": {
105+
"type": "boolean"
106+
},
107+
"emit_empty_slices": {
108+
"type": "boolean"
109+
},
110+
"emit_exported_queries": {
111+
"type": "boolean"
112+
},
113+
"emit_result_struct_pointers": {
114+
"type": "boolean"
115+
},
116+
"emit_params_struct_pointers": {
117+
"type": "boolean"
118+
},
119+
"emit_methods_with_db_argument": {
120+
"type": "boolean"
121+
},
122+
"emit_pointers_for_null_types": {
123+
"type": "boolean"
124+
},
125+
"emit_enum_valid_method": {
126+
"type": "boolean"
127+
},
128+
"emit_all_enum_values": {
129+
"type": "boolean"
130+
},
131+
"json_tags_case_style": {
132+
"type": "string"
133+
},
134+
"package": {
135+
"type": "string"
136+
},
137+
"out": {
138+
"type": "string"
139+
},
140+
"overrides": {
141+
"type": "array",
142+
"items": {
143+
"type": "object",
144+
"properties": {
145+
"go_type": {
146+
"oneOf": [
147+
{
148+
"type": "object",
149+
"properties": {
150+
"import": {
151+
"type": "string"
152+
},
153+
"package": {
154+
"type": "string"
155+
},
156+
"type": {
157+
"type": "string"
158+
},
159+
"pointer": {
160+
"type": "boolean"
161+
},
162+
"slice": {
163+
"type": "boolean"
164+
},
165+
"spec": {
166+
"type": "string"
167+
},
168+
"builtin": {
169+
"type": "boolean"
170+
}
171+
}
172+
},
173+
{
174+
"type": "string"
175+
}
176+
]
177+
},
178+
"go_struct_tag": {
179+
"type": "string"
180+
},
181+
"db_type": {
182+
"type": "string"
183+
},
184+
"engine": {
185+
"enum": [
186+
"postgresql",
187+
"mysql",
188+
"sqlite"
189+
]
190+
},
191+
"nullable": {
192+
"type": "boolean"
193+
},
194+
"unsigned": {
195+
"type": "boolean"
196+
},
197+
"column": {
198+
"type": "string"
199+
}
200+
}
201+
}
202+
},
203+
"sql_package": {
204+
"type": "string"
205+
},
206+
"sql_driver": {
207+
"type": "string"
208+
},
209+
"output_batch_file_name": {
210+
"type": "string"
211+
},
212+
"output_db_file_name": {
213+
"type": "string"
214+
},
215+
"output_models_file_name": {
216+
"type": "string"
217+
},
218+
"output_querier_file_name": {
219+
"type": "string"
220+
},
221+
"output_files_suffix": {
222+
"type": "string"
223+
},
224+
"inflection_exclude_table_names": {
225+
"type": "array",
226+
"items": {
227+
"type": "string"
228+
}
229+
},
230+
"query_parameter_limit": {
231+
"type": "integer"
232+
},
233+
"omit_unused_structs": {
234+
"type": "boolean"
235+
},
236+
"rules": {
237+
"type": "array",
238+
"items": {
239+
"type": "string"
240+
}
241+
}
242+
}
243+
}
244+
},
245+
"overrides": {
246+
"type": "array",
247+
"items": {
248+
"type": "object",
249+
"properties": {
250+
"go_type": {
251+
"oneOf": [
252+
{
253+
"type": "object",
254+
"properties": {
255+
"import": {
256+
"type": "string"
257+
},
258+
"package": {
259+
"type": "string"
260+
},
261+
"type": {
262+
"type": "string"
263+
},
264+
"pointer": {
265+
"type": "boolean"
266+
},
267+
"slice": {
268+
"type": "boolean"
269+
},
270+
"spec": {
271+
"type": "string"
272+
},
273+
"builtin": {
274+
"type": "boolean"
275+
}
276+
}
277+
},
278+
{
279+
"type": "string"
280+
}
281+
]
282+
},
283+
"go_struct_tag": {
284+
"type": "string"
285+
},
286+
"db_type": {
287+
"type": "string"
288+
},
289+
"engine": {
290+
"enum": [
291+
"postgresql",
292+
"mysql",
293+
"sqlite"
294+
]
295+
},
296+
"nullable": {
297+
"type": "boolean"
298+
},
299+
"unsigned": {
300+
"type": "boolean"
301+
},
302+
"column": {
303+
"type": "string"
304+
}
305+
}
306+
}
307+
}
308+
},
309+
"rename": {
310+
"type": "object",
311+
"patternProperties": {
312+
".*": {
313+
"type": "string"
314+
}
315+
}
316+
},
317+
"rules": {
318+
"type": "array",
319+
"items": {
320+
"type": "object",
321+
"properties": {
322+
"name": {
323+
"type": "string"
324+
},
325+
"rule": {
326+
"type": "string"
327+
},
328+
"message": {
329+
"type": "string"
330+
}
331+
}
332+
}
333+
}
334+
}

0 commit comments

Comments
 (0)