-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix cast x-validate when decoded schema (#647)
* Fix cast x-validate when decoded schema * fix credo complain when using apply/3 --------- Co-authored-by: Giorgio Torres <giorgio.torres@hpe.com>
- Loading branch information
Showing
3 changed files
with
48 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
620c57e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @GPrimola, may i know why you dont just put |> convert_value_to_atom_if_present("x-validate") in OpenApiSpex.OpenApi.Decode.prepare_schema/1 ?. I also got the same issue(locally) where my module is a string instead of atom. Added the mentioned line seems to fix it(at least for my case). Would be great if you can enlighten me, thanks!
620c57e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GPrimola the suggestion of @rifkiKargo makes a lot of sense and it has the advantage that the string -> atom module will be performed once when decoding. The only drawback is that
convert_value_to_atom_if_present("x-validate")
won't work with strings like"OpenApiSpec.CastTest.CustomValidator.EvenInt"
it works though with"Elixir.OpenApiSpec.CastTest.CustomValidator.EvenInt"
.