Skip to content

Commit

Permalink
Don't set x-struct when :struct? is false
Browse files Browse the repository at this point in the history
  • Loading branch information
moxley committed Dec 13, 2020
1 parent 686dce7 commit 70f3bf1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/open_api_spex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ defmodule OpenApiSpex do
quote do
@compile {:report_warnings, false}
@behaviour OpenApiSpex.Schema
@schema OpenApiSpex.build_schema(unquote(body), module: __MODULE__)
@schema OpenApiSpex.build_schema(
unquote(body),
Keyword.merge([module: __MODULE__], unquote(opts))
)

def schema, do: @schema

Expand Down Expand Up @@ -245,7 +248,11 @@ defmodule OpenApiSpex do
body
|> Map.delete(:__struct__)
|> update_in([:"x-struct"], fn struct_module ->
struct_module || module
if Keyword.get(opts, :struct?, false) do
struct_module || module
else
struct_module
end
end)
|> update_in([:title], fn title ->
title || title_from_module(module)
Expand Down

0 comments on commit 70f3bf1

Please sign in to comment.