---
schema_version: "1"
id: 16da083dd26f1ecb45f9656a3746a891ca51f32e1a5d2fc91a1ec8c66b48b054
title: Configure REST Validator Extension
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/api-manager/latest/rest-validator-extension.md
canonical_url: https://docs.mulesoft.com/api-manager/latest/rest-validator-extension
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 2d7a029c3a5ee9f1ee2c99f9883558ec0419b720398f24edf77eff98c8d9f581
description: MuleSoft Documentation Site
release: 2.x
latest: true
---
---
product: API Manager
version: 2.x
is-latest-version: true
---

# Configure REST Validator Extension

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

The REST validator extension enables you to perform schema validations that use a RAML or OAS
specification against the attributes of a request. Additionally, the extension adds default values
to attributes, if they are already not set in the request.

Unless otherwise noted, this documentation applies only to REST validator extension v2.x. To use the
REST validator extension in your Mule artifact, such as a Mule runtime engine (Mule) application
XML, you must:

1.  [Include the dependency in your pom.xml file](#include-dependency).

2.  [Add the namespace and schema to your Mule artifact](#add-namespace-and-schema).

3.  [Configure the REST validator extension](#configure-rest-validator-extension).

4.  [Use REST validator operations](#use-operations).

## Include Dependencies in Your pom.xml File

You can include the REST validator in your Mule artifact (for example, Mule application XML) by
adding the following snippet in the `<dependencies>` section of your `pom.xml` file:

```XML
<dependency>
		     <groupId>com.mulesoft.anypoint</groupId>
		     <artifactId>mule-rest-validator-extension</artifactId>
		     <version>${restValidatorVersion}</version>
		     <classifier>mule-plugin</classifier>
</dependency>
```

As a best practice, define a Maven property inside the `<properties>` section, with the version of
the REST validator that you want to use:

```XML
<properties>
<restValidatorVersion>2.3.2</restValidatorVersion>
</properties>
```

## Add Namespace and Schema to Your Mule Artifact

To use the REST validator operations in your Mule artifact, include the following namespace and
schema:

```text
xmlns:rest-validator="http://www.mulesoft.org/schema/mule/rest-validator"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/rest-validator http://www.mulesoft.org/schema/mule/rest-validator/current/mule-rest-validator.xsd"
```

## Configure the REST Validator Extension

To configure the REST validator extension, add the following syntax in your Mule artifact:

`<rest-validator:config name="validatorConfig" api="${specFile}"/>`

This snippet contains the required attributes for configuration. You can specify
[additional attributes](#config-reference) to customize the extension. The following example
illustrates how to use attributes deserializing strategies:

```XML
    <rest-validator:config name="configValidator" api="${specFile}" keepApiBaseUri="true">
        <rest-validator:attributes-deserializing-strategies arrayHeaderDelimiter="COMMA"/>
    </rest-validator:config>
```

## Use the REST Validator Operation

After you configure the REST validator, you can start using the validator operation:

**Operation Name**

`validate-request`

**Description**

Validates a request against the specified RAML or OAS specification in the configuration.

**Usage Example**

`<rest-validator:validate-request config-ref="validatorConfig"/>`

**Attributes Description**

The following table lists the attributes and provides their descriptions:

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Required?</th></tr></thead><tbody><tr><td><div><div><p><code>attributes</code></p></div></div></td><td><div><div><p>A DataWeave expression that extracts the attributes to validate. Default value: #[attributes]</p></div></div></td><td><div><div><p>No</p></div></div></td></tr><tr><td><div><div><p><code>payload</code></p></div></div></td><td><div><div><p>A DataWeave expression that extracts the payload to validate. Default value: #[payload]</p></div></div></td><td><div><div><p>No</p></div></div></td></tr><tr><td><div><div><p><code>config-ref</code></p></div></div></td><td><div><div><p>A REST validator configuration.</p></div></div></td><td><div><div><p>Yes</p></div></div></td></tr></tbody></table>

**Output**

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.

**Error Types**

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.

## REST Validator Extension Configuration Reference

The following table describes the attributes that you configure for your validator extension:

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Required?</th></tr></thead><tbody><tr><td><div><div><p><code>name</code></p></div></div></td><td><div><div><p>A unique identifier for your configuration.</p></div></div></td><td><div><div><p>Yes</p></div></div></td></tr><tr><td><div><div><p><code>api</code></p></div></div></td><td><div><div><p>If you are using a version of the REST validator later than 2.0.0, you must use the <code>raml</code> attribute. This includes the location of the specification file against which the requests are to be validated.</p></div></div></td><td><div><div><p>Yes</p></div></div></td></tr><tr><td><div><div><p><code>parser</code></p></div></div></td><td><div><div><p>The parser used to validate the requests:</p></div><div><ul><li><p>AUTO (default)</p><div><p>APIkit attempts to initiate the validation using AMF. If errors occur, the RAML parser performs the validation.</p></div></li><li><p>AMF</p><div><p>The APIkit router uses AMF to read the API and validate incoming requests.</p></div></li><li><p>RAML</p><div><p>The APIkit router uses the RAML parser to read the API and validate incoming requests.</p></div></li></ul></div></div></td><td><div><div><p>No</p></div></div></td></tr><tr><td><div><div><p><code>keepApiBaseUri</code></p></div></div></td><td><div><div><p>Specifies whether you can override the <code>baseUri</code> property in the specification with the URI of the deployed application. If you must use the console operation, set this property to <code>true</code>. The default value is <code>false</code>.</p></div><div><p>If you are using a REST validator version that is later than 2.0.0, use the <code>keepRamlBaseUri</code> attribute.</p></div></div></td><td><div><div><p>No</p></div></div></td></tr><tr><td><div><div><p><code>queryParamsStrictValidation</code></p></div></div></td><td><div><div><p>Validates whether all the query parameters in the request are defined in the specification file. If some of the parameters are not specified, the validation fails. The default value is <code>false</code>.</p></div></div></td><td><div><div><p>No</p></div></div></td></tr><tr><td><div><div><p><code>headersStrictValidation</code></p></div></div></td><td><div><div><p>Validates whether all the required headers defined in the specification are defined in the request. If some of the parameters are not specified, the validation fails. The default value is <code>false</code>.</p></div></div></td><td><div><div><p>No</p></div></div></td></tr><tr><td><div><div><p><code>attributesDeserializingStrategies</code></p></div></div></td><td><div><div><p>Allows parsing of the HTTP headers that contain an array of values that are separated by commas.</p></div></div></td><td><div><div><p>No</p></div></div></td></tr></tbody></table>

## REST Validator and APIkit Compatibility Reference

You can share the REST validator (`pom.xml` dependency) across applications by using a domain.
However, if some of those applications also have a dependency on APIkit, that version of APIkit in
each application must match the one required by the REST validator version that you use in your
domain.

Per the following table of compatibilities, for example, if you use the REST validator v2.2.0 in
your domain, all your applications using APIkit must import the 1.4.2 version:

<table><colgroup><col> <col></colgroup><thead><tr><th>Rest Validator Version</th><th>APIkit REST Module Version</th></tr></thead><tbody><tr><td><div><div><p>2.3.2</p></div></div></td><td><div><div><p>1.11.17</p></div></div></td></tr><tr><td><div><div><p>2.3.1</p></div></div></td><td><div><div><p>1.10.4</p></div></div></td></tr><tr><td><div><div><p>2.3.0</p></div></div></td><td><div><div><p>1.10.0</p></div></div></td></tr><tr><td><div><div><p>2.2.4</p></div></div></td><td><div><div><p>1.9.0</p></div></div></td></tr><tr><td><div><div><p>2.2.3</p></div></div></td><td><div><div><p>1.8.3</p></div></div></td></tr><tr><td><div><div><p>2.2.2</p></div></div></td><td><div><div><p>1.7.0</p></div></div></td></tr><tr><td><div><div><p>2.2.1</p></div></div></td><td><div><div><p>1.5.3</p></div></div></td></tr><tr><td><div><div><p>2.2.0</p></div></div></td><td><div><div><p>1.4.2</p></div></div></td></tr><tr><td><div><div><p>2.1.3</p></div></div></td><td><div><div><p>1.3.17</p></div></div></td></tr><tr><td><div><div><p>2.1.2</p></div></div></td><td><div><div><p>1.3.11</p></div></div></td></tr><tr><td><div><div><p>2.1.1</p></div></div></td><td><div><div><p>1.3.5</p></div></div></td></tr><tr><td><div><div><p>2.1.0</p></div></div></td><td><div><div><p>1.3.5</p></div></div></td></tr><tr><td><div><div><p>2.0.0</p></div></div></td><td><div><div><p>1.2.0</p></div></div></td></tr><tr><td><div><div><p>1.2.0</p></div></div></td><td><div><div><p>1.1.16</p></div></div></td></tr><tr><td><div><div><p>1.1.1</p></div></div></td><td><div><div><p>1.1.1</p></div></div></td></tr></tbody></table>
