Closed alien-mcl closed 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"
]
}
rdfs
used in place of hydra terms to make the context more useful to non-Hydra useshydra:Error
can be placed in the response body. Mixing @type
and type
appears totally fine for JSON-LD parsingI'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.
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:
errorCode
term that is required to make that output of that standard JSON-LD context ahydra:Error
resourceIt may still valid to drop the second change - the only drawback would be the resulting resource would've been a
hydra:Status
which makes thehydra:Error
itself somehow obsolete (which is not that bad after all).