-
Notifications
You must be signed in to change notification settings - Fork 0
add minimal JSON schema #116
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e3c6454
add minimal JSON schema
cjyetman ec4172a
formatting
cjyetman d5d062b
add npm script function to run ajv JSON validation
cjyetman 8de3682
add JSON validator GitHub action (and invalid data to trigger an error)
cjyetman 3c5f2f1
fix data error
cjyetman 18b22b6
change `json` script to `json:check`
cjyetman c1ae9ac
use `@jirutka/ajv-cli` instead of `ajv-cli`
cjyetman 63e17d9
update JSON validation commmand for `@jirutka/ajv-cli`
cjyetman 4e5080e
remove stray double quote
cjyetman 0344e50
fail on additional properties (with intentional error)
cjyetman fb0cbfe
fix intentional error
cjyetman 359a6c1
make all fields required (with intentional failure)
cjyetman e75d9f2
fix intentional error
cjyetman 8d45d63
fix linting
cjyetman ae6d64b
require all and only schema keys in `dataSource` object (with intenti…
cjyetman 57273f5
fix intentional error
cjyetman 2fbbcf6
fix formatting
cjyetman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| name: JSON validate Frontend service | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'frontend/pbtar_schema.json' | ||
| - 'frontend/src/data/scenarios_metadata.json' | ||
| - '.github/workflows/frontend-json.yml' | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'frontend/pbtar_schema.json' | ||
| - 'frontend/src/data/scenarios_metadata.json' | ||
| - '.github/workflows/frontend-json.yml' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| lint: | ||
| name: "Run ajv JSON validator" | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
| cache: 'npm' | ||
| cache-dependency-path: frontend/package-lock.json | ||
|
|
||
| - name: Install dependencies | ||
| working-directory: ./frontend | ||
| run: npm ci | ||
|
|
||
| - name: Run ajv JSON validator | ||
| working-directory: ./frontend | ||
| run: npm run json:check |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "$id": "pbtar_schema.json", | ||
| "title": "PBTAR Scenarios metadata Schema", | ||
| "description": "A schema for the scenarios metadata dataset in PBTAR", | ||
| "type": "array", | ||
| "items": { | ||
| "type": "object", | ||
| "properties": { | ||
| "id": { | ||
| "description": "The unique identifier for a scenario", | ||
| "type": "string" | ||
| }, | ||
| "name": { | ||
| "description": "Name of the scenario", | ||
| "type": "string" | ||
| }, | ||
| "description": { | ||
| "description": "Description of the scenario", | ||
| "type": "string" | ||
| }, | ||
| "category": { | ||
| "description": "Category of the scenario", | ||
| "type": "string" | ||
| }, | ||
| "target_year": { | ||
| "description": "Target year of the scenario", | ||
| "type": "string" | ||
| }, | ||
| "target_temperature": { | ||
| "description": "Target temperature of the scenario", | ||
| "type": "string" | ||
| }, | ||
| "regions": { | ||
| "description": "Regions that the scenario covers", | ||
| "type": "array", | ||
| "uniqueItems": true, | ||
| "items": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "sectors": { | ||
| "description": "Sectors that the scenario covers", | ||
| "type": "array", | ||
| "items": { | ||
| "enum": [ | ||
| "Agriculture", | ||
| "Buildings", | ||
| "Coal", | ||
| "Industrial", | ||
| "Oil & Gas", | ||
| "Power", | ||
| "Renewables", | ||
| "Transport" | ||
| ] | ||
| } | ||
| }, | ||
| "publisher": { | ||
| "description": "Publisher of the scenario", | ||
| "type": "string" | ||
| }, | ||
| "published_date": { | ||
| "description": "Date that the scenario was published", | ||
| "type": "string" | ||
| }, | ||
| "overview": { | ||
| "description": "Overview of the scenario", | ||
| "type": "string" | ||
| }, | ||
| "expertRecommendation": { | ||
| "description": "Expert recommendation for the scenario", | ||
| "type": "string" | ||
| }, | ||
| "dataSource": { | ||
| "description": "Data source for the scenario", | ||
| "type": "object", | ||
| "properties": { | ||
| "description": { "type": "string" }, | ||
| "url": { "type": "string" }, | ||
| "downloadAvailable": { "type": "boolean" } | ||
| }, | ||
| "additionalProperties": false, | ||
| "required": ["description", "url", "downloadAvailable"] | ||
| } | ||
| }, | ||
| "additionalProperties": false, | ||
| "required": [ | ||
| "id", | ||
| "name", | ||
| "description", | ||
| "category", | ||
| "target_year", | ||
| "target_temperature", | ||
| "regions", | ||
| "sectors", | ||
| "publisher", | ||
| "published_date", | ||
| "overview", | ||
| "expertRecommendation", | ||
| "dataSource" | ||
| ] | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.