paragsarin / HALValidator

This Validator API exposes set of API restful endpoints for validating external HAL+JSON API to ensure their complaince with HAL+JSON resource API format.
GNU General Public License v3.0
2 stars 2 forks source link

Does HAL spec actually require _embedded? #4

Open beaudet opened 3 years ago

beaudet commented 3 years ago

Greetings, thanks for the helpful tool. As far as I can tell from the latest version of the HAL specifications, it seems the _embedded property is OPTIONAL even if the name of the property is reserved.

https://datatracker.ietf.org/doc/html/draft-kelly-json-hal

4.1.2.  _embedded

   The reserved "_embedded" property is OPTIONAL

   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.

Removing _embedded from required in the JSON schema seems to fix the issue.

beaudet commented 3 years ago

In addition, it looks like the self link is optional but when not present, the validator is reporting:

Required properties are missing from object: self

8.1.  Self Link

   Each Resource Object SHOULD contain a 'self' link that corresponds
   with the IANA registered 'self' relation (as defined by [RFC5988])
   whose target is the resource's URI.

The HAL+JSON being validated (with removal of _embedded as required field):


{
  "@context": "https://linked.art/ns/v1/linked-art.json",
  "id": "https://example.com/object/1",
  "type": "HumanMadeObject",
  "_label": "Example Object",
  "_links": {
    "curies": [
      { "name":"la", "href":"https://linked.art/api/1.0/rels/{rel}", "templated": true}
    ],
  "la:part": {"href": "https://example.com/object/1/parts"}
  }
}