DataPower Gateway only

validate

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

Restriction:
  • The schema that represents the XML can reference only one XML namespace.
  • The schema cannot reference polymorphic XML elements.
  • The OpenAPI discriminator field is not supported by the validate policy.
  • The validate policy can be used only with the DataPower® Gateway, not with the Micro Gateway.
The validate policy has the following format:
- validate:
  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 (Swagger 2.0) definition file.

The following table describes the policy properties:
Table 1. validate policy properties
Property Required Description Data type
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 (Swagger 2.0) 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 (validate) in the built-in policies section.

Example 1

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