The root problem here is that User.changeset
doesn’t require any fields, so sending it nil
s won’t cause it to be invalid.
HOWEVER
There are several other layers missing as well:
-
if there were validation errors, the code in the controller’s
create
function will make it fall-through and return{:error, changeset}
. Do you have a fallback controller set up? -
phoenix_swagger
can help with this, but only if it’s correctly configured and enabled:- the name of the parameter
create
expects isuser
notbody
, theparameters
block should startuser(:body, Schema.ref(...)
- the validations need to be wired up, either through the
PhoenixSwagger.Plug.Validate
plug or by directly callingPhoenixSwagger.ConnValidator.validate!
directly.
- the name of the parameter