Assert Valid JSON Schema

Parameters#

NameType/ValueRequired
ExpressionExpressionYes
JsonSchemaJSON schema definitionYes
CommentStringNo
  • Expression: It's the path to the element we want to operate on (e.g. payload.ProductID). See Expression for more details.
  • JsonSchema: The JSON schema definition. This will be used to validate the JSON passed in the expression field. See below for an example.
  • Comment: Add comment messages in the form of a string data type.

JSON Schema Example#

Sample JSON

{
"rectangle":{
"a":15,
"b":5
}
}

Sample Schema

{
"type":"object",
"properties":{
"rectangle":{
"$ref":"#/definitions/Rectangle"
}
},
"definitions":{
"size":{
"type":"number",
"minimum":0
},
"Rectangle":{
"type":"object",
"properties":{
"a":{
"$ref":"#/definitions/size"
},
"b":{
"$ref":"#/definitions/size"
}
}
}
}
}

Code View Example#

<set var="json_success" lang="template"> <![CDATA[{ "rectangle" : { "a" : 15, "b" : 5 } }]]> </set> <assert-valid-jsonschema expression="json_success"> <![CDATA[{ "type" : "object", "properties" : { "rectangle" : {"$ref" : "#/definitions/Rectangle" } }, "definitions" : { "size" : { "type" : "number", "minimum" : 0 }, "Rectangle" : { "type" : "object", "properties" : { "a" : {"$ref" : "#/definitions/size"}, "b" : {"$ref" : "#/definitions/size"} } } } }]]> </assert-valid-jsonschema>
Last updated on by James Tacker