I have some trouble with understanding the perfect way to apply the REST pattern for objects and subobjects. Let us consider following classes:
class Foo {
Long id;
Bar bar;
}
class Bar {
Long id;
String name;
}
As far as I understand in simple cases we have:
- List of
Fooobjects -.../foos - One
Fooobject -.../foos/{id}
Now I have problem understanding how accesing subobjects will work. What will be correct if I want to fetch Foo objects, in which Bar objects has name == baz
Whether that will be .../foos/bar/name/baz or /foos?barName=baz?
Which mapping should I use to fetch Bar objects by parameter name out of Foo?. Would that will be .../foos/bar/{name} or something different?