OASValidation Error Handling

OAS policy has an error message that looks something like this:

 

 

 OASValidation OAS-ValidateFromSwagger with resource "oas://tokenizacion-v1-openapi.yaml": failed with reason: "[ERROR - [Path '/solicitud'] Object has missing required properties (["idSuscripcion"]): []]"

 

 

And it is saved in the variable "OASValidation.OAS-ValidateFromSwagger.fault.cause". How do I go about extracting this error message to create a custom error payload?

Is there a variable I can call that only returns the reason?

1 6 518
6 REPLIES 6

Can you try looking in the variable named fault.reason ? You can also look at fault.name .

Also does the OAS validation does not see to validate the maximum and minimum length for the field? Or have I missed some configuration?

Did fault.reason work?  Did it satisfy your original question? 

No fault.reason was empty, I've extracted the message using custom javascript.

Also need to extract the fields with errors using custom code. It would be useful if the policy gave the field that were causing errors as a list. 

Thanks. That's good feedback. I agree with that.

Hi,

I am also trying to do the exact same thing where i want to output the field names as an array. can you help me with what you did with the JavaScript.