Skip to content

Commit

Permalink
Added JSON schema
Browse files Browse the repository at this point in the history
  • Loading branch information
manami-project committed May 1, 2024
1 parent d181db3 commit 0eb2503
Show file tree
Hide file tree
Showing 4 changed files with 251 additions and 26 deletions.
69 changes: 43 additions & 26 deletions .github/workflows/json_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,50 @@ on:
- '.github/CONTRIBUTING.md'

jobs:
build:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install jsonlint-cli -g
- name: Lint dataset
run: jsonlint-cli *.json
- name: Lint dead-entries
run: jsonlint-cli dead-entries/*.json
check-commit-message:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check commit message
id: check_message
run: |
MESSAGE=$(git log --format=%B -n 1 ${{ github.event.after }})
if [[ "$MESSAGE" == "Updated entries"* ]]; then
echo "run_schema_validation=true" >> "$GITHUB_OUTPUT"
else
echo "run_schema_validation=false" >> "$GITHUB_OUTPUT"
fi
outputs:
run_schema_validation: ${{ steps.check_message.outputs.run_schema_validation }}
dataset-validation:
needs: check-commit-message
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cardinalby/schema-validator-action@v3
if: ${{ needs.check-commit-message.outputs.run_schema_validation == 'true' }}
with:
file: 'anime-offline-database.json|anime-offline-database-minified.json'
schema: 'schema.json'
dead-entries-validation:
needs: check-commit-message
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup node environment
uses: actions/setup-node@v4
- uses: cardinalby/schema-validator-action@v3
if: ${{ needs.check-commit-message.outputs.run_schema_validation == 'true' }}
with:
node-version: '16'
- name: Install jsonlint
run: npm install jsonlint -g
- name: Check anime-offline-database.json
run: jsonlint -q anime-offline-database.json
- name: Check anime-offline-database-minified.json
run: jsonlint -q anime-offline-database-minified.json
- name: Check dead-entries for anidb
run: jsonlint -q dead-entries/anidb.json
- name: Check dead-entries for anidb-minified.json
run: jsonlint -q dead-entries/anidb-minified.json
- name: Check dead-entries for anilist
run: jsonlint -q dead-entries/anilist.json
- name: Check dead-entries for anilist-minified.json
run: jsonlint -q dead-entries/anilist-minified.json
- name: Check dead-entries for kitsu
run: jsonlint -q dead-entries/kitsu.json
- name: Check dead-entries for kitsu-minified.json
run: jsonlint -q dead-entries/kitsu-minified.json
- name: Check dead-entries for myanimelist
run: jsonlint -q dead-entries/myanimelist.json
- name: Check dead-entries for myanimelist-minified.json
run: jsonlint -q dead-entries/myanimelist-minified.json
file: 'dead-entries/anidb.json|dead-entries/anidb-minified.json|dead-entries/anilist.json|dead-entries/anilist-minified.json|dead-entries/kitsu.json|dead-entries/kitsu-minified.json|dead-entries/myanimelist.json|dead-entries/myanimelist-minified.json'
schema: 'dead-entries/schema.json'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
!anime-offline-database.json
!anime-offline-database-minified.json
!anime-offline-database.zip
!schema.json

!.github/
.github/*
Expand Down Expand Up @@ -38,6 +39,7 @@ dead-entries/*
!dead-entries/myanimelist.json
!dead-entries/myanimelist-minified.json
!dead-entries/myanimelist.zip
!dead-entries/schema.json

!pics/
pics/*
Expand Down
49 changes: 49 additions & 0 deletions dead-entries/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/manami-project/anime-offline-database/blob/raw/dead-entries/schema.json",
"title": "anime-offline-database",
"description": "Updated every week: A JSON based anime dataset containing the most important meta data as well as cross references to various anime sites such as MAL, ANIDB, ANILIST, KITSU and more... ",
"type": "object",
"required": [
"license",
"repository",
"lastUpdate",
"deadEntries"
],
"properties": {
"license": {
"description": "Information about the license of the dataset.",
"type": "object",
"required": [
"name",
"url"
],
"properties": {
"name": {
"description": "Name of the license.",
"const": "GNU Affero General Public License v3.0"
},
"url": {
"description": "URL to the whole license file.",
"const": "https://github.com/manami-project/anime-offline-database/blob/master/LICENSE"
}
}
},
"repository": {
"description": "URL of this github repository which is the source of the dataset.",
"const": "https://github.com/manami-project/anime-offline-database"
},
"lastUpdate": {
"description": "The date on which the file was updated in the format: YYYY-MM-DD.",
"type": "string"
},
"deadEntries": {
"description": "IDs of anime which have been removed from the respective meta data provider.",
"type": "array",
"uniqueItems": true,
"items": {
"type": "string"
}
}
}
}
157 changes: 157 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/manami-project/anime-offline-database/raw/master/schema.json",
"title": "anime-offline-database",
"description": "Updated every week: A JSON based anime dataset containing the most important meta data as well as cross references to various anime sites such as MAL, ANIDB, ANILIST, KITSU and more... ",
"type": "object",
"required": [
"license",
"repository",
"lastUpdate",
"data"
],
"properties": {
"license": {
"description": "Information about the license of the dataset.",
"type": "object",
"required": [
"name",
"url"
],
"properties": {
"name": {
"description": "Name of the license.",
"const": "GNU Affero General Public License v3.0"
},
"url": {
"description": "URL to the whole license file.",
"const": "https://github.com/manami-project/anime-offline-database/blob/master/LICENSE"
}
}
},
"repository": {
"description": "URL of this github repository which is the source of the dataset.",
"const": "https://github.com/manami-project/anime-offline-database"
},
"lastUpdate": {
"description": "The date on which the file was updated in the format: YYYY-MM-DD.",
"type": "string"
},
"data": {
"description": "List of all anime.",
"type": "array",
"uniqueItems": true,
"items": {
"type": "object",
"required": [
"sources",
"title",
"type",
"episodes",
"status",
"animeSeason",
"picture",
"thumbnail",
"synonyms",
"relatedAnime",
"tags"
],
"properties": {
"sources": {
"description": "URLs to the pages of the meta data providers for this anime.",
"type": "array",
"uniqueItems": true,
"items": {
"type": "string"
}
},
"title": {
"description": "Main title.",
"type": "string"
},
"type": {
"description": "Distribution type.",
"enum": [
"TV",
"MOVIE",
"OVA",
"ONA",
"SPECIAL",
"UNKNOWN"
]
},
"episodes": {
"description": "Number of episodes, movies or parts.",
"type": "number",
"minimum": 0
},
"status": {
"description": "Status of distribution.",
"enum": [
"FINISHED",
"ONGOING",
"UPCOMING",
"UNKNOWN"
]
},
"animeSeason": {
"description": "Data on when the anime was first distributed.",
"type": "object",
"required": [
"season"
],
"properties": {
"season": {
"description": "Season.",
"enum": [
"SPRING",
"SUMMER",
"FALL",
"WINTER",
"UNDEFINED"
]
},
"year": {
"description": "Year.",
"type": ["number", "null"],
"minimum": 1907
}
}
},
"picture": {
"description": "URL of a picture which represents the anime.",
"type": "string"
},
"thumbnail": {
"description": "URL of a smaller version of the picture.",
"type": "string"
},
"synonyms": {
"description": "Alternative titles and spellings under which the anime is also known.",
"type": "array",
"uniqueItems": true,
"items": {
"type": "string"
}
},
"relatedAnime": {
"description": "URLs to the meta data providers for anime that are somehow related to this anime.",
"type": "array",
"uniqueItems": true,
"items": {
"type": "string"
}
},
"tags": {
"description": "A non-curated list of tags and genres which describe the anime.",
"type": "array",
"uniqueItems": true,
"items": {
"type": "string"
}
}
}
}
}
}
}

0 comments on commit 0eb2503

Please sign in to comment.