Skip to content

Instantly share code, notes, and snippets.

@ruswerner
Last active March 31, 2020 19:34
Show Gist options
  • Select an option

  • Save ruswerner/8ce0beb730f7c24d4ab900e314a306d5 to your computer and use it in GitHub Desktop.

Select an option

Save ruswerner/8ce0beb730f7c24d4ab900e314a306d5 to your computer and use it in GitHub Desktop.
{
"$id": "https://coastapp.com/card-layout.json",
"$schema": "http://json-schema.org/draft-07/schema",
"definitions": {
"section": {
"$id": "#section",
"type": "object",
"properties": {
"type": { "type": "string", "enum": ["section"] },
"fields": {
"type": "array",
"items": { "type": "string" },
"minItems": 1
},
"layout": {
"type": "string",
"enum": ["list", "range"],
"default": "list"
},
"textStyle": {
"type": "string",
"enum": ["h4", "body1"],
"default": "body1"
}
},
"required": ["type", "fields"]
},
"comments": {
"$id": "#comments",
"description": "Renders the comments widget with unread indicator",
"type": "object",
"properties": {
"type": { "type": "string", "enum": ["comments"] }
},
"required": ["type"]
},
"actions": {
"$id": "#actions",
"type": "object",
"properties": {
"type": { "type": "string", "enum": ["actions"] },
"elements": {
"type": "array",
"items": { "anyOf": [{ "$ref": "#button" }] },
"minItems": 1
}
},
"required": ["type", "elements"]
},
"divider": {
"$id": "#divider",
"description": "Renders a horizontal divider between blocks",
"type": "object",
"properties": {
"type": { "type": "string", "enum": ["divider"] }
},
"required": ["type"]
},
"image": {
"$id": "#image",
"description": "Renders a full-width image",
"type": "object",
"properties": {
"type": { "type": "string", "enum": ["image"] },
"field": { "type": "string" },
"size": {
"type": "string",
"enum": ["full", "thumb"],
"default": "full"
}
},
"required": ["type", "field"]
},
"file": {
"$id": "#file",
"description": "Renders a file reference with optional preview",
"type": "object",
"properties": {
"type": { "type": "string", "enum": ["file"] },
"preview": { "type": "boolean", "default": false }
},
"required": ["type"]
},
"button": {
"$id": "#button",
"description": "Button action element",
"type": "object",
"properties": {
"type": { "type": "string", "enum": ["button"] },
"style": {
"type": "string",
"enum": ["default", "primary", "danger"],
"default": "default"
},
"id": { "type": "string" },
"url": { "type": "string" },
"value": { "type": "string" },
"text": { "type": "string" }
},
"required": ["type", "id", "text"]
}
},
"title": "Card Layout Schema",
"type": "object",
"properties": {
"blocks": {
"type": "array",
"items": {
"anyOf": [
{ "$ref": "#section" },
{ "$ref": "#comments" },
{ "$ref": "#actions" },
{ "$ref": "#divider" },
{ "$ref": "#image" },
{ "$ref": "#file" }
]
},
"minItems": 1
}
},
"required": ["blocks"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment