Skip to main content
Version: ACE 5

Response Validation

Overview

Response validation allows verifying if data that is assigned to doc result node is according to the schema that has been defined in API (or default schema if schema is not provided in API definition). This is useful when you want to make sure that the result of the flow is the same as defined in the API definition so to ensure the integrity of data for the end client and elimination of errors that might occur if the result wouldn't meet the expectations.

Configuration

  • Response schema - schema definition for the doc node.
    • Requires a schema to be set up first in ACE's schemas section. Afterwards the needed schema (default) has to be selected under Response schema selector. This is the default schema that will be used if dynamic API request associated with the flow has not a schema defined (and is also useful for testing the flow with debugger or test tool).
  • throw as error - If checked (default) and the doc result node does not pass validation, an error will be thrown that can be handled with the Catch step.
  • target path - doc node on which to store the validation result when throw as error unchecked(empty array if successful, error object if failed).

Examples

Example schema
{
"id": "f65597c6-e5de-491c-a42c-57da2ce49b1e",
"title": "testSchema",
"nodeKey": "testSchema",
"properties": {
"name": {
"type": "string"
}
},
"type": "object",
"required": [
"name"
]
Step configuration
stepType: resp-validation
config:
defaultSchema: testSchema
name: Response Validation
description: ""
condition: ""
Example flow configuration with valid input data
    tags:
- general
steps:
- stepType: input-transform
config:
key: result
name: Input Transform
description: ""
condition: ""
- stepType: resp-validation
config:
defaultSchema: testSchema
name: Response Validation
description: ""
condition: ""
sampleData:
name: Tim
Flow result
{
"doc": {
"result": {
"name": "Tim"
}
},
"errors": [],
"performance": {
"steps": [
{
"step": "input-transform",
"executionTime": 0
},
{
"step": "resp-validation",
"executionTime": 12
}
],
"executionTimeOfFlow": 13,
"timeMetric": "ms"
}
}
Example flow configuration with invalid (name not passed) input data
    tags:
- general
steps:
- stepType: input-transform
config:
key: result
name: Input Transform
description: ""
condition: ""
- stepType: resp-validation
config:
defaultSchema: testSchema
name: Response Validation
description: ""
condition: ""
sampleData:
full name: Tim
Flow result
{
"doc": {
"result": {
"full name": "Tim"
}
},
"errors": [
{
"error": "Error in flow 'demoResponseValidationInvalid' : Response Schema validation error",
"validationErrors": [
{
"keyword": "required",
"dataPath": "",
"schemaPath": "#/required",
"params": {
"missingProperty": "name"
},
"message": "should have required property 'name'"
}
]
}
],
"performance": {
"steps": [
{
"step": "input-transform",
"executionTime": 0
},
{
"step": "resp-validation",
"executionTime": 20
}
],
"executionTimeOfFlow": 22,
"timeMetric": "ms"
}
}
Example flow configuration with invalid (name not passed) input data and throw as error unchecked
    tags:
- general
steps:
- stepType: input-transform
config:
key: result
name: Input Transform
description: ""
condition: ""
- stepType: resp-validation
config:
throwAsError: false
defaultSchema: testSchema
targetPath: validations
name: Response Validation
description: ""
condition: ""
sampleData:
full name: Tim
Flow result
{
"doc": {
"result": {
"full name": "Tim"
},
"validations": [
{
"keyword": "required",
"dataPath": "",
"schemaPath": "#/required",
"params": {
"missingProperty": "name"
},
"message": "should have required property 'name'"
}
]
},
"errors": [],
"performance": {
"steps": [
{
"step": "input-transform",
"executionTime": 0
},
{
"step": "resp-validation",
"executionTime": 17
}
],
"executionTimeOfFlow": 19,
"timeMetric": "ms"
}
}