I have a DB schema that has a few 1-n relationships, lets say a User has many Orders which has many Order Lines:
users ----< orders ---< order_lines
I’ve implemented the include parameter on my APIs so a client can request all of this data in one go like this:
/users/1?include=orders.order_lines
From what a gather from the specs, I understand that I need to put both orders
and order_lines
in the included
section of the API response.
It also seems that they need to appear on the same level, i.e. both orders
and order_lines
go into the includes
array as equals.
My questions are:
- Am I understanding this correctly?
- If so, why is this represented as a flat structure? Why isn’t
order_lines
nested insideorders
(maybe as anotherincludes
?)