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 with an error response that lists what was wrong. Set validationDetails to false to reject with a bare error instead, and failureHandler to control where the failure is logged. See distribution/tutorials/xml/50-XSD-Schema-validation.yaml and distribution/tutorials/soap/40-WSDL-Message-Validation.yaml.
 validator:
   wsdl: <url> | schema: <url> | jsonSchema: <url> | schematron: <url>   # choose one
   [ validationDetails: true | false ]   # default: true
   [ 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>
validationDetails: <boolean>
wsdl: <string>
validator:
  '$ref': <string>
  failureHandler: <string>
  jsonSchema: <string>
  schema: <string>
  schemaMappings: {}
  schematron: <string>
  schemaVersion: <string>
  serviceName: <string>
  skipFaults: <boolean>
  validationDetails: <boolean>
  wsdl: <string>

Attributes

NameRequiredDefaultDescriptionExamples
$reffalse-Reference a component defined under components.-
failureHandlerfalseresponseWhere a validation failure is reported in addition to the error response. log writes the details to the log, response does not. What the client receives is controlled by validationDetails.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.-
validationDetailsfalsetrueWhether validation error responses list what was wrong with the message. Set to false to reject with a bare error instead. The details are not hidden by production mode, because the schema a message is validated against is public.false
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