This repository has been archived by the owner on May 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
my.feature
67 lines (64 loc) · 2.7 KB
/
my.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Feature: JSON Schema test
Scenario: Validating JSON Schema from Behat works
Given there is a response equal to:
"""
[
{"id": "a", "name": "a", "created_at": "2010-01-01T12:00:00Z", "created_by": {"id": "a", "username": "a"}, "updated_at": "2010-01-01T12:00:00Z", "updated_by": {"id": "a", "username": "a"}},
{"id": "b", "name": "b", "created_at": "2010-01-01T12:00:00Z", "created_by": {"id": "b", "username": "b"}, "updated_at": "2010-01-01T12:00:00Z", "updated_by": {"id": "b", "username": "b"}}
]
"""
Then the JSON should be valid according to this schema:
"""
{
"definitions": {
"user": {
"type": "object",
"required": ["id", "username"],
"properties": {
"id": {"type": "string", "format": "udid"},
"username": {"type": "string"}
},
"additionalProperties": false
},
"image": {
"type": "object",
"required": ["id", "name"],
"properties": {
"id": {"type": "string", "format": "udid"},
"name": {"type": "string"},
"created_at": {"type": "string", "format": "date-time"},
"created_by": {"$ref": "#/definitions/user"},
"updated_at": {"type": "string", "format": "date-time"},
"updated_by": {"$ref": "#/definitions/user"}
},
"additionalProperties": false
}
},
"type": "array",
"items": {"$ref": "#/definitions/image"},
"minItems": 2,
"maxItems": 2,
"uniqueItems": true,
"additionalItems": false
}
"""
Scenario: Validating JSON Schema from Behat with external $refs works
Given there is a response equal to:
"""
[
{"id": "a", "name": "a", "created_at": "2010-01-01T12:00:00Z", "created_by": {"id": "a", "username": "a"}, "updated_at": "2010-01-01T12:00:00Z", "updated_by": {"id": "a", "username": "a"}},
{"id": "b", "name": "b", "created_at": "2010-01-01T12:00:00Z", "created_by": {"id": "b", "username": "b"}, "updated_at": "2010-01-01T12:00:00Z", "updated_by": {"id": "b", "username": "b"}}
]
"""
Then the JSON should be valid according to this schema:
"""
{
"type": "array",
"id": "features/my.feature",
"items": {"$ref": "schemas/image.json"},
"minItems": 2,
"maxItems": 2,
"uniqueItems": true,
"additionalItems": false
}
"""