Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SHACL for IriTemplate mappings #215

Open
tpluscode opened this issue May 25, 2020 · 3 comments
Open

Use SHACL for IriTemplate mappings #215

tpluscode opened this issue May 25, 2020 · 3 comments

Comments

@tpluscode
Copy link
Contributor

Oh, what about IriTemplate mappings. Maybe they could also be described with a Shape?

The entire mappings could easily be swapped with a Shape, provided that individual PropertyShapes have an additional variable name which use use currently.

Here's an idea for changing EXAMPLE 19 from the spec

{
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
  "@type": "IriTemplate",
  "template": "http://api.example.com/issues{?q}",
  "variableRepresentation": "BasicRepresentation",
- "mapping": [
-   {
-     "@type": "IriTemplateMapping",
+ "mapping": {
+   "@type": "sh:NodeShape",
+   "sh:property": [
      "variable": "q",
-     "property": "hydra:freetextQuery",
-     "required": true
-    }
-  ]
+     "sh:path": "hydra:freetextQuery",
+     "sh:minCount": 1
+   ]
+ }
}

Little has to change conceptually.

  • hydra:IriTemplateMapping -> sh:PropertyShape
  • hydra:variable used with sh:PropertyShape
  • hydra:property -> sh:path
  • hydra:required -> sh:minCount

Of course, some limitations could be imposed for practical reasons:

@tpluscode
Copy link
Contributor Author

Let's keep the discussion separate for SHACL for hydra:expects as opposed to hydra:mapping

@tpluscode
Copy link
Contributor Author

Alternative solution proposed by @alien-mcl would be to keep the IriTemplateMapping and simply link the template to a shape which is an alternative description of the same graph.

{
  "@context": "http://www.w3.org/ns/hydra/context.jsonld",
  "@type": "IriTemplate",
  "template": "http://api.example.com/issues{?q}",
  "variableRepresentation": "BasicRepresentation",
  "hashi:shape": "ex:IssueSearchShape",
  "mapping": { /* ... */ }
}

A client which understands SHACL extensions would find the hashi:shape link and use that as the description of user input.

By keeping the Hydra Core mapping property other clients could use that as a fallback and still produce a conforming template

@asbjornu
Copy link
Member

I think that's an elegant solution. 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants