Concorda / concorda-dashboard

concorda dashboard
MIT License
5 stars 8 forks source link

consider changing API alias to plural "/users" instead of singular "/user" ? #115

Closed girishla closed 8 years ago

girishla commented 8 years ago

I find that using the plural form of nouns (/users as opposed to /user) is more widely adopted and less frowned upon. Any chance of changing it ?

mirceaalexandru commented 8 years ago

Well I am not really agree of using plural. For me it seems better to use the entity name (such as in DB the standard is to not use plural for table/collection names). So for me it seems very natural to have something like:

GET /api/user?someFilters.... - list of users
GET /api/user/{id} - single user
POST /api/user - create user
PUT /api/user - update user
DELETE /api/user/:id - delete specified user

In this way we have an uniform API for managing users. Otherwise all will use singular, only for

GET /api/user 

will use plural.

Or you want plural for all, even if returns/alter a single user?

But I think this is possibly a personal view, we can leave this open for other comments.

@mcdonnelldean @ckiss ?

girishla commented 8 years ago

I agree it's not set in stone by any spec that we really follow - but standards like JSONAPI recommend the plural form

I've also only seen the plural form in a vast majority of systems I've worked with.

Some APIs like github use the singular form for a special purpose like GET /user would get the current authenticated user - and they use plurals in all normal cases.

Again, it isn't a biggie, just a frown factor :smile: No worries if we don't want to :thumbsup:

mcdonnelldean commented 8 years ago

I don't know what the right answer is here. @mcollina @rjrodger Opinions on plural vs singluar for endpoints?

rjrodger commented 8 years ago

GET /foo returns a list of foo GET /foo/1234 return foo with id=1234

GET /foos is an alias for foo - so I guess the real feature is an extended aliasing capability for seneca-web

But in this particular case, we can just kludge in an alias, so that /users will also work anywhere /user works - again this is no harm in this - in fact, Postel's Law demands it: https://en.wikipedia.org/wiki/Robustness_principle

mcdonnelldean commented 8 years ago

Seems like a fair comment, so the end result is we should have both.

girishla commented 8 years ago

👍 cheers, I'm starting to like Mr Postel 😀

mirceaalexandru commented 8 years ago

We can add support for alias in seneca-web, but this will just duplicate route as there is no build in support for alias in Hapi.

https://github.com/hapijs/hapi/issues/1099

girishla commented 8 years ago

Yes that's true, and will cause a bit of confusion - more so if there is tooling like swagger UI to generate API docs. Duplicate routes don't look good in documentation.

girishla commented 8 years ago

Let's park this for now as it looks like most of you in Seneca are used to the singular form.

mirceaalexandru commented 8 years ago

Is not about what we are used to, is what is best thing to do. I just presented my personal opinion and let the discussion open for other comments. There is a debate about using singular vs plural vs using both. So we must decide what to do and follow best practices, we can change our habits :)

girishla commented 8 years ago

Sure 😀.. How about make it an option into concorda?

rjrodger commented 8 years ago

Guys, there is an orthodoxy that says exactness is the right way to code, but that leads to brittle software. Again there is simply no harm in having an alias, and it can be noted as such in the docs.

mcdonnelldean commented 8 years ago

Agreed on this! But lets work it in to our current iteration plan

Kindest Regards,

Dean

On 10 Feb 2016, at 11:33, Richard Rodger notifications@github.com wrote:

Guys, there is an orthodoxy that says exactness is the right way to code, but that leads to brittle software. Again there is simply no harm in having an alias, and it can be noted as such in the docs.

— Reply to this email directly or view it on GitHub.

girishla commented 8 years ago

yes, makes sense. Thanks guys! appreciate the responses.

mirceaalexandru commented 8 years ago

I think we can close this.