I am designing a REST service with multiple end points which will be servicing the following hierarchy:
Department
has many Category Group
s
Category Group
has many Category
(-ies)
Category
has many Sub-Category
(-ies)
Sub-Category
has many Attribute
s.
Now, all these entities except for Attribute
s are optional meaning if I don't select anything on my hierarchical cascading dropdown based UI, I need to display the Attribute
s that belong to all Department
s, if I only select a Department
then I need to display Attribute
s that belong to all Category Group
s belonging to that Department
and so on.
The end goal is to save the hierarchy specifically the Attributes
and their parental relationships.
I have this rough structure in my mind to populate the cascading dropdown on the UI:
GET /departments - gives a list of all departments
.
GET /departments/[departmentIds]/categoryGroups - gives a list of category groups for all departments
.
GET /departments/[departmentIds]/categoryGroups/[categoryGroupIds]/categories - gives a list of categories for the given category groups and departments
.
And so on for sub-categories
and attributes
.
Can I shorten the last end point above to just be: GET /categoryGroups/[categoryGroupIds]/categories
?
For all attributes
in a department
can I just have -GET /departments/[departmentIds]/attributes
?
For all attributes
in a category group
-
GET /categoryGroups/[categoryGroupIds]/attributes
?
Will so many end-points be considered an end-point explosion of sorts? Are there any better ways of solving this?
Thanks.