diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f2c042..59eb704 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,6 @@ jobs: strategy: matrix: elixir: - - '1.12.3' - '1.13.4' - '1.14.5' - '1.15.7' @@ -24,10 +23,6 @@ jobs: - '25.3' - '26.2' exclude: - - elixir: '1.12.3' - otp: '25.3' - - elixir: '1.12.3' - otp: '26.2' - elixir: '1.13.4' otp: '26.2' - elixir: '1.14.5' diff --git a/.recode.exs b/.recode.exs new file mode 100644 index 0000000..53078be --- /dev/null +++ b/.recode.exs @@ -0,0 +1,35 @@ +[ + version: "0.7.2", + # Can also be set/reset with `--autocorrect`/`--no-autocorrect`. + autocorrect: true, + # With "--dry" no changes will be written to the files. + # Can also be set/reset with `--dry`/`--no-dry`. + # If dry is true then verbose is also active. + dry: false, + # Enables or disables color in the output. + color: true, + # Can also be set/reset with `--verbose`/`--no-verbose`. + verbose: false, + # Can be overwritten by calling `mix recode "lib/**/*.ex"`. + inputs: ["{mix,.formatter}.exs", "{apps,config,lib,test}/**/*.{ex,exs}"], + formatters: [Recode.CLIFormatter], + tasks: [ + # Tasks could be added by a tuple of the tasks module name and an options + # keyword list. A task can be deactivated by `active: false`. The execution of + # a deactivated task can be forced by calling `mix recode --task ModuleName`. + {Recode.Task.AliasExpansion, []}, + {Recode.Task.AliasOrder, []}, + {Recode.Task.Dbg, [autocorrect: false]}, + {Recode.Task.EnforceLineLength, [active: false]}, + {Recode.Task.FilterCount, []}, + {Recode.Task.IOInspect, [autocorrect: false]}, + {Recode.Task.Nesting, []}, + {Recode.Task.PipeFunOne, []}, + {Recode.Task.SinglePipe, []}, + {Recode.Task.Specs, [exclude: ["test/**/*.{ex,exs}", "mix.exs"], config: [only: :visible]]}, + {Recode.Task.TagFIXME, [exit_code: 2]}, + {Recode.Task.TagTODO, [exit_code: 4]}, + {Recode.Task.TestFileExt, []}, + {Recode.Task.UnusedVariable, [active: false]} + ] +] \ No newline at end of file diff --git a/lib/json_xema.ex b/lib/json_xema.ex index 8f03b55..3d237f6 100644 --- a/lib/json_xema.ex +++ b/lib/json_xema.ex @@ -8,8 +8,11 @@ defmodule JsonXema do import ConvCase alias Jason - alias JsonXema.{SchemaError, SchemaValidator, ValidationError} - alias Xema.{Format, Schema} + alias JsonXema.SchemaError + alias JsonXema.SchemaValidator + alias JsonXema.ValidationError + alias Xema.Format + alias Xema.Schema @type_map %{ "any" => :any, @@ -326,8 +329,7 @@ defmodule JsonXema do when is_list(value), do: {:type, - value - |> Enum.map(fn type -> + Enum.map(value, fn type -> @type_map_reverse |> Map.get(type) end)} diff --git a/lib/json_xema/schema_validator.ex b/lib/json_xema/schema_validator.ex index 7eba185..e035e46 100644 --- a/lib/json_xema/schema_validator.ex +++ b/lib/json_xema/schema_validator.ex @@ -1,5 +1,6 @@ defmodule JsonXema.SchemaValidator do @moduledoc false + # This module contains validators to check schemas against the official # JSON Schemas. diff --git a/mix.exs b/mix.exs index 6b69f89..006e325 100644 --- a/mix.exs +++ b/mix.exs @@ -5,7 +5,7 @@ defmodule JsonXema.MixProject do [ app: :json_xema, version: "0.6.2", - elixir: "~> 1.12", + elixir: "~> 1.13", start_permanent: Mix.env() == :prod, deps: deps(), description: description(), @@ -64,7 +64,8 @@ defmodule JsonXema.MixProject do {:ex_json_schema, "~> 0.9", only: :dev}, {:excoveralls, "~> 0.14", only: :test}, {:httpoison, "~> 2.2", only: :test}, - {:jason, "~> 1.3", only: [:dev, :test]} + {:jason, "~> 1.3", only: [:dev, :test]}, + {:recode, "~> 0.7"} ] end diff --git a/mix.lock b/mix.lock index 6d72464..bf4a33a 100644 --- a/mix.lock +++ b/mix.lock @@ -12,10 +12,12 @@ "dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"}, "earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, + "escape": {:hex, :escape, "0.1.0", "548edab75e6e6938b1e199ef59cb8e504bcfd3bcf83471d4ae9a3c7a7a3c7d45", [:mix], [], "hexpm", "a5d8e92db4677155df54bc1306d401b5233875d570d474201db03cb3047491cd"}, "ex_doc": {:hex, :ex_doc, "0.31.2", "8b06d0a5ac69e1a54df35519c951f1f44a7b7ca9a5bb7a260cd8a174d6322ece", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.1", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "317346c14febaba9ca40fd97b5b5919f7751fb85d399cc8e7e8872049f37e0af"}, "ex_json_schema": {:hex, :ex_json_schema, "0.10.2", "7c4b8c1481fdeb1741e2ce66223976edfb9bccebc8014f6aec35d4efe964fb71", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "37f43be60f8407659d4d0155a7e45e7f406dab1f827051d3d35858a709baf6a6"}, "excoveralls": {:hex, :excoveralls, "0.18.0", "b92497e69465dc51bc37a6422226ee690ab437e4c06877e836f1c18daeb35da9", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "1109bb911f3cb583401760be49c02cbbd16aed66ea9509fc5479335d284da60b"}, "file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"}, + "glob_ex": {:hex, :glob_ex, "0.1.6", "3a311ade50f6b71d638af660edcc844c3ab4eb2a2c816cfebb73a1d521bb2f9d", [:mix], [], "hexpm", "fda1e90e10f6029bd72967fef0c9891d0d14da89ca7163076e6028bfcb2c42fa"}, "hackney": {:hex, :hackney, "1.20.1", "8d97aec62ddddd757d128bfd1df6c5861093419f8f7a4223823537bad5d064e2", [:rebar3], [{:certifi, "~> 2.12.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "fe9094e5f1a2a2c0a7d10918fee36bfec0ec2a979994cff8cfe8058cd9af38e3"}, "httpoison": {:hex, :httpoison, "2.2.1", "87b7ed6d95db0389f7df02779644171d7319d319178f6680438167d7b69b1f3d", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "51364e6d2f429d80e14fe4b5f8e39719cacd03eb3f9a9286e61e216feac2d2df"}, "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, @@ -28,6 +30,9 @@ "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, "parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"}, "ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"}, + "recode": {:hex, :recode, "0.7.2", "aa24873b6eb4c90e635ad1f7e12b8e21575a087698bd6bda6e72a82c1298eca1", [:mix], [{:escape, "~> 0.1", [hex: :escape, repo: "hexpm", optional: false]}, {:glob_ex, "~> 0.1", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:rewrite, "~> 0.9", [hex: :rewrite, repo: "hexpm", optional: false]}], "hexpm", "d70fc60aae3c42781ec845515c1ddd4fe55218ed3fd8fe52267d338044ec7fb8"}, + "rewrite": {:hex, :rewrite, "0.10.0", "5d756b6dc67679e7156ff6055f9654be02dbaeb177aaf1ff6af7ee8da8718248", [:mix], [{:glob_ex, "~> 0.1", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:sourceror, "~> 0.13", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "68d7808cf549e7bf51b0119a8edc14d50970bad479115249030baa580c1d7b50"}, + "sourceror": {:hex, :sourceror, "0.14.1", "c6fb848d55bd34362880da671debc56e77fd722fa13b4dcbeac89a8998fc8b09", [:mix], [], "hexpm", "8b488a219e4c4d7d9ff29d16346fd4a5858085ccdd010e509101e226bbfd8efc"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"}, "statistex": {:hex, :statistex, "1.0.0", "f3dc93f3c0c6c92e5f291704cf62b99b553253d7969e9a5fa713e5481cd858a5", [:mix], [], "hexpm", "ff9d8bee7035028ab4742ff52fc80a2aa35cece833cf5319009b52f1b5a86c27"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"}, diff --git a/test/json_xema/schema_test.exs b/test/json_xema/schema_test.exs index edee3f8..3f883c9 100644 --- a/test/json_xema/schema_test.exs +++ b/test/json_xema/schema_test.exs @@ -17,7 +17,7 @@ defmodule Xema.SchemaTest do end test "returns :ok for empty object", %{draft04: schema} do - assert validate(schema, "{}" |> Jason.decode!()) == :ok + assert validate(schema, Jason.decode!("{}")) == :ok end test "returns an error for a wrong type", %{draft04: schema} do diff --git a/test/support/mix/tasks/gen/test_suite.ex b/test/support/mix/tasks/gen/test_suite.ex index 08cd491..5c57ab1 100644 --- a/test/support/mix/tasks/gen/test_suite.ex +++ b/test/support/mix/tasks/gen/test_suite.ex @@ -50,7 +50,7 @@ defmodule Mix.Tasks.Gen.TestSuite do gen_test_suite(@test_suite_path) false -> - path = File.cwd!() |> Path.join(@test_suite_path) + path = Path.join(File.cwd!(), @test_suite_path) IO.puts( "Error: Can't find JSON Schema Test Suite at #{path}, " <> @@ -88,7 +88,7 @@ defmodule Mix.Tasks.Gen.TestSuite do end defp write_test_file({file_name, code}) do - path = File.cwd!() |> Path.join(file_name) + path = Path.join(File.cwd!(), file_name) path |> Path.dirname() |> File.mkdir_p!() File.write!(path, code) end