Last active
April 5, 2018 10:05
-
-
Save pieterb/33b0aeb429cdd12a4a0f89a8bc406f9f to your computer and use it in GitHub Desktop.
hal+json schema for swagger 2.0
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
$schema: "http://json-schema.org/draft-04/schema#" | |
title: "HAL Schema" | |
description: | | |
JSON Hypertext Application Language Version 8 Internet-Draft, | |
according to https://tools.ietf.org/html/draft-kelly-json-hal-08", | |
definitions: | |
HRef: | |
description: | | |
Its value is either a URI [RFC3986] or a URI Template [RFC6570]. If | |
the value is a URI Template then the Link Object SHOULD have a | |
"templated" attribute whose value is true. | |
type: string | |
# TODO: Improve the following pattern. | |
pattern: "^(?:(?:https?|h2):)?(?://(?:[\\w\\-]+\\.?)+)?/(?:[\\w\\-.]+/?)*(?:\\?[^#]*)?(?:#.*)?$" | |
Name: | |
description: | | |
Its value MAY be used as a secondary key for selecting Link Objects | |
which share the same relation type. | |
type: string | |
Link: | |
title: Link Object | |
description: | | |
A Link Object represents a hyperlink from the containing resource to a | |
URI. | |
type: object | |
required: | |
- href | |
properties: | |
href: | |
$ref: "#/definitions/HRef" | |
templated: | |
description: | | |
Its value is boolean and SHOULD be true when the Link Object's "href" | |
property is a URI Template. Its value SHOULD be considered false if it | |
is undefined or any other value than true. | |
type: boolean | |
type: | |
description: | | |
Its value is a string used as a hint to indicate the media type | |
expected when dereferencing the target resource. | |
type: string | |
deprecation: | |
description: | | |
Its presence indicates that the link is to be deprecated (i.e. | |
removed) at a future date. Its value is a URL that SHOULD provide | |
further information about the deprecation. A client SHOULD provide | |
some notification (for example, by logging a warning message) whenever | |
it traverses over a link that has this property. The notification | |
SHOULD include the deprecation property's value so that a client | |
maintainer can easily find information about the deprecation. | |
type: string | |
name: | |
$ref: "#/definitions/Name" | |
profile: | |
description: | | |
Its value is a string which is a URI that hints about the profile | |
[RFC6906] of the target resource. | |
type: string | |
title: | |
description: | | |
Its value is a string and is intended for labelling the link with a | |
human-readable identifier (as defined by [RFC5988]). | |
type: string | |
hreflang: | |
description: | | |
Its value is a string and is intended for indicating the language of | |
the target resource (as defined by [RFC5988]). | |
type: string | |
CuriesLink: | |
description: | | |
Custom link relation types (Extension Relation Types in [RFC5988]) SHOULD | |
be URIs that when dereferenced in a web browser provide relevant | |
documentation, in the form of an HTML page, about the meaning and/or | |
behaviour of the target Resource. This will improve the discoverability of | |
the API. The CURIE Syntax [W3C.NOTE-curie-20101216] MAY be used for | |
brevity for these URIs. CURIEs are established within a HAL document via a | |
set of Link Objects with the relation type "curies" on the root Resource | |
Object. These links contain a URI Template with the token 'rel', and are | |
named via the "name" property. | |
allOf: | |
- $ref: '#/definitions/Link' | |
- required: | |
- href | |
- name | |
- templated | |
properties: | |
href: | |
$ref: "#/definitions/HRef" | |
name: | |
$ref: "#/definitions/Name" | |
templated: | |
enum: | |
- true | |
Resource: | |
title: Resource Object | |
description: | | |
A Resource Object represents a resource. It has two reserved properties: | |
(1) "_links" which contain links to other resources, and (2) "_embedded" | |
which contain embedded resources. All other properties MUST be valid JSON, | |
and represent the current state of the resource. | |
type: object | |
properties: | |
_links: | |
description: | | |
It is an object whose property names are link relation types (as | |
defined by [RFC5988]) and values are either a Link Object or an array | |
of Link Objects. The subject resource of these links is the Resource | |
Object of which the containing "_links" object is a property. | |
type: object | |
properties: | |
curies: | |
type: | |
- array | |
- object | |
allOf: | |
- $ref: '#/definitions/CuriesLink' | |
items: | |
$ref: '#/definitions/CuriesLink' | |
additionalProperties: | |
type: | |
- array | |
- object | |
allOf: | |
- $ref: '#/definitions/Link' | |
items: | |
$ref: '#/definitions/Link' | |
_embedded: | |
description: | | |
It is an object whose property names are link relation types (as | |
defined by [RFC5988]) and values are either a Resource Object or an | |
array of Resource Objects. Embedded Resources MAY be a full, partial, | |
or inconsistent version of the representation served from the target | |
URI. | |
type: object | |
additionalProperties: | |
type: | |
- array | |
- object | |
allOf: | |
- $ref: '#/definitions/Resource' | |
items: | |
$ref: '#/definitions/Resource' | |
$ref: "#/definitions/Resource" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment