Skip to content

Instantly share code, notes, and snippets.

@grayside
Created September 21, 2017 19:14
Show Gist options
  • Save grayside/3cf329bda044998355406da2e03b95a0 to your computer and use it in GitHub Desktop.
Save grayside/3cf329bda044998355406da2e03b95a0 to your computer and use it in GitHub Desktop.
Example Article Schema Output from Schemata module. Check out ._embedded.field_anyof_example
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://www.api-dx.vm/schemata/node/article?_format=schema_json&_describes=hal_json",
"type": "object",
"title": "node:article Schema",
"description": "Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.",
"properties": {
"nid": {
"type": "array",
"title": "ID",
"items": {
"type": "object",
"properties": {
"value": {
"type": "integer",
"title": "Integer value"
}
},
"required": [
"value"
]
},
"minItems": 1,
"maxItems": 1
},
"uuid": {
"type": "array",
"title": "UUID",
"items": {
"type": "object",
"properties": {
"value": {
"type": "string",
"title": "Text value",
"maxLength": 128
}
},
"required": [
"value"
]
},
"minItems": 1,
"maxItems": 1
},
"vid": {
"type": "array",
"title": "Revision ID",
"items": {
"type": "object",
"properties": {
"value": {
"type": "integer",
"title": "Integer value"
}
},
"required": [
"value"
]
},
"minItems": 1,
"maxItems": 1
},
"langcode": {
"type": "array",
"title": "Language",
"items": {
"type": "object",
"properties": {
"value": {
"type": "string",
"title": "Language code"
}
},
"required": [
"value"
]
},
"maxItems": 1
},
"status": {
"type": "array",
"title": "Publishing status",
"description": "A boolean indicating the published state.",
"items": {
"type": "object",
"properties": {
"value": {
"type": "boolean",
"title": "Boolean value"
}
},
"required": [
"value"
]
},
"default": [
{
"value": true
}
],
"maxItems": 1
},
"title": {
"type": "array",
"title": "Title",
"items": {
"type": "object",
"properties": {
"value": {
"type": "string",
"title": "Text value",
"maxLength": 255
}
},
"required": [
"value"
]
},
"minItems": 1,
"maxItems": 1
},
"_links": {
"title": "HAL Links",
"description": "Object of links with the rels as the keys",
"type": "object",
"properties": {
"http://www.api-dx.vm/rest/relation/node/article/uid": {
"$ref": "#/definitions/linkArray",
"title": "Authored by",
"description": "The username of the content author."
},
"http://www.api-dx.vm/rest/relation/node/article/revision_uid": {
"$ref": "#/definitions/linkArray",
"title": "Revision user ID",
"description": "The user ID of the author of the current revision."
},
"http://www.api-dx.vm/rest/relation/node/article/field_anyof_example": {
"$ref": "#/definitions/linkArray",
"title": "AnyOf Example",
"description": "If a field is configured using the Default reference method and can reference more than one content type, it will use anyOf in the JSON Schema to indicate your options."
},
"http://www.api-dx.vm/rest/relation/node/article/field_image": {
"$ref": "#/definitions/linkArray",
"title": "Image"
},
"http://www.api-dx.vm/rest/relation/node/article/field_tags": {
"$ref": "#/definitions/linkArray",
"title": "Tags",
"description": "Enter a comma-separated list. For example: Amsterdam, Mexico City, \"Cleveland, Ohio\""
},
"self": {
"$ref": "#/definitions/linkObject"
},
"type": {
"$ref": "#/definitions/linkObject"
}
}
},
"_embedded": {
"title": "HAL Embedded Resource",
"description": "An embedded HAL resource",
"type": "object",
"properties": {
"http://www.api-dx.vm/rest/relation/node/article/uid": {
"type": "array",
"items": {
"$ref": "http://www.api-dx.vm/schemata/user?_format=schema_json&_describes=hal_json"
},
"title": "Authored by"
},
"http://www.api-dx.vm/rest/relation/node/article/revision_uid": {
"type": "array",
"items": {
"$ref": "http://www.api-dx.vm/schemata/user?_format=schema_json&_describes=hal_json"
},
"title": "Revision user ID"
},
"http://www.api-dx.vm/rest/relation/node/article/field_anyof_example": {
"type": "array",
"items": {
"anyOf": [
{
"$ref": "http://www.api-dx.vm/schemata/node/article?_format=schema_json&_describes=hal_json"
},
{
"$ref": "http://www.api-dx.vm/schemata/node/page?_format=schema_json&_describes=hal_json"
}
]
},
"title": "AnyOf Example"
},
"http://www.api-dx.vm/rest/relation/node/article/field_image": {
"type": "array",
"items": {
"$ref": "http://www.api-dx.vm/schemata/file?_format=schema_json&_describes=hal_json"
},
"title": "Image"
},
"http://www.api-dx.vm/rest/relation/node/article/field_tags": {
"type": "array",
"items": {
"$ref": "http://www.api-dx.vm/schemata/taxonomy_term/tags?_format=schema_json&_describes=hal_json"
},
"title": "Tags"
}
}
},
"created": {
"type": "array",
"title": "Authored on",
"description": "The time that the node was created.",
"items": {
"type": "object",
"properties": {
"value": {
"type": "number",
"title": "Timestamp value",
"format": "utc-millisec"
}
},
"required": [
"value"
]
},
"maxItems": 1
},
"changed": {
"type": "array",
"title": "Changed",
"description": "The time that the node was last edited.",
"items": {
"type": "object",
"properties": {
"value": {
"type": "number",
"title": "Timestamp value",
"format": "utc-millisec"
}
},
"required": [
"value"
]
},
"maxItems": 1
},
"promote": {
"type": "array",
"title": "Promoted to front page",
"items": {
"type": "object",
"properties": {
"value": {
"type": "boolean",
"title": "Boolean value"
}
},
"required": [
"value"
]
},
"default": [
{
"value": true
}
],
"maxItems": 1
},
"sticky": {
"type": "array",
"title": "Sticky at top of lists",
"items": {
"type": "object",
"properties": {
"value": {
"type": "boolean",
"title": "Boolean value"
}
},
"required": [
"value"
]
},
"default": [
{
"value": false
}
],
"maxItems": 1
},
"revision_timestamp": {
"type": "array",
"title": "Revision timestamp",
"description": "The time that the current revision was created.",
"items": {
"type": "object",
"properties": {
"value": {
"type": "number",
"title": "Timestamp value",
"format": "utc-millisec"
}
},
"required": [
"value"
]
},
"maxItems": 1
},
"revision_log": {
"type": "array",
"title": "Revision log message",
"description": "Briefly describe the changes you have made.",
"items": {
"type": "object",
"properties": {
"value": {
"type": "string",
"title": "Text value"
}
},
"required": [
"value"
]
},
"default": [
{
"value": ""
}
],
"maxItems": 1
},
"revision_translation_affected": {
"type": "array",
"title": "Revision translation affected",
"description": "Indicates if the last edit of a translation belongs to current revision.",
"items": {
"type": "object",
"properties": {
"value": {
"type": "boolean",
"title": "Boolean value"
}
},
"required": [
"value"
]
},
"minItems": 1,
"maxItems": 1
},
"default_langcode": {
"type": "array",
"title": "Default translation",
"description": "A flag indicating whether this is the default translation.",
"items": {
"type": "object",
"properties": {
"value": {
"type": "boolean",
"title": "Boolean value"
}
},
"required": [
"value"
]
},
"default": [
{
"value": true
}
],
"maxItems": 1
},
"path": {
"type": "array",
"title": "URL alias",
"items": {
"type": "object",
"properties": {
"alias": {
"type": "string",
"title": "Path alias"
},
"pid": {
"type": "integer",
"title": "Path id"
}
}
},
"minItems": 1,
"maxItems": 1
},
"body": {
"type": "array",
"title": "Body",
"items": {
"type": "object",
"properties": {
"value": {
"type": "string",
"title": "Text"
},
"format": {
"type": "string",
"title": "Text format"
},
"summary": {
"type": "string",
"title": "Summary"
}
},
"required": [
"value"
]
},
"maxItems": 1
},
"comment": {
"type": "array",
"title": "Comments",
"items": {
"type": "object",
"properties": {
"status": {
"type": "integer",
"title": "Comment status"
},
"cid": {
"type": "integer",
"title": "Last comment ID"
},
"last_comment_timestamp": {
"type": "integer",
"title": "Last comment timestamp",
"description": "The time that the last comment was created."
},
"last_comment_name": {
"type": "string",
"title": "Last comment name",
"description": "The name of the user posting the last comment."
},
"last_comment_uid": {
"type": "integer",
"title": "Last comment user ID"
},
"comment_count": {
"type": "integer",
"title": "Number of comments",
"description": "The number of comments."
}
},
"required": [
"status"
]
},
"minItems": 1,
"default": [
{
"status": 2,
"cid": 0,
"last_comment_name": null,
"last_comment_timestamp": 0,
"last_comment_uid": 0,
"comment_count": 0
}
],
"maxItems": 1
}
},
"required": [
"nid",
"uuid",
"vid",
"title",
"revision_translation_affected",
"path",
"comment"
],
"definitions": {
"linkArray": {
"title": "HAL Link Array",
"description": "An array of linkObjects of the same link relation",
"type": "array",
"items": {
"$ref": "#/definitions/linkObject"
}
},
"linkObject": {
"title": "HAL Link Object",
"description": "An object with link information.",
"type": "object",
"properties": {
"name": {
"title": "Name",
"description": "Name of a resource, link, action, etc.",
"type": "string"
},
"title": {
"title": "Title",
"description": "A title for a resource, link, action, etc.",
"type": "string"
},
"href": {
"title": "HREF",
"description": "A hyperlink URL.",
"type": "string",
"format": "uri"
}
},
"required": [
"href"
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment