SchemaValidationTrial.Json =
{
"accessedByMember": false,
"account": {
"displayName": "4ed395e7-97a7-42fc-a909-d15804136c5e"
},
"line": {
"PIM": {
"bicycleExists": true,
"totalDiscount": {
"amount": "1.42"
},
"bicycles": [
{
"status_Ext": "Added"
},
{
"status_Ext": "Updated"
}
]
}
}
}
@id=ValidateMainSchema
Scenario: Validate the Main Schema
* def reqPayloadFile = sharedPath + 'SchemaValidationTrial.json'
* def reqPayload = read(reqPayloadFile)
* def commonSchemaRef=karate.call(sharedPath+'PPPPartnerEventsActions.feature'+'@validateCommonSchema')
* def accountMainSchema = commonSchemaRef.accountSchema
* def PIMMainSchema = commonSchemaRef.PIMSchema
* def MainSchema =
"""
{
"accessedByMember": '#boolean',
"account": '##(accountMainSchema)',
"line": '##(PIMMainSchema)'
}
"""
* match reqPayload == '##(MainSchema)'
@validateCommonSchema
Scenario: validate the Common Schema
* def accountSchema =
"""
{
"displayName":'#string'
}
"""
* def bicyclesSchema =
"""
{
"status_Ext": '#string'
}
"""
* def PIMSchema =
"""
{
"PIM": {
"bicycleExists": '#boolean',
"totalDiscount":{
"amount": '#string'
},
"bicycles": '#[] ##(bicyclesSchema)'
}
}
"""
Requirement:
- The Sub schema should be reusable. Example:
PIM{}
should be reusable in multipleScenario
.
When I run first scenario, this called second scenario. I am getting an error "bicyclesSchema is not define"
, but it is defined in second scenario .please check the Error logs screenshot.
Question: How to resolve this issue when the sub-schema defined variable called by another scenario?