@Katalon_Store @katalon_store_suppor
Looking for a Custom Keyword that should return json value based on the jsonpath supplied as parameter.
System.err.println CustomKeywords.‘className.getJsonValue’(‘definitions.address.properties.state.type’)
System.err.println CustomKeywords.‘className.getJsonValue’(‘properties.shipping_address.allOf[1].properties.type.enum[0]’)
@Keyword
public static String getJsonValue(String jsonPath){def jsonValue; def slurper = new groovy.json.JsonSlurper() def result = slurper.parseText('''{
“$schema”: “http://json-schema.org/draft-06/schema#”,“definitions”: {
“address”: {
“type”: “object”,
“properties”: {
“street_address”: { “type”: “string” },
“city”: { “type”: “string” },
“state”: { “type”: “string” }
},
“required”: [“street_address”, “city”, “state”]
}
},“type”: “object”,
“properties”: {
“billing_address”: { “$ref”: “#/definitions/address” },
“shipping_address”: {
“allOf”: [
{ “$ref”: “#/definitions/address” },
{ “properties”:
{ “type”: { “enum”: [ “residential”, “business” ] } },
“required”: [“type”]
}
]
}
}
}
‘’')return result.jsonPath()
}