After you configure the REST validator, you can start using the validator operation:
Validates a request against the specified RAML or OAS specification in the configuration.
<rest-validator:validate-request config-ref="validatorConfig"/>
The following table lists the attributes and provides their descriptions:
| Attribute |
Description |
Required? |
|
A DataWeave expression that extracts the attributes to validate. Default value: #[attributes]
|
|
|
A DataWeave expression that extracts the payload to validate. Default value: #[payload]
|
|
|
A REST validator configuration.
|
|
If the request does not violate the defined schema, the validation ends successfully and the result of the operation does not modify the HTTP request attributes. Conversely, default values are added to the schema validation and the output includes the original and new HTTP request attributes.
The validate-request operation might raise different errors if a problem occurs when retrieving a file or if the validation does not end successfully:
-
REST-VALIDATOR:BAD_REQUEST
Error raised when some of the attributes do not match with the schema. The attributes that are considered during the validation include:
-
Form parameters
-
Headers
-
Query parameters
-
URI parameters
-
REST-VALIDATOR:METHOD_NOT_ALLOWED
Error raised when the schema does not support a particular method for the required resource.
-
REST-VALIDATOR:RESOURCE_NOT_FOUND
Error raised when the root schema or some related file cannot be retrieved.