forked from karatelabs/karate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.feature
30 lines (28 loc) · 975 Bytes
/
schema.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Feature: json schema validation
# ignore because it does not work offline and slows down the Karate CI build
# one more reason to avoid using JSON schema !
@ignore
Scenario: using a third-party lib and a schema file
* string schema = read('products-schema.json')
* string json = read('products.json')
* def SchemaUtils = Java.type('com.intuit.karate.demo.util.SchemaUtils')
* assert SchemaUtils.isValid(json, schema)
Scenario: using karate's simpler alternative to json-schema
* def warehouseLocation = { latitude: '#number', longitude: '#number' }
* def productStructure =
"""
{
id: '#number',
name: '#string',
price: '#number? _ > 0',
tags: '##[_ > 0] #string',
dimensions: {
length: '#number',
width: '#number',
height: '#number'
},
warehouseLocation: '##(warehouseLocation)'
}
"""
* def json = read('products.json')
* match json == '#[] productStructure'