We're designing and developing an enterprise application using Spring Boot for REST APIs and Angular 8 as the web client. It's been an year since we started.
When I started, I read multiple articles which cleared my understanding of why REST without HATEOAS is not actually REST. I went ahead with the then available Spring HATEOAS project which was on v0.25 (not stable) then but good enough to get us started.
Now, it has moved to a stable 1.x version and we have upgraded to it.
In our case, we have a collection of documents stored in MongoDB which is used for multiple APIs. Think of it as a collection which contains lot of information and it has more than 3 ways to represent. And 95% of our APIs are GET requests, only 5% are PUT, POST and DELETE. Its a monitoring application API, you get it.
Now, I believe that the relation between a Resource and a Controller should be one-to-one.
Question 1: Am I correct with this?
And,
Question 2: Am I correct with the premise that as soon as the URL is same, the resource structure must not change?
Like, every time I hit the URL https://example.com/status, I must get a consistent structure of Response, irrespective of the query params I give to the API i.e. the number of keys in the response will be the same, but the values could vary.
Question 3: How do we define parent-child relation in a resource. Or should we even care about it?
Moving on,
Question 4: If I want a subset of keys for a Resource, should I define a new Resource for it, or I can manipulate the structure by giving some query parameters?
Answer to even one of the question could help me a lot.