Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added json-schema-form meta schema #6

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 188 additions & 0 deletions json-schema-form.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, @jguddas for your contribution! You were the first one 😄 Approved, merging it now :)

Copy link
Collaborator

@sandrina-p sandrina-p May 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last question @jguddas. You called this "hyper" schema, but in my understanding it's a meta schema, right? A "json hyper-schema" refers to an outdated variant of JSON schemas.

Or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are right, meta schema is the right term.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, merged as chore: because this does not influence the library itself (src/). Thanks again :)

"$schema": "http://json-schema.org/draft-07/schema#",
"title": "JSON json-schema-form-Schema",
"definitions": {
"schemaArray": {
"allOf": [
{
"$ref": "http://json-schema.org/draft-07/schema#/definitions/schemaArray"
},
{
"items": { "$ref": "#" }
}
]
}
},
"allOf": [{ "$ref": "http://json-schema.org/draft-07/schema#" }],
"properties": {
"additionalItems": { "$ref": "#" },
"additionalProperties": { "$ref": "#" },
"dependencies": {
"additionalProperties": {
"anyOf": [{ "$ref": "#" }, { "type": "array" }]
}
},
"items": {
"anyOf": [{ "$ref": "#" }, { "$ref": "#/definitions/schemaArray" }]
},
"definitions": {
"additionalProperties": { "$ref": "#" }
},
"patternProperties": {
"additionalProperties": { "$ref": "#" }
},
"properties": {
"additionalProperties": { "$ref": "#" }
},
"if": { "$ref": "#" },
"then": { "$ref": "#" },
"else": { "$ref": "#" },
"allOf": { "$ref": "#/definitions/schemaArray" },
"anyOf": { "$ref": "#/definitions/schemaArray" },
"oneOf": { "$ref": "#/definitions/schemaArray" },
"not": { "$ref": "#" },
"contains": { "$ref": "#" },
"propertyNames": { "$ref": "#" },
"x-jsf-order": {
"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.",
sandrina-p marked this conversation as resolved.
Show resolved Hide resolved
"$ref": "http://json-schema.org/draft-07/schema#/definitions/stringArray"
},
"x-jsf-errorMessage": {
"type": "object",
"additionalProperties": false,
"properties": {
"type": {
"type": "string",
"description": "Message shown when the value is not of the correct type."
},
"required": {
"type": "string",
"description": "Message shown when the value is required and not provided."
},
"minimum": {
"type": "string",
"description": "Message shown when the value is less than the minimum value."
},
"minLength": {
"type": "string",
"description": "Message shown when the value is less than the minimum length."
},
"maximum": {
"type": "string",
"description": "Message shown when the value is greater than the maximum value."
},
"maxLength": {
"type": "string",
"description": "Message shown when the value is greater than the maximum length."
},
"pattern": {
"type": "string",
"description": "Message shown when the value is not the correct format and does not match the pattern property."
},
"maxFileSize": {
"type": "string",
"description": "Message shown when the file size is greater than the maximum file size."
},
"accept": {
"type": "string",
"description": "Message shown when the file type is not accepted."
}
}
},
"x-jsf-presentation": {
"type": "object",
"description": "Presentation overrides for the schema",
"properties": {
"inputType": {
"description": "Input type for the generated UI field",
"type": "string",
"anyOf": [
{
"const": "text",
"description": "Similar to the native HTML input with text type."
},
{
"const": "select",
"description": "Similar to the native HTML select element."
},
{
"const": "radio",
"description": "Similar to a native HTML input with radio type."
},
{
"const": "number",
"description": "Similar to the native HTML input with number type."
},
{
"const": "date",
"description": "Expects a value with format YYY-MM-DD."
},
{
"const": "checkbox",
"description": "Similar to the native HTML input with checkbox type."
},
{
"const": "email",
"description": "Similar to the native HTML input with email type."
},
{
"const": "file",
"description": "Similar to the native HTML input with file type."
},
{
"const": "fieldset",
"description": "Groups multiple Fields inside. Its expected value is a nested object."
},
{
"const": "group-array",
"description": "A list of inputs that can be repeated. Its expected value is an array."
},
{
"type": "string",
"description": "Any arbitrary custom inputType you might want to represent your UI Field."
}
jguddas marked this conversation as resolved.
Show resolved Hide resolved
]
},
"accept": {
"description": "For `inputType: \"file\"`. The accepted file types, as a comma separated string.",
"type": "string"
},
"description": {
"description": "Field description with HTML. If you don't need HTML, please use the native description keyword.",
"type": "string"
},
"statement": {
"description": "Special message about the field. Useful in cases where this message is based on the field value.",
"type": "object",
"properties": {
"title": {
"type": "string"
},
"description": {
"description": "The sentence itself. Might include HTML.",
"type": "string"
},
"severity": {
"description": "Defines the type of message.",
"anyOf": [
{ "type": "string", "const": "info" },
{ "type": "string", "const": "warning" },
{ "type": "string", "const": "error" },
{ "type": "string", "const": "success" },
{}
]
}
}
},
"maxFileSize": {
"description": "For `inputType: \"file\"`. The maximum file size in KB. It's used to enhanced Yup validation.",
"type": "number"
},
"addFieldText": {
"description": "Used in `group-array` fields. The button text to add a new field.",
"type": "string"
}
}
}
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"files": [
"dist",
"src/tests",
"json-schema-form.schema.json",
"README.md",
"CHANGELOG.md",
"LICENSE.md"
Expand Down