Skip to content

Commit 07ae785

Browse files
committed
feat: #889 support json schema
1 parent dae29a3 commit 07ae785

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed

json-schema/schema.json

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

0 commit comments

Comments
 (0)