Created
January 22, 2020 13:44
-
-
Save msalahz/0c11144d549148a012b10919808efc4d to your computer and use it in GitHub Desktop.
AJV JSON Schema
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"definitions": {}, | |
"$id": "http://example.com/root.json", | |
"type": "object", | |
"title": "The Root Schema", | |
"required": ["contentType", "content"], | |
"additionalProperties": false, | |
"properties": { | |
"contentType": { | |
"$id": "#/properties/contentType", | |
"type": "string", | |
"title": "The Contenttype Schema", | |
"enum": ["notification"], | |
"default": "notification", | |
"examples": ["notification"], | |
"readOnly": true | |
}, | |
"content": { | |
"$id": "#/properties/content", | |
"title": "The Content Schema", | |
"type": "array", | |
"default": [{"type": "", "language": "en-US", "id": "", "text": "", "parameters": []}], | |
"minItems": 1, | |
"maxItems": 3, | |
"uniqueItems": true, | |
"uniqueItemProperties": ["index"], | |
"items": { | |
"$id": "#/properties/content/items", | |
"type": "object", | |
"title": "The Item Schema", | |
"additionalProperties": false, | |
"required": ["index", "type"], | |
"properties": { | |
"index": { | |
"$id": "#/properties/content/items/properties/index", | |
"type": "number", | |
"title": "The Index", | |
"minimum": 1, | |
"maximum": 6, | |
"default": 2, | |
"examples": [1, 2, 3], | |
"readOnly": true | |
}, | |
"type": { | |
"$id": "#/properties/content/items/properties/type", | |
"type": "string", | |
"title": "The Type Schema" | |
}, | |
"language": { | |
"$id": "#/properties/content/items/properties/language", | |
"type": "string", | |
"title": "The Language Schema", | |
"default": "", | |
"examples": ["en-US"] | |
}, | |
"id": { | |
"$id": "#/properties/content/items/properties/id", | |
"type": "string", | |
"title": "The Id Schema", | |
"description": "e.g. namespace@name", | |
"default": "", | |
"examples": ["namespace@name"] | |
}, | |
"text": { | |
"$id": "#/properties/content/items/properties/text", | |
"type": "string", | |
"title": "The Text Schema", | |
"default": "", | |
"examples": [""] | |
}, | |
"url": { | |
"$id": "#/properties/content/items/properties/url", | |
"type": "string", | |
"title": "The Url Schema", | |
"default": "", | |
"examples": ["http://www.samplesite.com/flights/norway"] | |
}, | |
"name": { | |
"$id": "#/properties/content/items/properties/name", | |
"type": "string", | |
"title": "The URL File Name Schema", | |
"default": "", | |
"examples": [""] | |
}, | |
"mime": { | |
"$id": "#/properties/content/items/properties/mime", | |
"type": "string", | |
"title": "The URL File MIME Type Schema", | |
"default": "", | |
"examples": [""] | |
}, | |
"parameters": { | |
"$id": "#/properties/content/items/properties/parameters", | |
"type": "array", | |
"title": "The Parameters Schema", | |
"items": { | |
"$id": "#/properties/content/items/properties/parameters/items", | |
"type": "object", | |
"title": "The Items Schema", | |
"required": ["name", "index", "value"], | |
"additionalProperties": false, | |
"properties": { | |
"name": { | |
"$id": "#/properties/content/items/properties/parameters/items/properties/name", | |
"type": "string", | |
"title": "The Name Schema", | |
"default": "", | |
"examples": [""], | |
"pattern": "^(.*)$" | |
}, | |
"index": { | |
"$id": "#/properties/content/items/properties/parameters/items/properties/index", | |
"type": "string", | |
"title": "The Index Schema", | |
"default": "", | |
"examples": [""], | |
"pattern": "^\\d+$" | |
}, | |
"value": { | |
"$id": "#/properties/content/items/properties/parameters/items/properties/value", | |
"type": "string", | |
"title": "The Value Schema", | |
"default": "", | |
"examples": [""], | |
"pattern": "[^]" | |
} | |
} | |
} | |
}, | |
"actions": { | |
"$id": "#/properties/content/items/properties/actions", | |
"type": "object", | |
"title": "The Actions Schema" | |
} | |
}, | |
"allOf": [ | |
{ | |
"if": { | |
"properties": { "index": { "const": 2 } } | |
}, | |
"then": { | |
"required": ["id", "language", "text"], | |
"properties": { | |
"type": { | |
"enum": ["notification"], | |
"default": "notification", | |
"examples": ["notification"] | |
}, | |
"language": { | |
"pattern": "^[A-Za-z]{2,4}([_-]([A-Za-z]{4}|[0-9]{3}))?([_-]([A-Za-z]{2}|[0-9]{3}))?$" | |
}, | |
"id": { | |
"pattern": "^[0-9a-z_]+@[a-z0-9_]+$" | |
}, | |
"text": { | |
"pattern": "[^]" | |
} | |
} | |
} | |
}, | |
{ | |
"if": { | |
"properties": { "index": { "const": 1 } } | |
}, | |
"then": { | |
"properties": { | |
"type": { | |
"enum": ["text", "file", "image", "video"], | |
"default": "text", | |
"examples": ["text", "file", "image", "video"] | |
} | |
}, | |
"if": { | |
"properties": { "type": { "const": "text" } } | |
}, | |
"then": { | |
"required": ["text"], | |
"properties": { | |
"text": { | |
"pattern": "[^]" | |
}, | |
"parameters": { | |
"maxItems": 1 | |
} | |
} | |
}, | |
"else": { | |
"required": ["url", "name", "mime"] | |
} | |
} | |
}, | |
{ | |
"if": { | |
"properties": { "index": { "const": 3 } } | |
}, | |
"then": { | |
"required": ["text"], | |
"properties": { | |
"text": { | |
"pattern": "[^]" | |
} | |
} | |
} | |
}, | |
{ | |
"if": { | |
"properties": { "index": { "minimum": 4 } } | |
}, | |
"then": { | |
"required": ["text"], | |
"properties": { | |
"type": { | |
"enum": ["quick-reply", "button"], | |
"default": "button", | |
"examples": ["quick-reply", "button"] | |
}, | |
"text": { | |
"pattern": "[^]" | |
} | |
}, | |
"if": { | |
"properties": { "type": { "const": "button" } } | |
}, | |
"then": { | |
"required": ["actions"], | |
"properties": { | |
"actions": { | |
"$id": "#/properties/content/items/properties/actions", | |
"type": "object", | |
"title": "The Actions Schema", | |
"oneOf": [ | |
{ | |
"required": ["url", "parameters"], | |
"properties": { | |
"url": { | |
"$id": "#/properties/content/items/properties/actions/properties/url", | |
"type": "string", | |
"title": "The Url Schema", | |
"default": "", | |
"examples": ["http://www.samplesite.com/flights/norway"], | |
"pattern": "[^]" | |
}, | |
"parameters": { | |
"$id": "#/properties/content/items/properties/actions/properties/parameters", | |
"type": "array", | |
"title": "The Parameters Schema", | |
"maxItems": 1, | |
"items": { | |
"$id": "#/properties/content/items/properties/actions/properties/parameters/items", | |
"type": "object", | |
"title": "The Items Schema", | |
"required": ["name", "index", "value"], | |
"additionalProperties": false, | |
"properties": { | |
"name": { | |
"$id": "#/properties/content/items/properties/actions/properties/parameters/items/properties/name", | |
"type": "string", | |
"title": "The Name Schema", | |
"default": "", | |
"examples": [""], | |
"pattern": "^(.*)$" | |
}, | |
"index": { | |
"$id": "#/properties/content/items/properties/actions/properties/parameters/items/properties/index", | |
"type": "string", | |
"title": "The Index Schema", | |
"default": "", | |
"examples": [""], | |
"pattern": "^\\d+$" | |
}, | |
"value": { | |
"$id": "#/properties/content/items/properties/actions/properties/parameters/items/properties/value", | |
"type": "string", | |
"title": "The Value Schema", | |
"default": "", | |
"examples": [""], | |
"pattern": "[^]" | |
} | |
} | |
} | |
} | |
} | |
}, | |
{ | |
"required": ["call"], | |
"properties": { | |
"call": { | |
"$id": "#/properties/content/items/properties/actions/properties/call", | |
"type": "string", | |
"title": "The Call Schema", | |
"default": "", | |
"examples": ["User Clicked on Link"], | |
"pattern": "^[\\+]?[(]?[0-9]{3}[)]?[-\\s\\.]?[0-9]{3}[-\\s\\.]?[0-9]{4,6}$" | |
} | |
} | |
} | |
] | |
} | |
} | |
} | |
} | |
} | |
] | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment