Skip to content

Add support for allowed literals and allowed individuals #82

@dschulten

Description

@dschulten

Currently there is no way in hydra to express a fixed number of possible values.

There seem to be no other established vocabularies which allow us to do so. At some point the RDF Shape WG shall provide a comprehensive way to express this and other constraints which then would supersede this proposal., But I think we need this earlier and I hope that hydra can provide valuable input to the Resource Shape WG by introducing such a facility which also integrates well with json-ld.

Proposal:
Have the following new properties and classes.

FIrst, hydra:allowedIndividual for enum values or other individuals with optional localized hydra:title to solve the value vs. caption problem.

* hydra:allowedIndividual :range hydra:AllowedIndividual - to hold the allowed individuals
  * hydra:AllowedIndividual - wrapper for allowed individuals with localized title
  * hydra:individual :domain hydra:AllowedIndividual - allowed URI values for a supported property

The :individual is for allowed values which are URIs, it should be used to apply @type:@vocab in the context.
Sample usage below. Client has requested Italian. The other language constructs of json-ld would work, too, see sample jsonld playgrounds below.

{
  "@context": {
      "@vocab": "http://schema.org/",
      "hydra": "http://www.w3.org/ns/hydra/core#",
      "hydra:individual": {
        "@type": "@vocab"
      }
  }
  ...
  "hydra:supportedProperty": [
      {
      "hydra:property": "eventStatus",
      "hydra:allowedIndividual": [
        {
          "hydra:individual": "EventCancelled",
          "hydra:title": "manifestazione annullata"
        },
        {
          "hydra:individual": "EventPostponed",
          "hydra:title": "manifestazione rinviata"
        } 
      ]
    }
  ]
}  

Second, hydra:allowedLiteral is for scalar values like strings or numbers.

* hydra:allowedLiteral - allowed literal values for a supported property

Finally, by dereferencing hydra:allowedResource the client can get a Collection or PagedCollection of allowed individuals which may have a search property in turn. This would be useful in case the number of allowed individuals is too large for :allowedIndividual.

* hydra:allowedResource - Resource or IriTemplate to retrieve allowedIndividuals

Also see http://tinyurl.com/qz85ep6 for a real-life JSON-LD playground example of allowedIndividual vs. allowedLiteral.
On http://tinyurl.com/om7fsqc one can see a language map.
On http://tinyurl.com/px4aj75 one can see an illustration for allowedResource with IriTemplate.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions