Skip to content

Commit

Permalink
Remove underscore_to_dash Configuration Option
Browse files Browse the repository at this point in the history
  • Loading branch information
jherdman committed Jan 25, 2019
1 parent 201ae1c commit d16670e
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 57 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ Under-the-hood `JSONAPI.EnsureSpec` relies on three individual plugs:
config :jsonapi,
host: "www.someotherhost.com",
scheme: "https",
underscore_to_dash: true, # DEPRECATED
field_transformation: :underscore,
remove_links: false,
json_library: Jason
Expand All @@ -151,9 +150,6 @@ config :jsonapi,
`"favorite-color": blue`). If your API uses dashed fields, set this value to
`:dasherize`. If your API uses underscores (e.g. `"favorite_color": "red"`)
set to `:underscore`.
- **underscore_to_dash**. This is a deprecated option that previously defaulted
to `false`. Please set the appropriate value on the `field_transformation`
configuration option.

## Other

Expand Down
7 changes: 0 additions & 7 deletions lib/jsonapi/deprecation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,4 @@ defmodule JSONAPI.Deprecation do
Macro.Env.stacktrace(__ENV__)
)
end

def warn(:underscore_to_dash) do
IO.warn(
"`:underscore_to_dash` is deprecated. If you want underscored fields, set `:field_transformation` to :underscore. If you want your fields to be dashed, set to :dasherized",
Macro.Env.stacktrace(__ENV__)
)
end
end
15 changes: 1 addition & 14 deletions lib/jsonapi/utils/string.ex
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,6 @@ defmodule JSONAPI.Utils.String do
fun.(value)
end

defp normalized_underscore_to_dash_config(value) when is_boolean(value) do
Deprecation.warn(:underscore_to_dash)

if value do
:dasherize
else
:underscore
end
end

defp normalized_underscore_to_dash_config(value) when is_nil(value), do: value

@doc """
The configured transformation for the API's fields. JSON:API v1.1 recommends
using camlized fields (e.g. "goodDog", versus "good_dog"). However, we don't hold a strong
Expand Down Expand Up @@ -219,8 +207,7 @@ defmodule JSONAPI.Utils.String do
```
"""
def field_transformation do
normalized_underscore_to_dash_config(Application.get_env(:jsonapi, :underscore_to_dash)) ||
field_transformation(Application.get_env(:jsonapi, :field_transformation))
field_transformation(Application.get_env(:jsonapi, :field_transformation))
end

@doc false
Expand Down
32 changes: 0 additions & 32 deletions test/utils/string_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,4 @@ defmodule JSONAPI.Utils.StringTest do
import JSONAPI.Utils.String

doctest JSONAPI.Utils.String

describe "legacy configuration to dasherize fields" do
setup do
Application.put_env(:jsonapi, :underscore_to_dash, true)

on_exit(fn ->
Application.delete_env(:jsonapi, :underscore_to_dash)
end)

{:ok, []}
end

test "#field_transformation/0 returns :dasherize" do
assert field_transformation() == :dasherize
end
end

describe "legacy configuration to underscore fields" do
setup do
Application.put_env(:jsonapi, :underscore_to_dash, false)

on_exit(fn ->
Application.delete_env(:jsonapi, :underscore_to_dash)
end)

{:ok, []}
end

test "#field_transformation/0 returns :underscore" do
assert field_transformation() == :underscore
end
end
end

0 comments on commit d16670e

Please sign in to comment.