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
I am using json view with Custom Mime Types. I have minimal and export mime types.
Additionally, a controller has an action which validates an object.
def validate(Pet pet) {
pet.validate()
respond pet
}
If I send an object with invalid data to "$baseUrl/pet/validate", the response will be 422 (the expected response). But if I send the same object to "$baseUrl/pet/validate?format=minimal", the response will be 404.
I created this tests to reproduce the issue:
void "test validate a property without format"() {
when:
def resp = restBuilder().post("$baseUrl/pet/validate") {
json ([name: 'invalid name'])
}
then:
resp.status == 422
resp.json.errors[0].field == "name"
}
void "test validate a property with specific format"() {
when:
def resp = restBuilder().post("$baseUrl/pet/validate?format=minimal") {
json ([name: 'invalid name'])
}
then:
resp.status == 422 // <-- this fail, the value is 404
resp.json.errors[0].field == "name"
}
I am using json view with Custom Mime Types. I have minimal and export mime types.
Additionally, a controller has an action which validates an object.
If I send an object with invalid data to
"$baseUrl/pet/validate"
, the response will be 422 (the expected response). But if I send the same object to"$baseUrl/pet/validate?format=minimal"
, the response will be 404.I created this tests to reproduce the issue:
Apparently, doesn't exist any error render registered to minimal mime type. So, https://github.com/grails/grails-core/blob/a16b4a4274025cc337b3b7dc4463bcad464f2ab9/grails-plugin-rest/src/main/groovy/grails/artefact/controller/RestResponder.groovy#L170 is executed. The same happens with export format.
Here the link to the sample app: https://github.com/AmaliaMV/gsonView-errorWithFormat
The text was updated successfully, but these errors were encountered: