- From: Angelo Veltens via GitHub <sysbot+gh@w3.org>
- Date: Tue, 19 Mar 2019 15:00:06 +0000
- To: public-hydra-logs@w3.org
I have taken some look at SHACL in the meanwhile and it seams to fit our use case quite well. One could describe a Collection that contains Events by a Shape like this: ```json { "@context": [ "http://www.w3.org/ns/hydra/context.jsonld", { "ex": "https://vocab.example/", "sh": "http://www.w3.org/ns/shacl#", "sh:class": { "@type": "@vocab" }, "sh:path": { "@type": "@vocab" }, "sh:property": { "@type": "@vocab" }, "sh:hasValue": { "@type": "@vocab" } } ], "@id": "ex:EventCollectionShape", "@type": "sh:NodeShape", "sh:class": "hydra:Collection", "sh:property": { "sh:path": "manages", "sh:node": { "sh:property": [{ "sh:path": "property", "sh:hasValue": "rdf:type" }, { "sh:path": "object", "sh:hasValue": "schema:Event" }] } } } ``` Such a Shape could be used in `hydra:returns` or `hydra:expects` to tell the client, that the operation returns/expects data that fulfills the constraints of that shape. That way we are much more flexible without having to reinvent the wheel. Thinking this further, we could even reconcider the `manages` block regarding Shapes, since this is also a situation where we want to tell the client "the elements in here, look like this". So instead of `hydra:property`, `hydra:object` etc. we could describe the collection elements by a Shape as well: ```json { "@context": [ "http://www.w3.org/ns/hydra/context.jsonld", { "ex": "https://vocab.example/", "sh": "http://www.w3.org/ns/shacl#", "sh:class": { "@type": "@vocab" }, "sh:path": { "@type": "@vocab" }, "sh:property": { "@type": "@vocab" }, "sh:hasValue": { "@type": "@id" } } ], "@id": "https://api.example/location/1/events", "@type": "Collection", "manages": { "@id": "ex:EventsAtLocation1Shape", "@type": "sh:NodeShape", "sh:class": "schema:Event", "sh:property": { "sh:path": "schema:location", "sh:hasValue": "/location/1" } } } ``` Then the EventCollectionShape cloud simply refer to the shape for the collection members (`ex:EventAtLocation1Shape`): ``` { "@context": [ //... same as above ], "@id": "ex:EventCollectionShape", "@type": "sh:NodeShape", "sh:class": "hydra:Collection", "sh:property": { "sh:path": "manages", "sh:hasValue": "ex:EventAtLocation1Shape", } } ``` -- GitHub Notification of comment by angelo-v Please view or discuss this issue at https://github.com/HydraCG/Specifications/pull/187#issuecomment-474409468 using your GitHub account
Received on Tuesday, 19 March 2019 15:00:07 UTC