HydraCG / Specifications

Specifications created by the Hydra W3C Community Group
Other
138 stars 26 forks source link

Supported property values source #227

Closed alien-mcl closed 3 years ago

alien-mcl commented 3 years ago

Describe the requirement

There are circumstances in which API would like to announce source of values for a specific supported property. While Hydra is not focusing on data structure descriptions, binding between properties and operations feeding these properties feels like in the area of interest for Hydra Core Vocabulary.

Hydra-agnostic example

Imagine a UI that shows an auto-generated form based on what API says, i.e. an issue. Between simple literal properties like title and description there is also an assignee. In order to avoid manual typing of person's details I'd like to be able to pick one from a list. Now the tricky part - how to drive that list (and the fact there is that list available).

Proposed solutions

My idea is to extend a bit a specification by inserting a new section in paragraph 5. Advanced Concepts. That bit of a description would describe special behavior that client would need to incorporate in case of either hydra:collection or hydra:search predicates encountered either on instances of hydra:SupportedProperty or rdf:Property. The former would let the client to discover that the collection provided feeds values for that very property and the latter provides a type-ahead-like list of values for that very property.

<> a hydra:ApiDocumentation;
  hydra:supportedClass api:Issue.
api:Issue a rdf:Class;
  hydra:supportedProperty [
    hydra:property api:assignee;
    hydra:search [
      hydra:template "http://temp.uri/api/user{?search}";
      hydra:variable "search";
      hydra:property hydra:freetextQuery;
      hydra:required "true"^^xsd:boolean
    ]
  ].

These details could be provided either on API Documentation level and inlined mandating the client to use the most specific source possible. This would mean that if an inlined declaration is available in the request that drove the form creation, that declaration should be used. Otherwise API documentation level declaration can be used as fallback.