diff --git a/hyper-schema.json b/hyper-schema.json index ec9c1441..204def3e 100644 --- a/hyper-schema.json +++ b/hyper-schema.json @@ -2,49 +2,109 @@ "$schema": "http://json-schema.org/draft/hyper-schema#", "id": "http://json-schema.org/draft/hyper-schema#", "title": "JSON Hyper-Schema", - "allOf": [ - {"$ref": "http://json-schema.org/draft-04/schema#"} - ], + "definitions": { + "schemaArray": { + "allOf": [ + { "$ref": "http://json-schema.org/drafts/schema" }, + { + "items": { "$ref": "#/definitions/subSchema" } + } + ] + }, + "linkDescription": { + "title": "Link Description Object", + "type": "object", + "required": [ "href" ], + "properties": { + "href": { + "description": "a URI template, as defined by RFC 6570, with the addition of the $, ( and ) characters for pre-processing", + "type": "string" + }, + "rel": { + "description": "relation to the target resource of the link", + "type": "string" + }, + "title": { + "description": "a title for the link", + "type": "string" + }, + "targetSchema": { + "description": "JSON Schema describing the link target", + "allOf": [ { "$ref": "#/definitions/subSchema" } ] + }, + "mediaType": { + "description": "media type (as defined by RFC 2046) describing the link target", + "type": "string" + }, + "method": { + "description": "specifies that the client can construct a templated query (\"get\") or non-idempotent request (\"post\") to a resource.", + "type": "string" + }, + "encType": { + "description": "The media type in which to submit data along with the request", + "type": "string", + "default": "application/json" + }, + "schema": { + "description": "Schema describing the data to submit along with the request", + "allOf": [ { "$ref": "#/definitions/subSchema" } ] + } + } + }, + "subSchema": { + "oneOf": [ + { + "allOf": [ + { "$ref": "#" }, + { "$ref": "http://json-schema.org/draft/schema#/definitions/notJsonReference" } + ] + }, + { "$ref": "http://json-schema.org/draft/schema#/definitions/jsonReference" } + ] + } + }, + + "allOf": [ { "$ref": "http://json-schema.org/draft/schema#" } ], "properties": { "additionalItems": { "anyOf": [ - {"type": "boolean"}, - {"$ref": "#"} + { "type": "boolean" }, + { "$ref": "#/definitions/subSchema" } ] }, "additionalProperties": { "anyOf": [ - {"type": "boolean"}, - {"$ref": "#"} + { "type": "boolean" }, + { "$ref": "#/definitions/subSchema" } ] }, "dependencies": { "additionalProperties": { "anyOf": [ - {"$ref": "#"}, - {"type": "array"} + { "$ref": "#/definitions/subSchema" }, + { "type": "array" } ] } }, "items": { "anyOf": [ - {"$ref": "#"}, - {"$ref": "#/definitions/schemaArray"} + { "$ref": "#/definitions/subSchema" }, + { "$ref": "#/definitions/schemaArray" } ] }, "definitions": { - "additionalProperties": {"$ref": "#"} + "additionalProperties": { "$ref": "#/definitions/subSchema" } }, "patternProperties": { - "additionalProperties": {"$ref": "#"} + "additionalProperties": { "$ref": "#/definitions/subSchema" } }, "properties": { - "additionalProperties": {"$ref": "#"} + "additionalProperties": { "$ref": "#/definitions/subSchema" } }, - "allOf": {"$ref": "#/definitions/schemaArray"}, - "anyOf": {"$ref": "#/definitions/schemaArray"}, - "oneOf": {"$ref": "#/definitions/schemaArray"}, - "not": { "$ref": "#" }, + "allOf": { "$ref": "#/definitions/schemaArray" }, + "anyOf": { "$ref": "#/definitions/schemaArray" }, + "oneOf": { "$ref": "#/definitions/schemaArray" }, + "not": { "$ref": "#/definitions/subSchema" }, "base": { "description": "URI Template resolved as for the 'href' keyword in the Link Description Object. The resulting URI Reference is resolved against the current URI base and sets the new URI base for URI references within the instance.", @@ -52,7 +112,7 @@ }, "links": { "type": "array", - "items": {"$ref": "#/definitions/linkDescription"} + "items": { "$ref": "#/definitions/linkDescription" } }, "media": { "type": "object", @@ -66,62 +126,17 @@ "type": "string" } } - } - }, - "definitions": { - "schemaArray": { - "type": "array", - "items": {"$ref": "#"} }, - "linkDescription": { - "title": "Link Description Object", - "type": "object", - "required": ["href"], - "properties": { - "href": { - "description": "a URI template, as defined by RFC 6570, with the addition of the $, ( and ) characters for pre-processing", - "type": "string" - }, - "rel": { - "description": "relation to the target resource of the link", - "type": "string" - }, - "title": { - "description": "a title for the link", - "type": "string" - }, - "targetSchema": { - "description": "JSON Schema describing the link target", - "$ref": "#" - }, - "mediaType": { - "description": "media type (as defined by RFC 2046) describing the link target", - "type": "string" - }, - "method": { - "description": "specifies that the client can construct a templated query (\"get\") or non-idempotent request (\"post\") to a resource.", - "type": "string" - }, - "encType": { - "description": "The media type in which to submit data along with the request", - "type": "string", - "default": "application/json" - }, - "schema": { - "description": "Schema describing the data to submit along with the request", - "$ref": "#" - } - } + "readOnly": { + "description": "If true, indicates that the value of this property is controlled by the server.", + "type": "boolean", + "default": "false" } }, "links": [ { "rel": "self", "href": "{+id}" - }, - { - "rel": "full", - "href": "{+($ref)}" } ] } diff --git a/links.json b/links.json new file mode 100644 index 00000000..3c9cd1c6 --- /dev/null +++ b/links.json @@ -0,0 +1,42 @@ +{ + "$schema": "http://json-schema.org/draft/hyper-schema#", + "id": "http://json-schema.org/draft/links#", + "title": "Link Description Object", + "type": "object", + "required": [ "href" ], + "properties": { + "href": { + "description": "a URI template, as defined by RFC 6570, with the addition of the $, ( and ) characters for pre-processing", + "type": "string" + }, + "rel": { + "description": "relation to the target resource of the link", + "type": "string" + }, + "title": { + "description": "a title for the link", + "type": "string" + }, + "targetSchema": { + "description": "JSON Schema describing the link target", + "allOf": [ { "$ref": "hyper-schema#" } ] + }, + "mediaType": { + "description": "media type (as defined by RFC 2046) describing the link target", + "type": "string" + }, + "method": { + "description": "specifies that the client can construct a templated query (\"get\") or non-idempotent request (\"post\") to a resource.", + "type": "string" + }, + "encType": { + "description": "The media type in which to submit data along with the request", + "type": "string", + "default": "application/json" + }, + "schema": { + "description": "Schema describing the data to submit along with the request", + "allOf": [ { "$ref": "hyper-schema#" } ] + } + } +} diff --git a/schema.json b/schema.json index d44cd480..206ed587 100644 --- a/schema.json +++ b/schema.json @@ -1,12 +1,26 @@ { - "id": "http://json-schema.org/draft/schema#", "$schema": "http://json-schema.org/draft/schema#", - "description": "Core schema meta-schema", + "id": "http://json-schema.org/draft/schema#", + "title": "Core schema meta-schema", "definitions": { + "jsonReferece": { + "type": "object", + "properties": { + "$ref": { + "type": "string", + "format": "uriref" + } + }, + "required": [ "$ref" ] + }, + "notJsonReference": { + "not": { + "required": [ "$ref" ] + } + }, "schemaArray": { "type": "array", - "minItems": 1, - "items": { "$ref": "#" } + "items": { "$ref": "#/definitions/subSchema" } }, "positiveInteger": { "type": "integer", @@ -19,12 +33,32 @@ ] }, "simpleTypes": { - "enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ] + "enum": [ + "array", + "boolean", + "integer", + "null", + "number", + "object", + "string" + ] }, "stringArray": { "type": "array", "items": { "type": "string" }, - "uniqueItems": true + "uniqueItems": true, + "default": [] + }, + "subSchema": { + "oneOf": [ + { + "allOf": [ + { "$ref": "#" }, + { "$ref": "#/definitions/notJsonReference" } + ] + }, + { "$ref": "#/definitions/jsonReference" } + ] } }, "type": "object", @@ -46,23 +80,14 @@ "default": {}, "multipleOf": { "type": "number", - "minimum": 0, - "exclusiveMinimum": true + "exclusiveMinimum": 0 }, "maximum": { "type": "number" }, - "exclusiveMaximum": { - "type": "boolean", - "default": false - }, "minimum": { "type": "number" }, - "exclusiveMinimum": { - "type": "boolean", - "default": false - }, "maxLength": { "$ref": "#/definitions/positiveInteger" }, "minLength": { "$ref": "#/definitions/positiveIntegerDefault0" }, "pattern": { @@ -72,13 +97,13 @@ "additionalItems": { "anyOf": [ { "type": "boolean" }, - { "$ref": "#" } + { "$ref": "#/definitions/subSchema" } ], "default": {} }, "items": { "anyOf": [ - { "$ref": "#" }, + { "$ref": "#/definitions/subSchema" }, { "$ref": "#/definitions/schemaArray" } ], "default": {} @@ -96,30 +121,30 @@ "additionalProperties": { "anyOf": [ { "type": "boolean" }, - { "$ref": "#" } + { "$ref": "#/definitions/subSchema" } ], "default": {} }, "definitions": { "type": "object", - "additionalProperties": { "$ref": "#" }, + "additionalProperties": { "$ref": "#/definitions/subSchema" }, "default": {} }, "properties": { "type": "object", - "additionalProperties": { "$ref": "#" }, + "additionalProperties": { "$ref": "#/definitions/subSchema" }, "default": {} }, "patternProperties": { "type": "object", - "additionalProperties": { "$ref": "#" }, + "additionalProperties": { "$ref": "#/definitions/subSchema" }, "default": {} }, "dependencies": { "type": "object", "additionalProperties": { "anyOf": [ - { "$ref": "#" }, + { "$ref": "#/definitions/subSchema" }, { "$ref": "#/definitions/stringArray" } ] } @@ -145,11 +170,41 @@ "allOf": { "$ref": "#/definitions/schemaArray" }, "anyOf": { "$ref": "#/definitions/schemaArray" }, "oneOf": { "$ref": "#/definitions/schemaArray" }, - "not": { "$ref": "#" } - }, - "dependencies": { - "exclusiveMaximum": [ "maximum" ], - "exclusiveMinimum": [ "minimum" ] + "not": { "$ref": "#/definitions/subSchema" } }, + "allOf": [ + { + "oneOf": [ + { + "exclusiveMaximum": { "type": "number" } + }, + { + "exclusiveMaximum": { + "type": "boolean", + "default": false + }, + "dependencies": { + "exclusiveMaximum": [ "maximum" ] + } + } + ] + }, + { + "oneOf": [ + { + "exclusiveMinimum": { "type": "number" } + }, + { + "exclusiveMinimum": { + "type": "boolean", + "default": false + }, + "dependencies": { + "exclusiveMinimum": [ "minimum" ] + } + } + ] + } + ], "default": {} }