Skip to content

Commit c3a9be4

Browse files
authoredJun 5, 2021
feat: add json specification (#21)
1 parent d1fb9cc commit c3a9be4

File tree

5 files changed

+71
-2
lines changed

5 files changed

+71
-2
lines changed
 

‎index.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "./index.spec.json",
23
"types": {
34
"feat": {
45
"description": "A new feature",

‎index.spec.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var jsonschema = require("jsonschema");
2+
var fs = require("fs");
3+
4+
var data = fs.readFileSync("./index.json");
5+
var schema = fs.readFileSync("./index.spec.json");
6+
7+
jsonschema.validate(JSON.parse(data), JSON.parse(schema), {
8+
throwAll: true,
9+
});

‎index.spec.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Conventional Commit Types Data Schema",
4+
"additionalProperties": true,
5+
"definitions": {
6+
"commitType": {
7+
"type": "object",
8+
"additionalProperties": false,
9+
"properties": {
10+
"description": {
11+
"type": "string"
12+
},
13+
"title": {
14+
"type": "string"
15+
}
16+
},
17+
"required": ["description", "title"]
18+
}
19+
},
20+
"properties": {
21+
"types": {
22+
"type": "object",
23+
"additionalProperties": { "$ref": "#/definitions/commitType" }
24+
}
25+
},
26+
"required": ["types"]
27+
}

‎package-lock.json

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "List of conventional commit types.",
55
"main": "index.json",
66
"scripts": {
7-
"test": "json -f index.json"
7+
"test": "node index.spec"
88
},
99
"keywords": [],
1010
"author": "Anders D. Johnson",
@@ -14,6 +14,6 @@
1414
"url": "https://github.com/commitizen/conventional-commit-types.git"
1515
},
1616
"devDependencies": {
17-
"json": "^9.0.4"
17+
"jsonschema": "^1.4.0"
1818
}
1919
}

0 commit comments

Comments
 (0)
Please sign in to comment.