-
Notifications
You must be signed in to change notification settings - Fork 15
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
Open api spex object refactor #2780
Conversation
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.
Nice!
I'm not 100% what we "solve" with this exactly, except one decode
function, as everything else remains untouched in essence
It's a pity that there is not any way to set struct?
default value as false
somehow.
Otherwise, we need to remember always to add the value, and it looks like something we can forget pretty easily. I hope we don't 😅
Maybe we could have our own macro for that
@@ -116,7 +112,4 @@ defmodule TrentoWeb.V1.SUMACredentialsController do | |||
end | |||
|
|||
def get_policy_resource(_), do: Trento.SoftwareUpdates.Settings | |||
|
|||
defp decode_body(body) when is_struct(body), do: Map.from_struct(body) |
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.
Is this the unique real place where we are forced to decode to map?
As far as I see, we can get the remaining fields exactly the same way without the struct?
field
2fb1833
to
732d355
Compare
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.
❤️
e8cf6de
to
4e198f4
Compare
Description
This PR change the use of OpenApiSpex macro, to include
struct?:false
as parameter.This allow us to better pattern match into the controller action functions and also allow us to not decode the body_params into a map, and pass them directly to ecto, as phoenix convention.
The validation of the paramters and openapi definition remains untouched.
Other small controller fixes added.
Tested.