3. Security and Validation

validator

Version

Validates request and response message bodies against a schema. The schema type is selected by the attribute you set: wsdl for SOAP messages, schema for XML against an XSD, jsonSchema for JSON or YAML, or schematron. Exactly one of them must be configured; inside a soapProxy the WSDL is taken from the proxy automatically. An empty body passes; an invalid body is rejected, either with a detailed error response or a generic one plus a log entry, depending on failureHandler. See the examples under examples/validation, examples/xml/xml-validation, and examples/web-services-soap/soap-wsdl-validation.
 validator:
   wsdl: <url> | schema: <url> | jsonSchema: <url> | schematron: <url>   # choose one
   [ failureHandler: response | log ]   # default: response
 

Example Configuration

api:
port: 2000
flow:
- validator:
jsonSchema: schema.json
target:
url: https://api.predic8.de
api:
   port: 2000
   flow:
     - validator:
         jsonSchema: schema.json
   target:
     url: https://api.predic8.de

Syntax

validator:
'$ref': <string>
failureHandler: <string>
jsonSchema: <string>
schema: <string>
schemaMappings: {}
schematron: <string>
schemaVersion: <string>
serviceName: <string>
skipFaults: <boolean>
wsdl: <string>
validator:
  '$ref': <string>
  failureHandler: <string>
  jsonSchema: <string>
  schema: <string>
  schemaMappings: {}
  schematron: <string>
  schemaVersion: <string>
  serviceName: <string>
  skipFaults: <boolean>
  wsdl: <string>

Attributes

NameRequiredDefaultDescriptionExamples
$reffalse-Reference a component defined under components.-
failureHandlerfalseresponseHow a validation failure is reported. response returns a detailed error to the client; log returns a generic error and writes the details to the log.log
jsonSchemafalse-JSON Schema (URL or file) to validate JSON or YAML message bodies against.schema2000.json
schemafalse-XSD schema (URL or file) to validate XML message bodies against.http://www.predic8.com/schemas/order.xsd
schematronfalse-Schematron schema (URL or file) to validate XML message bodies against.car-schematron.xml
schemaVersionfalse2020-12JSON Schema draft to validate against. Applies only to jsonSchema.04, 05, 06, 07, 2019-09, 2020-12
serviceNamefalse-Name of a service element in the WSDL. When set, messages are validated against that service only.ArticleService
skipFaultsfalsefalseWhether to skip validation of SOAP fault messages. Only valid together with wsdl.-
wsdlfalse-WSDL (URL or file) to validate SOAP request and response messages against.http://predic8.com/material/ArticleService?wsdl

Child Structure

ElementCardinalityDescription
schemaMappings0..1

Can be used in