I am trying below in Karate.
I have a json schema ( for response validation) in .json file. There are few REGEXs that are common in many schemas. I want to extract them into one common file as key value pairs and use it across other schemas. Is it possible? if so, how can I do that? Is templating allowed in json schema?
Example:
Sample Json Schema File ( sample-response.json):
{
"response": {
"name": "#string",
"amount": "#regex ^(-?)([0]|[1-9][0-9]{0,15})[.][0-9]{2}$"
}
}
Feature File
Feature: Example feature
Background:
* def sampleResponse = read('./sample-response.json');
Scenario: Example scenario
When url 'https://someurl.com'
And method get
Then status 200
And match response == sampleResponse
What would I like to Do?
I would like to store the amount regex in json file as a reusable variable and use templating in json file to replace it. Is it possible?
{
"response": {
"name": "#string",
"amount": "{{get regex from this template}}"
}
}