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

Add configuration option to set resource type to singular/plural #1081

Merged
merged 1 commit into from
Aug 28, 2015

Conversation

beauby
Copy link
Contributor

@beauby beauby commented Aug 24, 2015

JSONAPI spec (http://jsonapi.org/format/#document-resource-object-identification) does not specify whether the type should be singular or plural. By default, AMS makes it plural, while some client-side libraries default to singular. This PR adds a configuration option to globally set it to plural or singular. (c.f. #1080)

@beauby
Copy link
Contributor Author

beauby commented Aug 24, 2015

The proposed config key is jsonapi_resource_type (I couldn't find anything better... any idea?), which takes values :plural (by default) or :singular. I'll update the docs if there is interest on this PR.

@joaomdmoura
Copy link
Member

Cool @beauby Thanks you so much, I'm merging this 😄

joaomdmoura added a commit that referenced this pull request Aug 28, 2015
Add configuration option to set resource type to singular/plural
@joaomdmoura joaomdmoura merged commit 64168cb into rails-api:master Aug 28, 2015
@joaomdmoura
Copy link
Member

Oh, Could you please also write some docs to it onto our new docs and maybe mention it shortly on README?

with_jsonapi_resource_type :singular do
serializer = CommentSerializer.new(@comment)
adapter = ActiveModel::Serializer::Adapter::JsonApi.new(serializer)
ActionController::Base.cache_store.clear
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SerializableResource? :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, we could use SerializableResource through all those serializer + adapter in the tests, glad that yyou pointed that out@bf4. @beauby could you make a PR updating it?

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

Successfully merging this pull request may close these issues.

3 participants