karate : Complex JSON Schema matching
See original GitHub issueFeature: Complex Schema
Background:
* def JSONtobeValidiated =
"""
{
"MyArray": {
"MYinternalDetails": [
{
"SomeField": "dc",
"textfield": [],
"OptionalArray1": [
{
"Users": "Y",
"IsAllowed": "Y"
},
{
"Users": "Y",
"IsAllowed": "Y"
}
]
},
{
"SomeField": "cd",
"textfield": [],
"OptionalArray3": [
{
"Astring": "Lazy",
"AnotherString": "N",
"textfield": []
},
{
"Astring": "FREE",
"AnotherString": "N",
"textfield": [
{
"title": "Name",
"alertMessage": "Please enter valid name."
},
{
"title": "Mobile No",
"alertMessage": "Please enter mobile no."
}
]
}
]
},
{
"SomeField": "gv",
"textfield": [
{
"title": "First",
"alertMessage": "SOme Alert"
}
]
},
{
"SomeField": "rp",
"textfield": []
}
]
}
}"""
* def textfield = { title: '#string', alertMessage: '#string' }
* def OptionalArray1 = { Users: '#string',IsAllowed: '#string' }
* def OptionalArray3 = { Astring: '#string' ,AnotherString: '#string', textfield: '##[]' }
* def MYinternalDetails =
"""
{
SomeField: '#string',
textfield: '##[]',
OptionalArray1: '##[] OptionalArray1'
OptionalArray3: '##[] OptionalArray3'
}
"""
* def ValidJsonSchema = { MyArray: { MYinternalDetails: '#[] MYinternalDetails' } }
Scenario: These matches works
* match JSONtobeValidiated.MyArray.MYinternalDetails == '#[]'
* match JSONtobeValidiated.MyArray.MYinternalDetails == '#[4]'
* match JSONtobeValidiated contains { MyArray: '#ignore' }
* match JSONtobeValidiated contains { MyArray: { MYinternalDetails: '#ignore' } }
Scenario: These match doesn't work
* match JSONtobeValidiated contains { MyArray: { MYinternalDetails: '#[] MYinternalDetails' } }
Scenario: These match doesn't work either
* match JSONtobeValidiated.MyArray.MYinternalDetails == '#[] MYinternalDetails'
Scenario: These match Also doesn't work
* match JSONtobeValidiated == ValidJsonSchema
In Above Example , Schema matching doesn’t seems to be working as expected. Need to match full JSON schema.
Reference: https://stackoverflow.com/questions/49231115/karate-complex-json-schema-matching
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
karate : Complex JSON Schema matching - Stack Overflow
JsonSmartJsonProvider'. How do I get following Working * match JSONtobeValidiated == ValidJsonSchema.
Read more >karate : Complex JSON Schema matching · Issue #346 - GitHub
In Above Example , Schema matching doesn't seems to be working as expected. Need to match full JSON schema. Reference: https://stackoverflow.com ...
Read more >Karate JSON Schema Validation : Karate API Testing Tutorials
In this video, We are going to learn about the Karate JSON Schema Validation. JSON Schema validation for API is important and KARATE...
Read more >APIs Unleashed 05: Schema Validation - Synapse QA
Schema validation can be easily achieved in KarateDSL by using fuzzy matching markers. Karate offers a wide range of markers for validating JSON...
Read more >Karate | Test Automation Made Simple.
URISyntaxException and match not working as expected because of special or ... Embedded expressions are useful when you have complex JSON read from...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Confirming that it worked for many other cases as well. Thanks again!
Hey @ptrthomas It seems to be working. I’ll check more cases and will confirm. Thanks a lot.