DataPower
Gateway

validate - DataPower Gateway (v5 compatible)

Use the validate policy to validate the payload in an assembly flow against a schema.

Gateway support

Note: This page describes the validate policy implementation in the DataPower® Gateway (v5 compatible). If you are using the DataPower API Gateway, see validate - DataPower API Gateway.

For information on the different types of gateway, see API Connect gateway types.

Table 1. Table showing which gateways support this policy, and the corresponding policy version
Gateway Policy version
DataPower Gateway (v5 compatible) 1.0.0

This topic describes how to configure the policy in your OpenAPI source; for details on how to configure the policy in the assembly user interface, see Validate - DataPower Gateway (v5 compatible).

Restriction:
  • The schema that represents the XML can reference only one XML namespace.
  • The schema cannot reference polymorphic XML elements.
  • The validation works on the message.body variable and not any other output/context variable. If the invoke policy contains a configured response object variable, then message.body is not set, and validate is not able to act.
  • If you use the multipleOf keyword in a schema definition for the API then, due to rounding behavior, the specified value must satisfy the following conditions, otherwise the validation fails when the API is called:
    • The value must not be less than 0.000000999999999999999848869.
    • If the value is greater than 1, the amount before the decimal point must not be greater than 999999999999999934463.

About

The validate policy has the following format:
- validate:
  version: version
  title: title
  description: description
  definition: swagger_schema_definition_to_be_used

Apply this policy by adding an assembly extension with an execute field to your OpenAPI definition file.

Properties

The following table describes the policy properties:
Table 2. validate policy properties
Property Required Description Data type
version Yes The policy version number string
title No A title for the policy. string
description No A policy description. string
definition Yes The schema to be used to validate the payload.
Valid values:
  • request: Select this value to validate the request input against the schema definition that is specified in the Type field for the request parameter for this operation. For information about how to create a request parameter, see Configuring an operation.
  • response: Select this value to validate the response to be returned to the client application, against the schema definition that is specified in the Schema field for the response parameter for this operation. For information about how to create a response parameter, see Configuring an operation.
  • The name of a schema definition, in the following format:
     #/definitions/schema_name
    The schema must be defined in the definitions: section of your OpenAPI file.
string

You can also apply an validate policy by using the API Designer assembly editor to add a built-in policy to the API. For more information, see Validate - DataPower Gateway (v5 compatible) in the built-in policies section.

Example 1

validate:
  version: 1.0.0
  title: validate the response
  definition: #/definitions/RouteOutput