RE: Implementing Hydra in PLP Provider

On 1 Dez 2014 at 03:43, ☮ elf Pavlik ☮ wrote:
> Howdy!

Hola :-)


> I just got prototype of PLP Provider to the point where I can start
> implementing Hydra API
> https://github.com/hackers4peace/plp-provider/tree/hydra

Great! I'm writing this offline so I can't have a look at the moment.


> Currently README describes implemented API, TL;DR
> 
> POST /
> GET /:uuid
> PUT /:uuid
> DELETE /:uuid
> 
> Tomorrow I plan to work on first draft of hydra:ApiDocumentation. Few
> questions come to my mind
> 
> 1. Can I set entrypoint to / and define for it suportedOperation
> { "method": "POST", "@type": "CreateResourceOperation" }

Yes. Make sure that you use hydra:operation if you associate it to the "/" resource. supportedOperation has to be used with either a class or a property and then applies to all instances of the class or values of that property.


> 2. From API perspective I would like to treat all resources as
> plp:Profile, but let them have actual types like schema:Person,
> schema:Event etc. Do I need to include plp:Profile in @type of each
> resource or hydra:ApiDocumentation could handle this somehow?

Yes, I guess you have.. unless it is fine for you to depend on some RDFS inferences.


> 3. How to describe required Authorization header? - POST, PUT, DELETE
> require JSON Web Token(JWT)[1] in it

Hydra doesn't allow you to describe that at the moment. You may use HTTP's authentication headers for it instead.


> 4. How to describe property which requires Mozilla Persona assertion[2],
> assuming existence of an URI for such class (let's say
> persona:Assertion). Would something like below do:
> 
> {
>   "@context": "http://www.w3.org/ns/hydra/context.jsonld",
>   "@id": "http://hackers4peace.net/plp/api#login",
>   "@type": "Link",
>   "title": "Login",
>   "description": "A link to login endpoint",
>   "supportedOperation": [
>     {
>       "@type": "LoginOperation",
>       "title": "Login to the web service",
>       "method": "POST",
>       "expects": "persona:Assertion",
>       "returns": "auth:JsonWebToken",
>       "statusCodes": [
>         ... optional information about status codes that might be
> returned ...
>       ]
>     }
>   ]
> }

Yes. This is how I would describe it.


> Thanks for your feedback!

You are welcome :-) Please keep us posted on your progress


> [1] http://jwt.io
> [2] https://developer.mozilla.org/en-US/docs/Web/API/navigator.id.get


--
Markus Lanthaler
@markuslanthaler

Received on Sunday, 14 December 2014 19:45:28 UTC