Skip to content

Commit

Permalink
improvement: use struct spec to avoid double % in struct inspect
Browse files Browse the repository at this point in the history
currently, inspecting an `OpenApiSpex.Schema` looks like this:

`%OpenApiSpex.Schema%{type: :object}`

with the new change, it looks like this:

`%OpenApiSpex.Schema{type: :object}`

which allows copy/pasting the struct
  • Loading branch information
zachdaniel committed Jun 28, 2024
1 parent e8a3538 commit 5ab8aa7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/open_api_spex/inspect/for_schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ defimpl Inspect, for: OpenApiSpex.Schema do
end)
|> Map.new()

concat(["%OpenApiSpex.Schema", to_doc(map, opts)])
infos =
for %{field: field} = info <- OpenApiSpex.Schema.__info__(:struct),
Map.has_key?(map, field),
field not in [:__struct__, :__exception__],
do: info

Inspect.Map.inspect(map, Macro.inspect_atom(:literal, OpenApiSpex.Schema), infos, opts)

Check warning on line 20 in lib/open_api_spex/inspect/for_schema.ex

View workflow job for this annotation

GitHub Actions / Test (OTP 25 / Elixir 1.13)

Macro.inspect_atom/2 is undefined or private

Check warning on line 20 in lib/open_api_spex/inspect/for_schema.ex

View workflow job for this annotation

GitHub Actions / Lint (OTP 25 / Elixir 1.13)

Macro.inspect_atom/2 is undefined or private
end
end

0 comments on commit 5ab8aa7

Please sign in to comment.