-
Notifications
You must be signed in to change notification settings - Fork 205
Description
Hi!
I have a schema that includes another nested schema. Something like this:
defmodule MyApp.CreateUserResponse do
OpenApiSpex.schema(
%{
title: "CreateUserResponse",
type: :object,
properties: %{
user: MyApp.UserSchema.schema()
}
},
derive?: false
)
end
defmodule MyApp.UserSchema do
OpenApiSpex.schema(%{
title: "UserSchema",
allOf: [
SomeOtherSchema1.schema(),
SomeOtherSchema.schema()
]
})
end
When I call something like OpenApiSpex.cast_value(%{user: %{}}, MyApp.CreateUserResponse.schema())
, I get this result:
%MyApp.CreateUserResponse{
user: %{}
}
but I expected to get:
%MyApp.CreateUserResponse{
user: %MyApp.UserSchema{}
}
(All this code is pseudo-code, I modified my real app code to serve as a simple example - please let me know if you need me to create a reproduction repo with code that can actually run)
After some debugging, I found this PR: #455 That PR removed calls of struct(acc, module)
from OpenApiSpex.Cast.AllOf
, but not from OpenApiSpex.Cast.OneOf
and OpenApiSpex.Cast.AnyOf
. I am guessing that might have been a mistake. I was able to modify OpenApiSpex.Cast.AllOf
in a way that made my code work. It's this: master...angelikatyborska:open_api_spex:all-of-struct
If my assumptions and my changes are correct, I can open a PR. I'm opening an issue first according to the contributing guides.