-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to distinguish controllers that return an object or a list? #7
Comments
Option 1: use rules for guessing what is expected to be returned For example, Pros:
Cons:
|
Option 2: let user to specify what is expected in the result
- path: /categories/:id
get: SELECT ...
return: object <-- NEW
- path: /categories
get: ...
return: list <-- NEW The name also could be
- path: /categories/:id
get: SELECT ...
- path: /categories
get: ...
hints: <-- NEW
- "result:list" The name also could be
- path: /categories/:id
get: ...
- path: /categories
get_list: ... <-- NEW Here we have many names: Pros:
Cons:
|
Hey @php-coder, I suppose, that option 2.1 is more suitable for fixing your issue. Because but no matter as you wish you cannot avoid adding new field, so it had better been more clear for understanding for user. That is why modify |
After discussions I started to think about introducing a single field. I had something like this in mind: input:
...
output:
multiple: true <-- look here
type: PersonDto
fields:
id: int
name: string Because I can't predict future and I can't suggest an option that I would be happy with, I've decided to go with the simplest and fastest approach right now. I will change API when I have more use-cases. In 44c061d I introduced I leave the issue open because I anticipate that the current solution will be revised in future. |
At this moment we have
get
verb that accepts aSELECT
query. Some endpoints return a single object (GET /category/1
) while others return a list (GET /categories
). In addition, when we expect an object, code should return 404 error for an empty result, while for a list, it should return an empty list. Example:How we can distinguish such cases so we can generate different code?
The text was updated successfully, but these errors were encountered: