vt-elixir / ja_serializer

JSONAPI.org Serialization in Elixir.
Other
640 stars 148 forks source link

Optional json-api version member ? #321

Closed tzumby closed 1 year ago

tzumby commented 5 years ago

I noticed the library adds the version member by default, with no way to exclude it from the JSON payload. The specification marks that as a MAY, I'm curious to see what you all think about adding a flag to exclude that ? I could contribute with a PR

{
  "jsonapi": {
    "version": "1.0"
  }
}
beerlington commented 5 years ago

I'm interested in keeping with the spec, but I'm curious what the use case would be. If JaSerializer only supports 1.0, why would you want that optional?

tzumby commented 5 years ago

I may have jumped the gun when I created this issue :)

The reason I would want this optional is because I'm working with a json-api that is not following the spec and breaks if you provide a version object. The obvious solution is to get the API to follow spec. I just happened to see that the version is optional and wanted to see your opinion about allowing that. This may not be worth it on a second thought.

beerlington commented 5 years ago

I'm on the fence on this one. It doesn't seem like JaSerializer is doing anything wrong by including the version and any client that consumes then JSON:API should be able to just ignore it in the response if it's not using it. I don't think this is a compelling enough reason to make the version optional, but I'll leave this issue open for comments.

denniscastro commented 5 years ago

If you have an application with legacy code and his tests and the consumer application (SPA) are strictcs, it's better that the version member be optional.