Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add JSON schema validation #797

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
86da2d9
Added JSON schema validation
ritesh-pandey Nov 6, 2020
d50f4e6
Moved ajv from dependency to devDependency
ritesh-pandey Nov 7, 2020
23f6888
Added Chai plug-in for running tests
ritesh-pandey Nov 7, 2020
2b4426c
Removed chai plug-in for schema validation
ritesh-pandey Nov 8, 2020
7ae574e
feat: expose dataset on website (#795)
ARKEOLOGIST Nov 10, 2020
12f69af
fix(swag): update broken image links (#835)
aslafy-z Jul 26, 2021
4a247fe
chore(deps): bump path-parse from 1.0.6 to 1.0.7 (#838)
dependabot[bot] Aug 24, 2021
5d2a40a
fix(swag): set Img Bot opportunity as expired (#837)
Nikhil27b Aug 24, 2021
e333076
fix(swag): update openebs image (#844)
aslafy-z Aug 24, 2021
8c3556f
feat: replace renovate with dependabot (#841)
aslafy-z Aug 24, 2021
7651c9c
chore(deps): bump actions/setup-node from 1 to 2.4.0 (#845)
dependabot[bot] Aug 24, 2021
9f7f3ae
chore(deps): bump actions/cache from 1 to 2.1.6 (#846)
dependabot[bot] Aug 24, 2021
4db726e
chore(deps-dev): bump postcss from 8.1.6 to 8.3.6 (#847)
dependabot[bot] Aug 24, 2021
f48d027
chore(deps): bump browserslist from 4.14.5 to 4.16.8 (#848)
dependabot[bot] Aug 24, 2021
67862a8
chore(deps): bump hosted-git-info from 2.7.1 to 2.8.9 (#820)
dependabot[bot] Aug 24, 2021
1e1e743
chore(deps): bump lodash from 4.17.19 to 4.17.21 (#819)
dependabot[bot] Aug 24, 2021
7f0773e
chore(deps): bump ini from 1.3.5 to 1.3.8 (#849)
dependabot[bot] Aug 24, 2021
6308d9f
chore(deps): bump y18n from 3.2.1 to 3.2.2 (#814)
dependabot[bot] Aug 24, 2021
e8e7948
chore(deps): bump pug-code-gen from 2.0.1 to 2.0.3 (#813)
dependabot[bot] Aug 24, 2021
eef510e
chore(deps-dev): bump chai from 4.2.0 to 4.3.4 (#851)
dependabot[bot] Aug 24, 2021
c860f07
chore(deps-dev): bump mocha from 8.2.1 to 9.1.0 (#850)
dependabot[bot] Aug 24, 2021
e5855b0
chore(deps-dev): bump sharp from 0.26.2 to 0.29.0 (#852)
dependabot[bot] Aug 24, 2021
dbac040
chore(deps-dev): bump @babel/core from 7.12.3 to 7.15.0 (#853)
dependabot[bot] Aug 24, 2021
f0b2f31
fix: update tag selector background color (#854)
aslafy-z Aug 24, 2021
c41d68c
feat: mark opportunities as done (#438)
amhislop Aug 24, 2021
e281582
Update test/functional/data.spec.js
aslafy-z Aug 24, 2021
2f31701
Update test/functional/data.spec.js
aslafy-z Aug 24, 2021
344b453
Update schema.json
aslafy-z Aug 24, 2021
d2f6503
Update data.spec.js
aslafy-z Aug 24, 2021
d117814
Added JSON schema validation
ritesh-pandey Nov 6, 2020
341af8a
Moved ajv from dependency to devDependency
ritesh-pandey Nov 7, 2020
d3c5c1e
Added Chai plug-in for running tests
ritesh-pandey Nov 7, 2020
db1c678
Removed chai plug-in for schema validation
ritesh-pandey Nov 8, 2020
6ff5f8c
Update test/functional/data.spec.js
aslafy-z Aug 24, 2021
7075125
Update test/functional/data.spec.js
aslafy-z Aug 24, 2021
4d2fcf5
Update schema.json
aslafy-z Aug 24, 2021
4695e5f
Update data.spec.js
aslafy-z Aug 24, 2021
4adfcf0
Merge branch 'JSON-schema-validation-745' of github.com:ritesh-pandey…
ritesh-pandey Aug 26, 2021
6b93da5
Updated package-lock.json
ritesh-pandey Aug 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"devDependencies": {
"@babel/core": "7.12.3",
"@babel/preset-env": "7.12.1",
"ajv": "^6.12.6",
"autoprefixer": "10.0.1",
"chai": "4.2.0",
"chalk": "4.1.0",
Expand Down
108 changes: 108 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "http://devswag.io/schema.json",
"type": "array",
"title": "The root schema",
"description": "The root schema comprises the entire JSON document.",
"default": [],
"examples": [],
"additionalItems": true,
"items": {
"$id": "#/items",
"anyOf": [
{
"$id": "#/items/anyOf/0",
"type": "object",
"title": "The first anyOf schema",
"description": "An explanation about the purpose of this instance.",
"default": {},
"examples": [],
"required": [
"name",
"difficulty",
"description",
"reference",
"image",
"dateAdded",
"tags"
],
"properties": {
"name": {
"$id": "#/items/anyOf/0/properties/name",
"type": "string",
"title": "The name schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": []
},
"difficulty": {
"$id": "#/items/anyOf/0/properties/difficulty",
"type": "string",
"title": "The difficulty schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [],
"pattern": "easy|medium|hard"
},
"description": {
"$id": "#/items/anyOf/0/properties/description",
"type": "string",
"title": "The description schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": []
},
"reference": {
"$id": "#/items/anyOf/0/properties/reference",
"type": "string",
"title": "The reference schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": []
aslafy-z marked this conversation as resolved.
Show resolved Hide resolved
},
"image": {
"$id": "#/items/anyOf/0/properties/image",
"type": "string",
"title": "The image schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [],
"format": "uri"
},
"dateAdded": {
"$id": "#/items/anyOf/0/properties/dateAdded",
"type": "string",
"title": "The dateAdded schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [],
"format": "date-time"
},
"tags": {
"$id": "#/items/anyOf/0/properties/tags",
"type": "array",
"title": "The tags schema",
"description": "An explanation about the purpose of this instance.",
"default": [],
"examples": [],
"additionalItems": true,
"minItems": 1,
"items": {
"$id": "#/items/anyOf/0/properties/tags/items",
"anyOf": [
{
"$id": "#/items/anyOf/0/properties/tags/items/anyOf/0",
"type": "string",
"title": "The first anyOf schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": []
aslafy-z marked this conversation as resolved.
Show resolved Hide resolved
}
]
}
}
}
}
]
}
}
8 changes: 8 additions & 0 deletions test/functional/data.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ const got = require('got');
const {expect} = require('chai');
const parallel = require('mocha.parallel');
const sharp = require('sharp');
const Ajv = require('ajv');

const data = require('../../data.json');
aslafy-z marked this conversation as resolved.
Show resolved Hide resolved
const schema = require('../../schema.json');
const LIMIT_PARALLEL_TESTS = 10;

const requestOptions = {
Expand All @@ -23,6 +25,12 @@ function checkURL(url, head = false) {
}

describe('swag-for-dev', function () {
it('data.json has valid schema', function () {
const ajv = new Ajv();
aslafy-z marked this conversation as resolved.
Show resolved Hide resolved
const valid = ajv.validate(schema, data);
expect(valid).to.be.true;
});

it('data.json is valid', function () {
aslafy-z marked this conversation as resolved.
Show resolved Hide resolved
expect(data).to.be.an('Array');
data.forEach(datum => {
Expand Down