-
Notifications
You must be signed in to change notification settings - Fork 27
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
Native SHACL support #214
Comments
Isn't |
I think you mean that its range is a schema:rangeIncludes schema:rangeIncludes schema:Class . Note that it still does not use
IMO this is not desired. With |
I like the idea of having SHACL on board - I was among those suggesting it in last years. We just need to move carefully - removing the I also find it a bit surprising to modify I'd look rather at |
Shoot, you're right. We already have changed the range and in fact also use `rangeIncludes` 👌
I was again misled by the discrepancy between the JSON-LD and HTML 🤦♂️. We should work on having them synchronised.
That said, I would still propose to add `hydra:expects schema:rangeIncludes sh:Shape`. This way we would explicitly define the types which a generic client should handle. Otherwise, like you said, `hydra:Resource` is a totally open-ended fallback.
I'm curious about your other ideas. While I don't think `supportedClass` fits SHACL, I would like to know what you had in mind for `hydra:property`
|
Oh, what about The entire mappings could easily be swapped with a Shape, provided that individual 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.
Of course, some limitations could be imposed for practical reasons:
Maybe I should make a separate issue to discuss this? |
I was wondering whether there is any need to denote that a mapping can be a SHACL property - in RDF everything used as predicate is considered rdf:Property (correct me if I'm wrong), thus I see no point in explicitely saying that a I still see some benefits from using SHACL for cardinalities, but I think it is a way beyond this issue. |
You propose to simply replace
I'm confused. The
And the cardinality is only because SHACL does not have a |
No, I'd leave it as it is now. I wouldn't introduce new constructs just for SHACL. I think my:Class a rdfs:Class .
my:predicate a rdfs:Property;
rdfs:domain my:Class .
my:Class a owl:Class .
my:predicate a owl:FunctionalProperty;
rdfs:domain my:Class .
my:Class a sh:NodeShape;
sh:property [
sh:path my:predicate
] . All of the above snippets defines same concept (more or less) of a class some:resource my:predicate "value . ...in which case it won't matter how the |
I am completely lost. For one, I don't understand why you bring in the By using SHACL for both
Surely, SHACL has features which we cannot currently match. Such as cardinalities, I would hardly want to reinvent that in |
All of these, SHACL, RDFS, OWL (and maybe other not mentioned here) allows you to describe data structures that an API can use (among other things that you can do with those vocabularies).
These were just examples to give a broader context of property definition. In SHACL you define a property in a shape's context, in RDFS/OWL you don't need a class, but I've added it to show the analogy.
I see no way how |
No but you may want to create UI for the form to take user input.
There is definitely more to SHACL. For example |
I was wondering on how to support various ways of how supported data structures could be hinted to the client. Currently I was also thinking on how the client would tell a server on it's preferences regarding data structure description (I've mentioned various ways of describing those in my previous post). Maybe a Prefer header? I'd love to see hydra as a common framework driving API, but I hate seeing several hydra dialects applied here and there so no generic client can talk to all of them. |
Class and Shape are orthogonal. A shape can, via
If we agree to add In the long run could even see |
I don't know SHACL that much - all I can see is that targets are used to create "node focus" for validation (i.e. which parts of the graph should validated against a shape).
I don't see how those two are related to each other. I was thinking on how client could ask server to describe it's data structures with desired vocabulary. Expectations are opposite - client describes something to the server. |
Quite interesting, but not what I had in mind indeed. I am only considering the API Documentation and not the resources themselves. What I meant is that a client if we have
then a compliant client will have to understand both ways in which an API might describe its operations. And anything else we add to this |
I've had issues with I have had the same issue, which i've described at length before, where I do wish to document those things alongside the ApiDocumentation documents, so that a browser could do useful displaying of those. The same issue with supportedClass / hydraClass prevents me from doing that there, so after consulting with some of you, I've also gone back to adding my own rdfs:Resource there, as an ApiDocumentation extension, which is completely out of specficiation and will only work for us, and as it's not in spec it's probably never gonna be interoperable. The specification itself never says that a browser or a client should know about rdfs at all, which makes it impossible for interop to exist, as no one knows what it would look like. All this to say two things: I don't really like breaking changes if I can avoid them, as like most devs I work on spec numbers, and continuous specs are a nightmare, and I'd like to have a plan to a 1.0 before I fork my work so I can actually support my API commercially over time. Secondly, and here I quote the specification:
Hydra is about adding hypermedia. It looks to me like it's never been tied to any schema system explictly so far, and I think it would benefit from not doing so.
I think that's no longer correct anyway, but even so, the premise itself I believe is flawed. There's RDFS, OWL, SHACL, but also (json schema in rdf)[https://www.w3.org/2019/wot/json-schema] (and json schema has rather wide industry support out there), and if i follow the spec today, i'm very much lost: except for properties to hydra:Resources being needed or not (round hole square peg problem, as defined above), schemas are not talked about and left as an exercise in creativity, also as described above. That renders the majority of my APIs not compliant as it exist. If we move everything to SHACL, then that's a breaking change, and the spec is still kinda neither here nor there. The current spec doesn't work for me, due to not providing the simple features to document schemas for things that are not dereferencable. I would suggest relaxing payload descriptions and supported classes to non-hydra types that could be then described independenlty and more effectively by a schema language of choice that would make sense to the industry in which hydra is used? Those could be additional lightweight specifications "Json Schema in Hydra APIs", "RDFS and SHACL in Hydra APIs" etc. Alternatively, one specification that covers describing all types that an API may use, with the minimum set of required if people feel that's useful, and then a controlled way to expand those hydra-defined things with additional schema (a binding to json schema, additons opf shacl shapes, etc). Let me read, and implement Hydra alone, in a client and in a server, without having to bring in the whole RDF world with me. I'll add one final note: reusable generic hypermedia clients have not received much love on most platforms, and making it harder to create one is not gonna help anything. |
Although I agree with @tpluscode in that SHACL solves the problems Hydra tries to solve better, I also have to agree with @serialseb here. We are specifying the Core vocabulary of Hydra, which I think implies being as concise and free of dependencies as possible. Instead of baking in any defaults for schema and shape validation, it would be great if Hydra Core allowed extension points that could be implemented by SHACL, OWL, JSON Schema, Relax NG, XSD or any other schema mechanism. I'm not even sure Hydra should provide its own MVP schema language out of the box, or simply define that as out of scope for the Core specification and delegate it to one of possibly many extension specifications. An extension specification that bridges SHACL and Hydra would get my vote, though. And I do think such a spec could be embraced as an official recommendation for a "Hydra Standard Profile" (a spec that defines which extensions to prefer for each of Hydra's extension points), but not as a requirement for Hydra Core. Thoughts? |
I was just thinking that indeed right now. I did hint above that anything we reference in the Core spec should be implemented by a generic client. But we also cannot have a client implement all possible schema options.
Right... It hardly makes sense to maintain a built-in model (
The vocabulary is already open enough to allow anything to be used with |
Exactly. What do you say, @serialseb? Is the value provided by
It would be great to see an attempt at specifying the bridge between Hydra and at least two different schema languages, just so we can get a clear picture of how that interaction is going to look like. If there are any wrinkles, we should iron those out before Hydra Core reaches v1.0. |
This should be fixed now as both
Terms from schema.org are quite dereferencable - HTML returned contains some markup that carries RDF details (I don't remember whether it was Microdata or RDFa). While not that common and difficult to process by clients, it's RDF.
I think that is not the purpose of hydra. You should use any of the mentioned schemas here to describe your data. Hydra should enable you to make some of those displayed things links or buttons.
Good point. I just think that when working with RDF, rdfs is a must. Basic RDF concepts are formalized in RDFs, thus simple use of
I agree. That's why I tend to hold some horses here :)
That's right - hydra never coupled itself with any specific external vocabulary. I prefer to enable hydra for extension rather than to bind it to some other vocab.
I don't think it'll gonna happen.
That's why I've pointed to it at the very beginning of the discussion:
Let me help you - it shouldn't. I don't think hydra should come with neither data structure definition language nor query language.
My initial thought on using SHACL was a soft recommendation within the spec but some RDF constructs opening hydra for extensions are welcome. |
To wrap up things, we've got currently 3 areas where SHACL (and possible other vocabs) could be used alongside with hydra:
|
I created PR HydraCG/extensions#8 to start writing down SHACL bits Please have a look |
Describe the requirement
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 and also becomes integrated into triple stores and other tools.
Various potential usages are listed on the SHACL Use Cases and Requirements W3C note.
SHACL can do easily do all that we are currently missing or half-heartedly support:
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 ofexpects
:Alternative solutions
For a moment I thought to keep the range but that doesn't seem right 🤷
The problem with
hydra:Class
may be that it is a subclass ofrdfs:Class
but shape isn't. In fact, there may be multiple shapes which has a sharedsh:targetClass
. They do serve a different purpose.Thus, I don't see a different solution right now.
The text was updated successfully, but these errors were encountered: