Skip to content

Instantly share code, notes, and snippets.

@ayoubbensakhria
Last active May 10, 2023 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayoubbensakhria/d88a7847f26cb863cb757ab53ba3d825 to your computer and use it in GitHub Desktop.
Save ayoubbensakhria/d88a7847f26cb863cb757ab53ba3d825 to your computer and use it in GitHub Desktop.
{
"title": "A list of tasks",
"type": "object",
"required": [
"title"
],
"properties": {
"title": {
"type": "string",
"title": "Task list title"
},
"tasks": {
"type": "array",
"title": "Tasks",
"items": {
"type": "object",
"required": [
"title"
],
"properties": {
"title": {
"type": "string",
"title": "Title",
"description": "A sample title"
},
"details": {
"type": "string",
"title": "Task details",
"description": "Enter the task details"
},
"done": {
"type": "boolean",
"title": "Done?",
"default": false
}
}
}
}
}
}
{
"definitions": {
"Thing": {
"type": "object",
"properties": {
"name": {
"type": "string",
"default": "Default name"
}
}
}
},
"type": "object",
"properties": {
"listOfStrings": {
"type": "array",
"title": "A list of strings",
"items": {
"type": "string",
"default": "bazinga"
}
},
"multipleChoicesList": {
"type": "array",
"title": "A multiple choices list",
"items": {
"type": "string",
"enum": [
"foo",
"bar",
"fuzz",
"qux"
]
},
"uniqueItems": true
},
"fixedItemsList": {
"type": "array",
"title": "A list of fixed items",
"items": [
{
"title": "A string value",
"type": "string",
"default": "lorem ipsum"
},
{
"title": "a boolean value",
"type": "boolean"
}
],
"additionalItems": {
"title": "Additional item",
"type": "number"
}
},
"minItemsList": {
"type": "array",
"title": "A list with a minimal number of items",
"minItems": 3,
"items": {
"$ref": "#/definitions/Thing"
}
},
"defaultsAndMinItems": {
"type": "array",
"title": "List and item level defaults",
"minItems": 5,
"default": [
"carp",
"trout",
"bream"
],
"items": {
"type": "string",
"default": "unidentified"
}
},
"nestedList": {
"type": "array",
"title": "Nested list",
"items": {
"type": "array",
"title": "Inner list",
"items": {
"type": "string",
"default": "lorem ipsum"
}
}
},
"unorderable": {
"title": "Unorderable items",
"type": "array",
"items": {
"type": "string",
"default": "lorem ipsum"
}
},
"copyable": {
"title": "Copyable items",
"type": "array",
"items": {
"type": "string",
"default": "lorem ipsum"
}
},
"unremovable": {
"title": "Unremovable items",
"type": "array",
"items": {
"type": "string",
"default": "lorem ipsum"
}
},
"noToolbar": {
"title": "No add, remove and order buttons",
"type": "array",
"items": {
"type": "string",
"default": "lorem ipsum"
}
},
"fixedNoToolbar": {
"title": "Fixed array without buttons",
"type": "array",
"items": [
{
"title": "A number",
"type": "number",
"default": 42
},
{
"title": "A boolean",
"type": "boolean",
"default": false
}
],
"additionalItems": {
"title": "A string",
"type": "string",
"default": "lorem ipsum"
}
}
}
}
{
"type": "object",
"title": "Number fields & widgets",
"properties": {
"number": {
"title": "Number",
"type": "number"
},
"integer": {
"title": "Integer",
"type": "integer"
},
"numberEnum": {
"type": "number",
"title": "Number enum",
"enum": [
1,
2,
3
]
},
"numberEnumRadio": {
"type": "number",
"title": "Number enum",
"enum": [
1,
2,
3
]
},
"integerRange": {
"title": "Integer range",
"type": "integer",
"minimum": -50,
"maximum": 50
},
"integerRangeSteps": {
"title": "Integer range (by 10)",
"type": "integer",
"minimum": 50,
"maximum": 100,
"multipleOf": 10
}
}
}
{
"title": "Widgets",
"type": "object",
"properties": {
"stringFormats": {
"type": "object",
"title": "String formats",
"properties": {
"email": {
"type": "string",
"format": "email"
},
"uri": {
"type": "string",
"format": "uri"
}
}
},
"boolean": {
"type": "object",
"title": "Boolean field",
"properties": {
"default": {
"type": "boolean",
"title": "checkbox (default)",
"description": "This is the checkbox-description"
},
"radio": {
"type": "boolean",
"title": "radio buttons",
"description": "This is the radio-description"
},
"select": {
"type": "boolean",
"title": "select box",
"description": "This is the select-description"
}
}
},
"string": {
"type": "object",
"title": "String field",
"properties": {
"default": {
"type": "string",
"title": "text input (default)"
},
"textarea": {
"type": "string",
"title": "textarea"
},
"placeholder": {
"type": "string"
},
"color": {
"type": "string",
"title": "color picker",
"default": "#151ce6"
}
}
},
"secret": {
"type": "string",
"default": "I'm a hidden string."
},
"disabled": {
"type": "string",
"title": "A disabled field",
"default": "I am disabled."
},
"readonly": {
"type": "string",
"title": "A readonly field",
"default": "I am read-only."
},
"readonly2": {
"type": "string",
"title": "Another readonly field",
"default": "I am also read-only.",
"readOnly": true
},
"widgetOptions": {
"title": "Custom widget with options",
"type": "string",
"default": "I am yellow"
},
"selectWidgetOptions": {
"title": "Custom select widget with options",
"type": "string",
"enum": [
"foo",
"bar"
]
},
"selectWidgetOptions2": {
"title": "Custom select widget with options, overriding the enum titles.",
"type": "string",
"oneOf": [
{
"const": "foo",
"title": "Foo"
},
{
"const": "bar",
"title": "Bar"
}
]
}
}
}
{
"definitions": {
"address": {
"type": "object",
"properties": {
"street_address": {
"type": "string"
},
"city": {
"type": "string"
},
"state": {
"type": "string"
}
},
"required": [
"street_address",
"city",
"state"
]
},
"node": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"children": {
"type": "array",
"items": {
"$ref": "#/definitions/node"
}
}
}
}
},
"type": "object",
"properties": {
"billing_address": {
"title": "Billing address",
"$ref": "#/definitions/address"
},
"shipping_address": {
"title": "Shipping address",
"$ref": "#/definitions/address"
},
"tree": {
"title": "Recursive references",
"$ref": "#/definitions/node"
}
}
}
{
"title": "Files",
"type": "object",
"properties": {
"file": {
"type": "string",
"format": "data-url",
"title": "Single file"
},
"files": {
"type": "array",
"title": "Multiple files",
"items": {
"type": "string",
"format": "data-url"
}
},
"filesAccept": {
"type": "string",
"format": "data-url",
"title": "Single File with Accept attribute"
}
}
}
{
"title": "Schema dependencies",
"description": "These samples are best viewed without live validation.",
"type": "object",
"properties": {
"simple": {
"src": "https://spacetelescope.github.io/understanding-json-schema/reference/object.html#dependencies",
"title": "Simple",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"credit_card": {
"type": "number"
}
},
"required": [
"name"
],
"dependencies": {
"credit_card": {
"properties": {
"billing_address": {
"type": "string"
}
},
"required": [
"billing_address"
]
}
}
},
"conditional": {
"title": "Conditional",
"$ref": "#/definitions/person"
},
"arrayOfConditionals": {
"title": "Array of conditionals",
"type": "array",
"items": {
"$ref": "#/definitions/person"
}
},
"fixedArrayOfConditionals": {
"title": "Fixed array of conditionals",
"type": "array",
"items": [
{
"title": "Primary person",
"$ref": "#/definitions/person"
}
],
"additionalItems": {
"title": "Additional person",
"$ref": "#/definitions/person"
}
}
},
"definitions": {
"person": {
"title": "Person",
"type": "object",
"properties": {
"Do you have any pets?": {
"type": "string",
"enum": [
"No",
"Yes: One",
"Yes: More than one"
],
"default": "No"
}
},
"required": [
"Do you have any pets?"
],
"dependencies": {
"Do you have any pets?": {
"oneOf": [
{
"properties": {
"Do you have any pets?": {
"enum": [
"No"
]
}
}
},
{
"properties": {
"Do you have any pets?": {
"enum": [
"Yes: One"
]
},
"How old is your pet?": {
"type": "number"
}
},
"required": [
"How old is your pet?"
]
},
{
"properties": {
"Do you have any pets?": {
"enum": [
"Yes: More than one"
]
},
"Do you want to get rid of any?": {
"type": "boolean"
}
},
"required": [
"Do you want to get rid of any?"
]
}
]
}
}
}
}
}
{
"type": "object",
"properties": {
"age": {
"type": "integer",
"title": "Age"
},
"items": {
"type": "array",
"items": {
"type": "object",
"anyOf": [
{
"properties": {
"foo": {
"type": "string"
}
}
},
{
"properties": {
"bar": {
"type": "string"
}
}
}
]
}
}
},
"anyOf": [
{
"title": "First method of identification",
"properties": {
"firstName": {
"type": "string",
"title": "First name",
"default": "Chuck"
},
"lastName": {
"type": "string",
"title": "Last name"
}
}
},
{
"title": "Second method of identification",
"properties": {
"idCode": {
"type": "string",
"title": "ID code"
}
}
}
]
}
{
"definitions": {
"locations": {
"enumNames": [
"New York",
"Amsterdam",
"Hong Kong"
],
"enum": [
{
"name": "New York",
"lat": 40,
"lon": 74
},
{
"name": "Amsterdam",
"lat": 52,
"lon": 5
},
{
"name": "Hong Kong",
"lat": 22,
"lon": 114
}
]
}
},
"type": "object",
"properties": {
"location": {
"title": "Location",
"$ref": "#/definitions/locations"
},
"locationRadio": {
"title": "Location Radio",
"$ref": "#/definitions/locations"
},
"multiSelect": {
"title": "Locations",
"type": "array",
"uniqueItems": true,
"items": {
"$ref": "#/definitions/locations"
}
},
"checkboxes": {
"title": "Locations Checkboxes",
"type": "array",
"uniqueItems": true,
"items": {
"$ref": "#/definitions/locations"
}
}
}
}
{
"title": "Schema default properties",
"type": "object",
"properties": {
"valuesInFormData": {
"title": "Values in form data",
"$ref": "#/definitions/defaultsExample"
},
"noValuesInFormData": {
"title": "No values in form data",
"$ref": "#/definitions/defaultsExample"
}
},
"definitions": {
"defaultsExample": {
"type": "object",
"properties": {
"scalar": {
"title": "Scalar",
"type": "string",
"default": "scalar default"
},
"array": {
"title": "Array",
"type": "array",
"items": {
"type": "object",
"properties": {
"nested": {
"title": "Nested array",
"type": "string",
"default": "nested array default"
}
}
}
},
"object": {
"title": "Object",
"type": "object",
"properties": {
"nested": {
"title": "Nested object",
"type": "string",
"default": "nested object default"
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment