RE: hydra:returns for operations returning collections of class instances

On 18 Jun 2014 at 18:15, Jindřich Mynarz wrote:
> On Wed, Jun 18, 2014 at 2:21 PM, Markus Lanthaler wrote:
>> That's a good question. The "main entity" that is returned is a collection but the thing the
>> client is probably interested in are the instances of :Class. I'd say the best thing would be to
>> be more explicit, i.e., expressing that it returns a Collection of :Class instances. This would
>> be quite trivial to describe with OWL (property restriction on member).
> 
> If you hint to use OWL in this case, do you mean something like the following?

Yes. I'm modifying your examples directly to show you what I had in mind:

  @prefix hydra: <http://www.w3.org/ns/hydra/core#> .
  @prefix owl: <http://www.w3.org/2002/07/owl#> .
  @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

  </operation/1>
      a hydra:Operation ;
      hydra:returns
      [
        rdfs:subClassOf
            hydra:Collection,
            [
              a owl:Restriction ;
              owl:onProperty hydra:member ;
              owl:allValuesFrom </some/Class>
            ]
      ] .

or, in JSON-LD:
 
  {
    "@context" : {
      "@vocab": "http://www.w3.org/ns/hydra/core#",
      "subClassOf": { "@id": http://www.w3.org/2000/01/rdf-schema#subClassOf", "@type": "@vocab" },
      "owl": "http://www.w3.org/2002/07/owl#",   
      "onProperty": { "@type" : "@vocab" },
      "allValuesFrom": { "@type" : "@id" }
    },
    "@id": "/operation/1",
    "@type": "Operation"
    "returns": {
      "subClassOf": [
        "Collection",
        {
          "@type": "owl:Restriction",
          "onProperty": "member",
          "allValuesFrom": "/some/Class"
        }
      ]
    }
  }


> I think there may be some minor issues with this design.
> 
> Wouldn't this design lead to proliferation of "collection classes" for
> many popular classes? I can imagine that if this was recommended
> practice, then we could see several classes of collections of
> schema:Person or schema:Product etc.

I don't think so because those classes don't need to have a name (or identifier if you prefer). As you see above, you would just 


> The description is in OWL (albeit in a simple subset) and there might
> be few clients and developers, who create these clients, that read
> OWL. If the main goal is to support a machine-readable API
> description, which is also readable to most web developers, and
> reasoning support isn't required, then OWL might not be the best way
> how to achieve this goal.

Fully agreed. If this feature turns out to be important, we can introduce a shortcut or something directly into Hydra.


> This design doesn't help solving the ISSUE #41 (a.k.a. collections
> breaking relationships), which I think is very much related, so a
> solution to this issue should be aligned with the solution to ISSUE #41.

I think it's a mostly unrelated issue.


--
Markus Lanthaler
@markuslanthaler

Received on Wednesday, 18 June 2014 21:47:47 UTC