Skip to content

Commit 7349ef9

Browse files
committed
Add tests validating example json files
1 parent 36179c4 commit 7349ef9

26 files changed

+481
-439
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Jekyll products
22
.sass-cache/
33
_site/
4+
node_modules/

.travis.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
language: ruby
22
dist: trusty
33
sudo: false
4+
node_js:
5+
- node
6+
before_script:
7+
- npm install ajv-cli
8+
- echo node ./node_modules/ajv-cli/index.js \"\$\@\" >> ajv
9+
- chmod +x ajv
10+
- PATH=".:$PATH"
411
script:
512
- bundle exec jekyll build
13+
- ajv test -s schema -d "_includes/person.json" --valid
14+
- ajv test -s schema -d "_includes/example1/schema*.json" --valid
15+
- ajv test -s _includes/example1/schema1.json -d _includes/example1/instance.json --valid
16+
- ajv test -s _includes/example1/schema2.json -d _includes/example1/instance.json --valid
17+
- ajv test -s _includes/example1/schema3.json -d _includes/example1/instance.json --valid
18+
- ajv test -s _includes/example1/schema4.json -d _includes/example1/instance.json --valid
19+
- ajv test -s _includes/example1/schema5.json -d _includes/example1/instance.json --valid
20+
- ajv test -s schema -d _includes/example1/set_schema.json --valid
21+
- ajv test -s _includes/example1/set_schema.json -d _includes/example1/set_instance.json -r geo --valid
22+
- ajv test -s schema -d "_includes/example2/schema*.json" --valid
23+
- ajv test -s schema -d "_includes/example2/entry_schema*.json" --valid
24+
- ajv test -s schema -d "_includes/example2/storage_schema*.json" --valid
25+
- ajv test -s _includes/example2/schema1.json -d _includes/example2/instance.json --valid
26+
- ajv test -s _includes/example2/schema2.json -d _includes/example2/instance.json -r _includes/example2/entry_schema3.json --valid
27+
- ajv test -s schema -d address -d calendar -d card -d geo --valid

_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ header_pages:
3434
exclude:
3535
- README.md
3636
- Gemfile
37+
- node_modules
3738

3839
gems:
3940
- jekyll-relative-links

_includes/example1/instance.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"id": 1,
3+
"name": "A green door",
4+
"price": 12.50,
5+
"tags": ["home", "green"]
6+
}

_includes/example1/schema1.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"title": "Product",
4+
"description": "A product from Acme's catalog",
5+
"type": "object"
6+
}

_includes/example1/schema2.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"title": "Product",
4+
"description": "A product from Acme's catalog",
5+
"type": "object",
6+
"properties": {
7+
"id": {
8+
"description": "The unique identifier for a product",
9+
"type": "integer"
10+
}
11+
},
12+
"required": ["id"]
13+
}

_includes/example1/schema3.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"title": "Product",
4+
"description": "A product from Acme's catalog",
5+
"type": "object",
6+
"properties": {
7+
"id": {
8+
"description": "The unique identifier for a product",
9+
"type": "integer"
10+
},
11+
"name": {
12+
"description": "Name of the product",
13+
"type": "string"
14+
}
15+
},
16+
"required": ["id", "name"]
17+
}

_includes/example1/schema4.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"title": "Product",
4+
"description": "A product from Acme's catalog",
5+
"type": "object",
6+
"properties": {
7+
"id": {
8+
"description": "The unique identifier for a product",
9+
"type": "integer"
10+
},
11+
"name": {
12+
"description": "Name of the product",
13+
"type": "string"
14+
},
15+
"price": {
16+
"type": "number",
17+
"minimum": 0,
18+
"exclusiveMinimum": true
19+
}
20+
},
21+
"required": ["id", "name", "price"]
22+
}

_includes/example1/schema5.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"title": "Product",
4+
"description": "A product from Acme's catalog",
5+
"type": "object",
6+
"properties": {
7+
"id": {
8+
"description": "The unique identifier for a product",
9+
"type": "integer"
10+
},
11+
"name": {
12+
"description": "Name of the product",
13+
"type": "string"
14+
},
15+
"price": {
16+
"type": "number",
17+
"minimum": 0,
18+
"exclusiveMinimum": true
19+
},
20+
"tags": {
21+
"type": "array",
22+
"items": {
23+
"type": "string"
24+
},
25+
"minItems": 1,
26+
"uniqueItems": true
27+
}
28+
},
29+
"required": ["id", "name", "price"]
30+
}

_includes/example1/set_instance.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[
2+
{
3+
"id": 2,
4+
"name": "An ice sculpture",
5+
"price": 12.50,
6+
"tags": ["cold", "ice"],
7+
"dimensions": {
8+
"length": 7.0,
9+
"width": 12.0,
10+
"height": 9.5
11+
},
12+
"warehouseLocation": {
13+
"latitude": -78.75,
14+
"longitude": 20.4
15+
}
16+
},
17+
{
18+
"id": 3,
19+
"name": "A blue mouse",
20+
"price": 25.50,
21+
"dimensions": {
22+
"length": 3.1,
23+
"width": 1.0,
24+
"height": 1.0
25+
},
26+
"warehouseLocation": {
27+
"latitude": 54.4,
28+
"longitude": -32.7
29+
}
30+
}
31+
]

0 commit comments

Comments
 (0)