- From: Dietrich Schulten <ds@escalon.de>
- Date: Mon, 05 Jan 2015 10:41:57 +0100
- To: public-hydra@w3.org
- Message-ID: <54AA5C65.90907@escalon.de>
Hi Kévin, That is currently not possible, maybe you want to review https://github.com/HydraCG/Specifications/issues/82 and see if the proposal given there would make sense for you. The issue of resource descriptions for expected requests has a number of competing solutions none of which is a good match for hydra at this time (IMO). - The Resource Shapes WG W3 submission [1] shows how to describe shapes using a polished version of oslc, but that is just one possible example how a future resource shape could look like - others are ShExC, SPIN, etc., and the WG has not arrived at anything of practical relevance yet. - schema.org actions [2] require you to PUT/POST/PATCH an Action class instead of the actual object you want to edit on the server. Unfortunately that is not a good match for most existing APIs where you simply send an item which should be added, replaced or updated - this makes it difficult to implement an API and render its responses interchangeably as Hal, json-ld or whatever, because the concept of requesting an Action does not exist in other media types. OTOH if you use schema:potentialAction, you have a quite powerful request description tool, but it is really a parallel world to hydra:operation (in spite of existing attempts to unify both). On the other hand, schema:potentialAction is well established in the wild, Gmail uses it already. Please let me know if the latter route is an option for you, I am interested if there is an audience for the parallel world in hydra-java [3]. [1] http://www.w3.org/Submission/shapes/ [2] http://schema.org/docs/actions.html [3] https://github.com/dschulten/hydra-java/ Best regards, Dietrich Am 05.01.2015 um 09:08 schrieb Kévin Dunglas: > Hello, > > Is there a way to describe allowed values with Hydra? > > For instance if I my API supports: > > * gr:ConstructionInstallation > * gr:Dispose > > > But not: > > * gr:Sell > > > 2014-09-07 23:25 GMT+02:00 Markus Lanthaler <markus.lanthaler@gmx.net > <mailto:markus.lanthaler@gmx.net>>: > > On 7 Sep 2014 at 13:50, Dietrich Schulten wrote: > > Am 06.09.2014 15:21, schrieb Gregg Kellogg: > >> On Sep 6, 2014, at 12:04 PM, Dietrich Schulten wrote: > >>> { name: "Pirates of the Caribbean", acquire: "RENT", delivery: > >>> "IN_SHOP" } > >>> > >>> Can I write a context which says that "RENT" means > >>> http://purl.org/goodrelations/v1#LeaseOut and "IN_SHOP" means > >>> "http://schema.org/OnSitePickup"? The json-ld spec seems not to > >>> mention such a usage. > >>> > >>> It seems that terms cannot appear as attribute values unless the > >>> attribute is @type. Also, jsonld-java doesn't understand what I > >>> might mean by: > >> > >> Actually, you want @type: @vocab, which will allow term values > >> without needing a compact URI form. > > > > After some discussion with Gregg who pointed me to > > http://www.w3.org/TR/json-ld-api/#value-expansion, this is the > outcome. > > > > The @vocab keyword has a second meaning which is not mentioned > in the > > json-ld spec, only in the api. If used as a value of @type in the > > context, it says that the corresponding attribute value must be > > expanded to an IRI. > > Actually, it's also described in the syntax spec (but there's no > example): > > http://www.w3.org/TR/json-ld/#type-coercion > > > > > Example: > > Define @vocab to be schema.org <http://schema.org>, let "gr" be > goodrelations, let > > "delivery" be @type:@vocab, then the value of the "delivery" > attribute > > in the JSON will be expanded as an IRI. > > > > The effect on the value of "delivery" is this: - A compact IRI > > gr:LeaseOut expands to http://purl.org/goodrelations/v1#LeaseOut. - > > Without gr: the @vocab value of schema.org <http://schema.org> > is prepended. Useful if the > > enumerated value is in schema.org <http://schema.org> - And now > the surprise: If I > > additionally define RENT to be gr:LeaseOut, that will be > resolved, too: > > > > { > > "@context": { > > "@vocab" : "http://schema.org/", > > "gr": "http://purl.org/goodrelations/v1#", > > "delivery" : { > > "@id" : "availableDeliveryMethod", > > "@type" : "@vocab" > > }, > > "RENT": "gr:LeaseOut" > > }, > > "@type": "Movie", > > "name": "Pirates of the Carribean", > > "offer": { > > "delivery": "RENT" > > } > > } > > > > expands to the following in the http://json-ld.org/playground/ > > > > { > > "@type": "http://schema.org/Movie", > > "http://schema.org/name": "Pirates of the Carribean", > > "http://schema.org/offer": { > > "http://schema.org/availableDeliveryMethod": { > > "@id": "http://purl.org/goodrelations/v1#LeaseOut" > > } > > } > > } > > > > Thanks a lot! > > Yep, this is a very powerful feature. > > > -- > Markus Lanthaler > @markuslanthaler > > > > > > -- > Kévin Dunglas > Consultant et développeur freelance > > http://dunglas.fr > Tél. : 06 60 91 20 20
Received on Monday, 5 January 2015 09:42:35 UTC