HydraCG / Specifications

Specifications created by the Hydra W3C Community Group
Other
138 stars 26 forks source link

#178 Make hydra:error compatible with RFC 7807 #218

Closed alien-mcl closed 3 years ago

alien-mcl commented 3 years ago

Summary

Changes are covering new standard JSON-LD context that maps RFC-7807 specific JSON properties to Hydra vocabulary.

More details

This pull-request should resolve issue #718 by introducing two new things:

It may still valid to drop the second change - the only drawback would be the resulting resource would've been a hydra:Status which makes the hydra:Error itself somehow obsolete (which is not that bad after all).

tpluscode commented 3 years ago

Following the discussion between myself, @alien-mcl and @serialseb, here's an example of how an Hydra error response could look like (context inlined)

{
  "@context": {
    "hydra": "http://www.w3.org/ns/hydra/core#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "type": "@type",
    "title": "rdfs:label",
    "detail": "rdfs:comment",
    "status": "hydra:statusCode",
    "instance": {
      "@id": "rdfs:seeAlso",
      "@type": "@id"
    }
  },
  "@type": "hydra:Error",
  "type": "https://example.com/probs/out-of-credit",
  "title": "You do not have enough credit.",
  "detail": "Your current balance is 30, but that costs 50.",
  "instance": "/account/12345/msgs/abc",
  "balance": 30,
  "accounts": [
    "/account/12345",
    "/account/67890"
  ]
}
  1. rdfs used in place of hydra terms to make the context more useful to non-Hydra uses
  2. hydra:Error can be placed in the response body. Mixing @type and type appears totally fine for JSON-LD parsing
alien-mcl commented 3 years ago

I've remapped the context accordingly and made some changes to the spec. In general I've made RFC-8708 errors recommended (SHOULD). This still enables older implementations compatible with the spec. I've also made a note regarding a statusCode that was removed from the context completely and was made archaic in the spec.