nilportugues / symfony-jsonapi

JSON API Transformer Bundle for Symfony 2 and Symfony 3
http://nilportugues.com
MIT License
115 stars 19 forks source link

Class name is serialized singular? #6

Closed mmucklo closed 8 years ago

mmucklo commented 8 years ago

Any way to change the way the class name is serialized - e.g.

Article.php --> "type": "article"

versus

Article.php --> "type": "articles"

The examples on jsonapi.org seem to tend towards plural, although the spec is "agnostic" about it.

http://jsonapi.org/format/

nilportugues commented 8 years ago

Class name is just transformed to an underscore version by default.

It is possible to decide to what it's serialized by using the yml file during the mapping process.

mapping:
  class: Acme\Domain\Dummy\Post
  alias: messages #user defined plural.
...

This bundle does the hard part but does not try to force you anything allowing its user to be the one under control.

mmucklo commented 8 years ago

Got it, thanks. It might be nice to have a parameter to pluralize everything in the future, but as long as there's a work around...

nilportugues commented 8 years ago

@mmucklo yeah I agree this should come as an enhancement