[Specifications] Native SHACL support (#214)

tpluscode has just created a new issue for https://github.com/HydraCG/Specifications:

== Native SHACL support ==
## Describe the requirement

[SHACL](https://www.w3.org/TR/shacl/) has been hinted multiple times in various locations. I would like to initiate a focused discussion leading to its adoption in Hydra

SHACL Shape can be an alternative resource description to the `hydra:Class`.

## Motivation

`hydra:Class` is inherently limited and it makes little sense to waste our limited resources on extending it. That would be wasted effort and just bloat.

Instead, SHACL is a well-recognised way to describe desired resources. Not only can it be used to drive the UI and API but is already being applied to [validate payloads](https://npm.im/rdf-validate-shacl) and also becomes [integrated into triple stores](https://www.stardog.com/blog/studio-shacl-released/) and other tools. 

Various potential usages are listed on the [SHACL Use Cases and Requirements](https://www.w3.org/TR/shacl-ucr/) W3C note.

SHACL can do easily do all that we are currently missing or half-heartedly support:

- cardinalities
- closed sets of potential values
- regular expressions
- property paths
- field ordering
- (proposed) UI aid via [DASH](http://datashapes.org/forms.html)

## Proposed solutions

There is only a simple change required to open a whole world of opportunities, including what has been discussed in #199. To loosen the `range` semantics of `expects`:

```diff
{
  "@id": "hydra:expects",
-  "range": "hydra:Class",
+  "schema:rangeIncludes": [
+    "hydra:Class",
+    "sh:Shape"
+  ]
},
```

## Alternative solutions

For a moment I thought to keep the range but that doesn't seem right 🤷
```diff
{
  "@id": "hydra:expects",
  "range": "hydra:Class",
+  "schema:rangeIncludes": [
+    "sh:Shape"
+  ]
},
```

The problem with `hydra:Class` may be that it is a subclass of `rdfs:Class` but shape isn't. In fact, there may be multiple shapes which has a shared `sh:targetClass`. They do serve a different purpose. 

Thus, I don't see a different solution right now.

Please view or discuss this issue at https://github.com/HydraCG/Specifications/issues/214 using your GitHub account

Received on Friday, 22 May 2020 08:07:09 UTC