Skip to content

Commit 414a5fe

Browse files
authored
chore: added json-schema-form meta schema (#6)
* feat: added json-schema-form hyper schema * fix: added descriptions and type property to x-jsf-errorMessage * fix: loosened restriction for x-jsf-presentation and inputType * fix: fixed multiple match error for inputType * fix: reduced restrictiveness of statement field * chore: added json-schema-form.schema.json to package.json files
1 parent 4b5d011 commit 414a5fe

File tree

2 files changed

+189
-0
lines changed

2 files changed

+189
-0
lines changed

json-schema-form.schema.json

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "JSON json-schema-form-Schema",
4+
"definitions": {
5+
"schemaArray": {
6+
"allOf": [
7+
{
8+
"$ref": "http://json-schema.org/draft-07/schema#/definitions/schemaArray"
9+
},
10+
{
11+
"items": { "$ref": "#" }
12+
}
13+
]
14+
}
15+
},
16+
"allOf": [{ "$ref": "http://json-schema.org/draft-07/schema#" }],
17+
"properties": {
18+
"additionalItems": { "$ref": "#" },
19+
"additionalProperties": { "$ref": "#" },
20+
"dependencies": {
21+
"additionalProperties": {
22+
"anyOf": [{ "$ref": "#" }, { "type": "array" }]
23+
}
24+
},
25+
"items": {
26+
"anyOf": [{ "$ref": "#" }, { "$ref": "#/definitions/schemaArray" }]
27+
},
28+
"definitions": {
29+
"additionalProperties": { "$ref": "#" }
30+
},
31+
"patternProperties": {
32+
"additionalProperties": { "$ref": "#" }
33+
},
34+
"properties": {
35+
"additionalProperties": { "$ref": "#" }
36+
},
37+
"if": { "$ref": "#" },
38+
"then": { "$ref": "#" },
39+
"else": { "$ref": "#" },
40+
"allOf": { "$ref": "#/definitions/schemaArray" },
41+
"anyOf": { "$ref": "#/definitions/schemaArray" },
42+
"oneOf": { "$ref": "#/definitions/schemaArray" },
43+
"not": { "$ref": "#" },
44+
"contains": { "$ref": "#" },
45+
"propertyNames": { "$ref": "#" },
46+
"x-jsf-order": {
47+
"description": "This keyword defines the order of fields for a given form or fieldset. It's placed at the schema root and inside of each fieldset.",
48+
"$ref": "http://json-schema.org/draft-07/schema#/definitions/stringArray"
49+
},
50+
"x-jsf-errorMessage": {
51+
"type": "object",
52+
"additionalProperties": false,
53+
"properties": {
54+
"type": {
55+
"type": "string",
56+
"description": "Message shown when the value is not of the correct type."
57+
},
58+
"required": {
59+
"type": "string",
60+
"description": "Message shown when the value is required and not provided."
61+
},
62+
"minimum": {
63+
"type": "string",
64+
"description": "Message shown when the value is less than the minimum value."
65+
},
66+
"minLength": {
67+
"type": "string",
68+
"description": "Message shown when the value is less than the minimum length."
69+
},
70+
"maximum": {
71+
"type": "string",
72+
"description": "Message shown when the value is greater than the maximum value."
73+
},
74+
"maxLength": {
75+
"type": "string",
76+
"description": "Message shown when the value is greater than the maximum length."
77+
},
78+
"pattern": {
79+
"type": "string",
80+
"description": "Message shown when the value is not the correct format and does not match the pattern property."
81+
},
82+
"maxFileSize": {
83+
"type": "string",
84+
"description": "Message shown when the file size is greater than the maximum file size."
85+
},
86+
"accept": {
87+
"type": "string",
88+
"description": "Message shown when the file type is not accepted."
89+
}
90+
}
91+
},
92+
"x-jsf-presentation": {
93+
"type": "object",
94+
"description": "Presentation overrides for the schema",
95+
"properties": {
96+
"inputType": {
97+
"description": "Input type for the generated UI field",
98+
"type": "string",
99+
"anyOf": [
100+
{
101+
"const": "text",
102+
"description": "Similar to the native HTML input with text type."
103+
},
104+
{
105+
"const": "select",
106+
"description": "Similar to the native HTML select element."
107+
},
108+
{
109+
"const": "radio",
110+
"description": "Similar to a native HTML input with radio type."
111+
},
112+
{
113+
"const": "number",
114+
"description": "Similar to the native HTML input with number type."
115+
},
116+
{
117+
"const": "date",
118+
"description": "Expects a value with format YYY-MM-DD."
119+
},
120+
{
121+
"const": "checkbox",
122+
"description": "Similar to the native HTML input with checkbox type."
123+
},
124+
{
125+
"const": "email",
126+
"description": "Similar to the native HTML input with email type."
127+
},
128+
{
129+
"const": "file",
130+
"description": "Similar to the native HTML input with file type."
131+
},
132+
{
133+
"const": "fieldset",
134+
"description": "Groups multiple Fields inside. Its expected value is a nested object."
135+
},
136+
{
137+
"const": "group-array",
138+
"description": "A list of inputs that can be repeated. Its expected value is an array."
139+
},
140+
{
141+
"type": "string",
142+
"description": "Any arbitrary custom inputType you might want to represent your UI Field."
143+
}
144+
]
145+
},
146+
"accept": {
147+
"description": "For `inputType: \"file\"`. The accepted file types, as a comma separated string.",
148+
"type": "string"
149+
},
150+
"description": {
151+
"description": "Field description with HTML. If you don't need HTML, please use the native description keyword.",
152+
"type": "string"
153+
},
154+
"statement": {
155+
"description": "Special message about the field. Useful in cases where this message is based on the field value.",
156+
"type": "object",
157+
"properties": {
158+
"title": {
159+
"type": "string"
160+
},
161+
"description": {
162+
"description": "The sentence itself. Might include HTML.",
163+
"type": "string"
164+
},
165+
"severity": {
166+
"description": "Defines the type of message.",
167+
"anyOf": [
168+
{ "type": "string", "const": "info" },
169+
{ "type": "string", "const": "warning" },
170+
{ "type": "string", "const": "error" },
171+
{ "type": "string", "const": "success" },
172+
{}
173+
]
174+
}
175+
}
176+
},
177+
"maxFileSize": {
178+
"description": "For `inputType: \"file\"`. The maximum file size in KB. It's used to enhanced Yup validation.",
179+
"type": "number"
180+
},
181+
"addFieldText": {
182+
"description": "Used in `group-array` fields. The button text to add a new field.",
183+
"type": "string"
184+
}
185+
}
186+
}
187+
}
188+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"files": [
1515
"dist",
1616
"src/tests",
17+
"json-schema-form.schema.json",
1718
"README.md",
1819
"CHANGELOG.md",
1920
"LICENSE.md"

0 commit comments

Comments
 (0)