inheritance and link serialization?
Hi,
I'm trying to construct a self link for a parent child relationship. I'm working on the snapshot so I have some of this which is great. However I don't see how to get the parents into the @Type annotation.
What I would like to do is something like this:
@Type(value = "parent", path = "/v2/parent/{parent.id}/child/{id}")
So but the parent and child class have an id, but the child is not accessible directly. You have to go through the parent to get the child.
I've played around with this but have not had any success. Do you have any suggestions?
Thanks!
Hello,
Support for accessing parent is not there, here is why:
- both parent and child should be first class citizens on your API
Parent path example: /v2/parent/{id}
Child path example: /v2/child/{id}
Relationship path: self: /v2/parent/{id}/relationship/child, related : /v2/parent/{id}/child
It is server's responsibility when you invoke /v2/parent/{id}/child to figure out which child is related to specified parent object and return it. Explicit id is not used.
As I understand the specification, there is no concept of ownership (no resource owns other resources), relationships are a mechanism to connect the resources.
There should not be API methods like this: /v2/parent/{parent.id}/child/{id}
Please let me know if Im missing the point here.