Open Source API Gateway
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. With a WSDL, SOAP header blocks can be validated as well. 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
   [ headers: none | bound | declared ]  # default: none, wsdl only
   [ requireBoundHeaders: true | false ] # default: false, wsdl only
 

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>
headers: none
jsonSchema: <string>
requireBoundHeaders: <boolean>
schema: <string>
schemaMappings: {}
schematron: <string>
schemaVersion: <string>
serviceName: <string>
skipFaults: <boolean>
validationDetails: <boolean>
wsdl: <string>
validator:
  '$ref': <string>
  failureHandler: <string>
  headers: none
  jsonSchema: <string>
  requireBoundHeaders: <boolean>
  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
headersfalsenoneWhich SOAP header blocks are validated. Only valid together with wsdl. none validates no header blocks. bound validates the header blocks the WSDL binding declares via soap:header, for requests those on the input of any of the service's operations, for responses those on the output, and for faults those it declares via soap:headerfault. declared validates in addition every header block whose element is declared globally in the WSDL's schemas, even if the binding does not mention it. Header blocks without such a declaration, e.g. WS-Security, are never validated, even if the binding mentions them.bound
jsonSchemafalse-JSON Schema (URL or file) to validate JSON or YAML message bodies against.schema2000.json
requireBoundHeadersfalsefalseWhether a SOAP message must carry the header blocks the WSDL binding declares via soap:header for its operation: a request those on the operation's input, a response those on its output. A message missing one is rejected. If the body element belongs to several operations, e.g. of two ports, only the header blocks all of them declare are required. Faults need no header blocks. Only valid together with wsdl; works with every value of headers, which controls whether the header blocks are also validated.true
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