0

I have been asked to implement HATEOAS as part of our rest API and this is how the response is defined in Swagger specs

_links: 
[
 {
rel:    
 string
The relationship to the request e.g. self which contains the resource that was requested or {object name}, a link to a resource that is related to the requested resource
action: 
[
 {
    httpVerb:   
         string
        Allowed actions for this link based on the users permissions
        Enum:
        Array[4]
           0:"GET"
           1:"POST"
           2:"PUT"
           3:"DELETE"
   }
]
    href:   
      string
      A fully qualified URL to the resource.
  }
]

rel and href make sense and I could find many examples for these two but I could not find anything for actions. Is it part of the standard? Should I really send it back?

I am using Spring hateoas library and that for sure does not support actions. Any guidance on this will be appreciable.

Thanks.

java_buzz
  • 67
  • 1
  • 6
  • Did some research. Palpal uses this format [link] (https://developer.paypal.com/docs/api/hateoas-links/#the-link-object) but HAL format is different and I found that changing Spring HATEOAS HAL format is not so easy. – java_buzz Mar 11 '17 at 22:59
  • _"Is it part of the standard?"_ Which standard are you referring to? You don't mention any in your question. And what is your actual question? – a better oliver Mar 12 '17 at 14:49
  • Sorry was not clear in my question. I was referring to HAL standards. HAL does not define _action_. Is there a standard which dictates that _action_ should be defined as part of specifications? – java_buzz Mar 13 '17 at 08:00

1 Answers1

1

What's interesting is that _links (with an underscore) is a HAL thing, so I don't expect the spec you got following any standard.

One standard I am aware of that includes actions is SIREN, but they differ from the action in your example.

Many REST APIs aren't even RESTful, not to mention HATEOAS. So the value of following a particular standard (or "standard") is debatable for now.

a better oliver
  • 26,330
  • 2
  • 58
  • 66
  • Thanks zeroflagL. I agree with you. I read a lot in last couple of days about it and looks like it is too early to follow one standard. Here is the list of many standards which are around if someone needs them : HAL [link](http://stateless.co/hal_specification.html) HYDRA [link](http://www.markus-lanthaler.com/hydra) Collection + JSON [link](https://github.com/collection-json/spec) JSON API [link](http://jsonapi.org/format) SIREN [link](https://github.com/kevinswiber/siren) JSON-LD [link](http://json-ld.org) – java_buzz Mar 13 '17 at 09:35