- Fixed warnings in Elixir 1.17
- Fixed warning in Elixir 1.14 for using Application.get_env/3 in module body. This required Application.compile_env/3 which is only available in Elixir 1.10+
- Empty relationships with links are now handled properly. Instead of returning a relationship resource with a broken link, we now remove the broken links from the serialized "relationships" key. - #340
- Allow "import" to be used as a relationship name - #336
- Bump dependencies and remove support for Elixir < 1.7
- Raise exception when using a reserved keyword in attributes/1 macro
- Removed JaSerializer generators in favor of documenting how to use with Phoenix generators.
- Add optional support for camelCase key format as recommended by JSON:API v1.1 - #316/#317
- Make JaSerializer.TopLevel.Builder.normalize_includes/1 public - #323
- Allow accept header with quality param - #320
- Include relationships in sparse field definition - #324
- Don't render empty relationships - #311
- Omit prev/next links when current page is > last page - #317
- Don't raise AssociationNotLoadedError if belongs to relationship can be determined. - #322
The following workaround is no longer needed:
has_one :city, serializer: MyApp.CityView
def city(%{city: %Ecto.Association.NotLoaded{}, city_id: nil}, _conn), do: nil
def city(%{city: %Ecto.Association.NotLoaded{}, city_id: id}, _conn), do: %{id: id}
def city(%{city: city}, _conn), do: city
- Fix application start up w/out Poison - #310
- Only include attributes key when there are attributes present - #297
- Serializer attribute and relationship function overrides must be public. Previously there was an untested/undocumented way of overriding attributes with private functions, but this is no longer supported.
In other words, change this:
defmodule PostSerializer do
use JaSerializer, dsl: true
attributes [:html]
defp html(post, _conn) do
Earmark.to_html(post.body)
end
end
to this:
defmodule PostSerializer do
use JaSerializer, dsl: true
attributes [:html]
def html(post, _conn) do
Earmark.to_html(post.body)
end
end
- Read key format config value at runtime - #265
- Build pagination URLs using base url and request path - #281
- Issue rendering some ecto changeset errors - #275
- Handle the case where the end of a link is a URI fragment - #293
- Added missing @callback in Serializer - #294
- Consistent relation override - #299
- Fix compilation error when defining already inlined by compiler methods - #304
- Add .formatter.exs for consistent formatting
- Fixed compiler warnings
- Use
capture_io
in tests to make output less noisy
- Add JaSerializer.Builder.PaginationLinks (@bcardarella) - #233
page_number_key
defaults to number instead ofpage
page_size_key
defaults to size instead ofpage-size
scrivener_base_url
renamed topage_base_url
- Allow serializing null structs (@juanazam) - #181
- Preserve ID in
to_attributes/1
(@xtian) - #254 - Allow API to produce pluralized types rather than having to configure each serializer one by one (@bcardarella) - #225
- Generator task for Phoenix 1.3 (@mikeni) - #243
- Fixed formatting of multi-word relationship path keys (@yogipatel) - #230
- Page links are merged in correct order (@qbart) - #251
- Fix an edge case with pagination links (@marpo60) - #252
- Improved performance of inline DSL attributes (@DocX) - #245
- Fixes and improvements by @peterberkenbosch, @petehamilton, @beerlington
- Breaking
- Elixir 1.1 and earlier no longer supported.
- Features
- Elixir 1.4 support. (@yordis, @joshuataylor, @asummers)
- Add
config :ja_serializer, scrivener_base_url:
support (@geolessel) - Support custom key deserialization (@vasilenko)
- Features
- Allow customization of pagination params in Scrivener integration (@scrogson)
- Bugfixes
- Add json api version to error responses. (@nmcalabroso)
- Support umbrella apps in generators. (@gullitmiranda)
- Support {:array, :integer} type ecto fields in error serializer (@henriquecf)
- Bugfixes
- Handle port numbers in link urls. (@MishaConway)
- Documentations
- Fixes and improvements by @archSeer, @JoshSmith, and @rynam0
- Misc
- Cleaned up Credo reported code inconsistencies
- Breaking
- The results of JaSerializer.format/4 now returns maps consistently keyed with binaries instead of mixed binaries and atoms. This is not an issue when rendering to json, but any direct testing of format/4 calls may need to be updated. (@bcardarella)
- Bugfixes
- Ensure deep linked
include
query params are correctly rendered. (@KronicDeth) - Use
build_conn/0
instead ofconn/0
in Phoenix test generator (@dustinfarris) - Properly parse nill relationships when de-serializing params (@kaermorchen)
- Ensure deep linked
- Features
- adds
:relationships
to serialization opts to skip serializing relationships. Defaults to true. (@bcardarella) - Adds preload/3 hook for preloading relationship data.
- Support passing more fields to EctoErrorSerializer (@nurugger07)
- adds
- Features
- Upgrade Scrivener for Ecto 2.0 & Scrivener support (@avitex)
- Bugfixes
- Fix ecto error serialization for both 2.0 and 1.0 support (@KronicDeth)
- Deprecations
- No longer supports Scrivener 1.x
- Features
- There is a full behaviour for serializing, including relationships, with a DSL on top.
- Adds type/2 hook for defining the object type.
- Performance
- Scrivener link integration are now faster (@benfalk)
- Parsing fields params is now more efficient (@benfalk)
- Deprecations
- Prefer type/2 callback over type/0.
- Returning functions from type/0 deprecated if favor of using type/2.
- MySerializer.format/3 deprecated in favor of JaSerializer.format/4.
- Bugfixes
- Fix generator imperative assignment warning. (@parndt)
- Fix default dsl link imperative assignment warning. (@itsgreggreg)
- Features
- Allow type to be set dynamically #94 (@benfalk)
- Add JaSerializer.Params.to_attributes/1 for merging relationships and attributes
- Add generator to generate json-api spec phoenix controllers and tests. (@Dreamer009)
- Bugfixes
- Don't render all pagination links when only one page of results #96 (@adamboas)
- Relax Ecto and Plug dependencies. (Ecto 2.0 support!)
- Performance
- Improved performance of included (sideloaded) relationships. #86 (@dgvncsz0f)
- Breaking
- You must now set the Phoenix :format_encoder for json-api to Poison in config.exs. Phoenix now handles conversion from map to json string. See README for details.
- Features
- Allow Poison 2.0
- Bugfixes
- Allow application/*, / and empty accept headers without returning 406.
- Count errors now display full message in description.
- Fixed serializing lists - #78
- Features
- Param parsing now happens via a protocol for extensibility.
- Breaking
- Pagination, sorting, filtering query param keys are now formatted with the configured key_format. This means the API outputs and expects dasherized by default. (@linstula)
- Features
- Deprecations messages now consistently formatted and contain a stack trace. (@derekprior)
- Features
- Type is now formatted as underscore or dasherized, same as your key setting. (@linstula)
- Features
- Updates error serializer to include field name in description. (@cjbell)
- Bugfixes
- Retain type information when deserializing. (@linstula)
- Fix pipe warning in Elixir 1.2 (@bortevik)
- Features
- Allow query params in link formatting. (@simonprev)
- Deps added to application for exrm. (@dmarkow)
- Bugfixes
- format_key typo in ecto_error_serializer (@gordonbisner)
- Features
- Support json-api spec
include
query param. (@green-arrow) - Support json-api spec
fields
query param. (@green-arrow) - Add meta info support
- Support json-api spec
- Features:
- Support custom ids in relationships. (@green-arrow)
- Adds error rendering support to Phoenix view.
- Deprecations:
- Use key
serializer
instead ofinclude
when defining relationships.
- Use key
- Dependencies:
- Ecto is now a required (non-optional) dependency.
- Features:
- Adds support for pagination links w/ Scrivener or via opts. (@vysakh0)
- Bugfixes:
- Properly serialize empty relationships. (@dmarkow)
- Bugfixes
- Adds optional Ecto dependency to fix compilation issue.
- Breaking:
- Raises exception if ecto relationship is not pre-fetched.
- Features:
- Adds JaSerializer.ErrorSerializer
- Adds JaSerializer.EctoErrorSerializer
- Pre-defines formats for Ecto built in types.
- Features:
- Add Phoenix integration w/ JaSerializer.PhoenixView.
- Infer type from module name.
- Add
attributes/2
callback w/ default implementation based onattributes/1
macro. - Add JaSerializer.ContentTypeNegotiation plug for setting content type.
- Add JaSerializer.Deserializer plug for param normalization.
- Deprecations:
- Remove
serialize
macro in favor oftype/0
callback.
- Remove
- Bugfix
- Added non-fallback formatters for simple data types to improve out of the box performance.
- Bugfixes:
- Fix issues w/ include chains that resulted in infinite loops.
- Features:
- Add config option for formatting keys as underscored or dasherized.
- Bugfixes:
- Serialize include chains w/o duplicates.
- Initial release.