Open Odaeus opened 8 years ago
Hi @Odaeus, nice to see you here.
The JSON-API implementation is mostly contributed by @janko-m and @groyoh. I don't immediately have time to work on it, but I'll happily take contributions.
It seems the pluralization is indeed hard-coded.
# @param [Yaks::Resource] resource
# @return [Hash]
def serialize_resource(resource)
result = {}
result[:type] = pluralize(resource.type)
result[:id] = resource[:id].to_s if resource[:id]
I'm guessing pluralize
calls dup
internally, hence your other issue. (this is really just a guess)
This could be made configurable, you can have a look at the HAL serializer for how to use format_options
yaks = Yaks.new do
format_options :json_api, {pluralize_resource_names: false}
end
If I'm using JSON API as the formatter and I set a type:
I'd expect the output to be:
But instead the type is pluralised to "books" and I can't see a way to stop it.
The JSON API spec says:
Though I'm not sure why, as not even Rails has ever pluralised the type of single objects.