-
Notifications
You must be signed in to change notification settings - Fork 190
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
AllOf cast returns a map, but I expected a struct #590
Comments
Hi @angelikatyborska thanks for reporting this well-written issue. I was also curious about this inconsistency in the past and I thought it was because the code wasn't smart enough to know how to accumulate the properties of the constituent schemas to make them the properties of the parent schema. Turns out it is smart enough (see: https://github.com/open-api-spex/open_api_spex/blob/master/lib/open_api_spex/schema.ex#L337-L339) which explains why the tests pass on your fork. I'm positive about turning this into a PR. This will be a backwards incompatible change though, so we'll have to think whether to bump a major version number, or to make it an opt-in behaviour through configuration. |
Sorry for the delayed response!
I would want to argue that this is a bug fix, maybe a minor change. It is also consistent with how every other cast work, so I think returning a struct from a In version v3.13.0 and below
In v3.13.0 the test passes, in v3.14.0 it fails. I will open a PR now. |
Makes sense, we'll release this as a bugfix. |
Hi!
I have a schema that includes another nested schema. Something like this:
When I call something like
OpenApiSpex.cast_value(%{user: %{}}, MyApp.CreateUserResponse.schema())
, I get this result:but I expected to get:
(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)
fromOpenApiSpex.Cast.AllOf
, but not fromOpenApiSpex.Cast.OneOf
andOpenApiSpex.Cast.AnyOf
. I am guessing that might have been a mistake. I was able to modifyOpenApiSpex.Cast.AllOf
in a way that made my code work. It's this: master...angelikatyborska:open_api_spex:all-of-structIf my assumptions and my changes are correct, I can open a PR. I'm opening an issue first according to the contributing guides.
The text was updated successfully, but these errors were encountered: