It's very common to see a pattern like this in a Rails controller (I'm using jsonapi-utils methods in the code):
if model.save
jsonapi_render json: model
else
jsonapi_render json: model.errors # doesn't work
end
Seems like this gem should expose a helper for this type of failed POST request, e.g. jsonapi_render_unprocessable model.errors which would serve 422 response with a response body listing the reasons why the model couldn't be written to the DB.
Not sure what JSONAPI spec says about this, however...