Skip to content
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

Singular vs Plural Resources #16

Closed
dgeb opened this issue May 5, 2013 · 1 comment
Closed

Singular vs Plural Resources #16

dgeb opened this issue May 5, 2013 · 1 comment

Comments

@dgeb
Copy link
Member

dgeb commented May 5, 2013

I'd like to discuss the use of the plural form of a resource name, regardless of whether a single object or an array of objects is returned.

For example, a single post is to be returned as posts:

{
  "posts": {
    // an individual post document
  }
}

Just like an array of resources:

{
  "posts": [{
    // an individual post document
  }, {
    // an individual post document
  }]
}

I can see some advantages to this approach:

  • it ensures that a single record won't be included twice (e.g. as a post and as a member of posts)
  • it may reduce the needs for an inflector in the client (although model names are often singularized, in which case singular/plural translations are still needed)
  • it makes the client leaner by eliminating the need to check both singular/plural forms of the noun

The disadvantages I see:

  • it is arguably semantically incorrect to return a single object with a plural key
  • it breaks with the conventions in stock Rails, AMS and most REST APIs I've encountered

It would be good to discuss this further and clarify the rationale in the spec.

@wycats
Copy link
Contributor

wycats commented May 5, 2013

This is a dup of #8 (which has a poor title). I'd love to get your feedback on my comment there.

@wycats wycats closed this as completed May 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants