Skip to content

Commit 0701d7c

Browse files
committed
feat: #889 support json schema
1 parent dae29a3 commit 0701d7c

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed

json-schema/schema.json

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
{
2+
"$schema": "https://json-schema.org/draft-07/schema",
3+
"description": "Configuration files for sql-formatter",
4+
"title": "SQL Formatter",
5+
"additionalProperties": false,
6+
"type": "object",
7+
"properties": {
8+
"dataTypeCase": {
9+
"description": "Converts data types to upper- or lowercase.",
10+
"$ref": "#/$defs/casing"
11+
},
12+
"denseOperators": {
13+
"description": "Decides whitespace around operators.",
14+
"type": "boolean"
15+
},
16+
"expressionWidth": {
17+
"description": "Determines maximum length of parenthesized expressions.",
18+
"type": "number",
19+
"default": 50,
20+
"exclusiveMinimum": 0
21+
},
22+
"functionCase": {
23+
"description": "Converts function names to upper- or lowercase.",
24+
"$ref": "#/$defs/casing"
25+
},
26+
"identifierCase": {
27+
"description": "[Experimental] Converts identifiers to upper- or lowercase. Only unquoted identifiers are converted.",
28+
"$ref": "#/$defs/casing"
29+
},
30+
"keywordCase": {
31+
"description": "Converts reserved keywords to upper- or lowercase.",
32+
"$ref": "#/$defs/casing"
33+
},
34+
"language": {
35+
"description": "Specifies the SQL dialect to use.",
36+
"enum": [
37+
"sql",
38+
"bigquery",
39+
"db2",
40+
"db2i",
41+
"duckdb",
42+
"hive",
43+
"mariadb",
44+
"mysql",
45+
"tidb",
46+
"n1ql",
47+
"plsql",
48+
"postgresql",
49+
"redshift",
50+
"singlestoredb",
51+
"snowflake",
52+
"spark",
53+
"sqlite",
54+
"transactsql",
55+
"trino"
56+
]
57+
},
58+
"linesBetweenQueries": {
59+
"description": "Decides how many empty lines to leave between SQL statements.",
60+
"type": "number",
61+
"default": 1,
62+
"exclusiveMinimum": 0
63+
},
64+
"logicalOperatorNewline": {
65+
"description": "Decides newline placement before or after logical operators (AND, OR, XOR).",
66+
"enum": ["before", "after"],
67+
"default": "before"
68+
},
69+
"newlineBeforeSemicolon": {
70+
"description": "Whether to place query separator (;) on a separate line.",
71+
"type": "boolean",
72+
"default": false
73+
},
74+
"paramTypes": {
75+
"description": "Whether to place query separator (;) on a separate line.",
76+
"type": "object",
77+
"additionalProperties": false,
78+
"properties": {
79+
"positional": {
80+
"description": "True to enable ? placeholders, false to disable them.",
81+
"type": "boolean"
82+
},
83+
"numbered": {
84+
"description": "To allow for ?1, :2 and/or $3 syntax for numbered placholders",
85+
"type": "array",
86+
"items": {
87+
"enum": ["?", ":", "$"]
88+
}
89+
},
90+
"named": {
91+
"description": "To allow for :name, @name and/or $name syntax for named placholders.",
92+
"type": "array",
93+
"items": {
94+
"enum": [":", "@", "$"]
95+
}
96+
},
97+
"quoted": {
98+
"description": "To allow for :\"name\", @\"name\" and/or $\"name\" syntax for quoted placholders.",
99+
"type": "array",
100+
"items": {
101+
"enum": [":", "@", "$"]
102+
}
103+
},
104+
"custom": {
105+
"description": "o allow for :name, @name and/or $name syntax for named placholders.",
106+
"type": "array",
107+
"items": {
108+
"type": "object",
109+
"properties": {
110+
"regex": {
111+
"type": "string"
112+
}
113+
},
114+
"required": ["regex"]
115+
}
116+
}
117+
},
118+
"examples": [{ "positional": true, "numbered": [], "named": [":", "@"] }]
119+
},
120+
"tabWidth": {
121+
"description": "Specifies amount of spaces to be used for indentation.",
122+
"oneOf": [
123+
{
124+
"type": "integer",
125+
"exclusiveMinimum": 0
126+
},
127+
{
128+
"const": "\t"
129+
}
130+
]
131+
},
132+
"useTabs": {
133+
"description": "Uses TAB characters for indentation. `tabWidth` will be ignored",
134+
"type": "boolean",
135+
"default": false
136+
}
137+
},
138+
"required": ["language"],
139+
"$defs": { "casing": { "enum": ["preserve", "upper", "lower"] } }
140+
}

0 commit comments

Comments
 (0)