Edited Question based on the comments and great feedback (thanks)
I have a REST controller exposing two GET endpoints.
- GetById - taking a single id (string)
- GetById - taking multiple id's (a collection of type string)
The only thing the controller does is call the service/domain layer which also exposes the GetById method. Both of these methods are part of the public interaface of the service layer.
The question is in regards to design, is it a good choice to force the client to create a collection from a single string e. g. new {myId}, or should the public API support both of these methods?
Original Question
I am currently facing the following situation. I have a REST Controller which accepts a single string (an id). This id is then passed to the underlying service layer which has a method also taking one string (the id).
Now I have the requirement to also accept multiple id's. The REST controller must accept multiple id's, however my question is, should the service layer provide now only one method taking multiple id's (List/Enumerable) or should the method be overloaded with both, a single string and a collection?
Thank you!