You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off, thanks a lot for all the work to put this library together!
I've had a great time using it to document some Elixir APIs.
Recently I've been trying to invest some effort in building better schemas and let OpenApiSpex.Plug.Cast cast them into structs. However I ran into a few issues when trying to use polymorphic schemas.
Having gone through the code a bit, it seems that casting into polymorphic schemas is simply not implemented... 😢
Is that the case or / and I doing something wrong?
If it hasn't been implemented yet, is there anything I can do to help?
Any pointers towards what would need to be done?
Do you have any idea how much effort you think it would take this implemented?
As a first step, only supporting polymorphic schemas that use discriminators might make this easier to implement. What do you think?
There is some complexity in avoiding infinite recursion between parent and child schemas, but should be possible. It would be great if you could take a look.
Particularly if you can come up with a way to conveniently declare the struct fields for a schema that uses allOf with references to other schemas.
Hi there 👋
First off, thanks a lot for all the work to put this library together!
I've had a great time using it to document some Elixir APIs.
Recently I've been trying to invest some effort in building better schemas and let
OpenApiSpex.Plug.Cast
cast them into structs. However I ran into a few issues when trying to use polymorphic schemas.For instance if I have the following schemas:
I would expect posting the following JSON:
To be cast into the following struct when using the
OpenApiSpex.Plug.Cast
plug:However, in my tests, it ends up being cast into:
Having gone through the code a bit, it seems that casting into polymorphic schemas is simply not implemented... 😢
Is that the case or / and I doing something wrong?
If it hasn't been implemented yet, is there anything I can do to help?
Any pointers towards what would need to be done?
Do you have any idea how much effort you think it would take this implemented?
As a first step, only supporting polymorphic schemas that use discriminators might make this easier to implement. What do you think?
The full code for my test from which the above snippets are taken from can be found here: maxmellen/open_api_spex_one_of_demo
Running
mix test
will showcase the issue I am talking about here:I also have a version of the schemas using a
Pet
parent schema that can be found on theall-of
branch:This schema results in the same behavior.
Thanks in advance for your help
Best ✨
The text was updated successfully, but these errors were encountered: