Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • The name of the embedded resource in our example is customers.
  • Other embedded resource names can be included. Each embedded resource name is a sub-property of the _embedded property.
  • Embedded resources can be singular (i.e., the value is just a resource object) or plural (i.e., the value is an array of resource objects). If the embedded resource object is singular by definition, then just set the value to a resource object. Otherwise, use an array even if there is only one embedded resource object. Otherwise, adding an array later on could break clients.
  • Each embedded resource object should also include its own self relation link (which is identified by the _links property).

In Summary

While HAL is not the only IANA registered media type that provides standards for including hypermedia in JSON objects, it is one of the most popular. For this reason, the SRP HTTP Framework provides the AddLinkRelationship and AddEmbeddedResources services to make it much easier to create HATEOAS APIs.