Skip to content

fix: add leading slash to JSON pointer in schema errors #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ash_json_api/error/schema_errors.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defmodule AshJsonApi.Error.SchemaErrors do
defp format_path_name(:parameter, []), do: ""

defp format_path_name(:json_pointer, path) do
Enum.join(path, "/")
"/" <> Enum.join(path, "/")
end

defp error_messages(reason, path, acc \\ [])
Expand Down
1 change: 1 addition & 0 deletions test/acceptance/patch_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ defmodule Test.Acceptance.PatchTest do

assert %{"errors" => [error]} = response.resp_body
assert error["code"] == "invalid_body"
assert error["source"] == %{"pointer" => "/data/attributes/hidden"}

assert error["detail"] ==
"Expected only defined properties, got key [\"data\", \"attributes\", \"hidden\"]."
Expand Down
2 changes: 2 additions & 0 deletions test/acceptance/post_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ defmodule Test.Acceptance.PostTest do
# response is a Plug.
assert %{"errors" => [error]} = response.resp_body
assert error["code"] == "invalid_body"
assert error["source"] == %{"pointer" => "/data/attributes/email"}

assert error["detail"] ==
"Expected only defined properties, got key [\"data\", \"attributes\", \"email\"]."
Expand Down Expand Up @@ -486,6 +487,7 @@ defmodule Test.Acceptance.PostTest do
# response is a Plug.
assert %{"errors" => [error]} = response.resp_body
assert error["code"] == "invalid_body"
assert error["source"] == %{"pointer" => "/data/attributes/email"}

assert error["detail"] ==
"Expected only defined properties, got key [\"data\", \"attributes\", \"email\"]."
Expand Down