Skip to content

Commit

Permalink
feat: add json specification (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
sno2 authored Jun 5, 2021
1 parent d1fb9cc commit c3a9be4
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "./index.spec.json",
"types": {
"feat": {
"description": "A new feature",
Expand Down
9 changes: 9 additions & 0 deletions index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var jsonschema = require("jsonschema");
var fs = require("fs");

var data = fs.readFileSync("./index.json");
var schema = fs.readFileSync("./index.spec.json");

jsonschema.validate(JSON.parse(data), JSON.parse(schema), {
throwAll: true,
});
27 changes: 27 additions & 0 deletions index.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Conventional Commit Types Data Schema",
"additionalProperties": true,
"definitions": {
"commitType": {
"type": "object",
"additionalProperties": false,
"properties": {
"description": {
"type": "string"
},
"title": {
"type": "string"
}
},
"required": ["description", "title"]
}
},
"properties": {
"types": {
"type": "object",
"additionalProperties": { "$ref": "#/definitions/commitType" }
}
},
"required": ["types"]
}
32 changes: 32 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "List of conventional commit types.",
"main": "index.json",
"scripts": {
"test": "json -f index.json"
"test": "node index.spec"
},
"keywords": [],
"author": "Anders D. Johnson",
Expand All @@ -14,6 +14,6 @@
"url": "https://github.com/commitizen/conventional-commit-types.git"
},
"devDependencies": {
"json": "^9.0.4"
"jsonschema": "^1.4.0"
}
}

0 comments on commit c3a9be4

Please sign in to comment.