Created
December 19, 2018 20:45
-
-
Save NickyMeuleman/f18b70684e12697d71b4178ad1403988 to your computer and use it in GitHub Desktop.
JSON-schema
This file contains 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
{ | |
"$schema": "./drivers.schema.json", | |
"series": "f1", | |
"season": 2018, | |
"driverList": [ | |
{ | |
"raceNumber": 14, | |
"code": "ALO", | |
"firstName": "Fernando", | |
"lastName": "Alonso", | |
"dateOfBirth": "1981-07-29", | |
"team": "MCLAREN", | |
"quotes": ["GP2 engine, GP2", "5 second penalty? Issa yoke"] | |
}, | |
{ | |
"raceNumber": 3, | |
"code": "RIC", | |
"firstName": "Daniel", | |
"lastName": "Ricciardo", | |
"dateOfBirth": "1989-07-01", | |
"nationality": "Australian", | |
"team": "REDBULL" | |
} | |
] | |
} |
This file contains 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
{ | |
"$schema": "http://json-schema.org/draft-07/schema", | |
"title": "Drivers", | |
"description": "Formula 1 drivers", | |
"type": "object", | |
"additionalProperties": false, | |
"properties": { | |
"$schema": { | |
"type": "string", | |
"description": "path to the JSON-schema to use for this file" | |
}, | |
"series": { | |
"type": "string", | |
"const": "f1" | |
}, | |
"season": { | |
"type": "integer", | |
"description": "year corresponding with season" | |
}, | |
"driverList": { | |
"type": "array", | |
"items": { | |
"$ref": "#/definitions/driver" | |
} | |
} | |
}, | |
"definitions": { | |
"driver": { | |
"type": "object", | |
"additionalProperties": false, | |
"properties": { | |
"raceNumber": { | |
"type": "integer", | |
"minimum": 0, | |
"maximum": 99, | |
"description": "number this driver races with" | |
}, | |
"code": { | |
"type": "string", | |
"minLength": 3, | |
"maxLength": 3, | |
"description": "3 letter abbreviation" | |
}, | |
"firstName": { | |
"type": "string" | |
}, | |
"lastName": { | |
"type": "string" | |
}, | |
"dateOfBirth": { | |
"type": "string", | |
"format": "date", | |
"description": "dateOfBirth in YYYY-MM-DD format", | |
"default": "YYYY-MM-DD" | |
}, | |
"nationality": { | |
"type": "string" | |
}, | |
"team": { | |
"$ref": "#/definitions/team" | |
}, | |
"quotes": { | |
"type": "array", | |
"items": { | |
"type": "string" | |
}, | |
"uniqueItems": true | |
} | |
}, | |
"required": ["raceNumber", "code", "team"] | |
}, | |
"team": { | |
"enum": [ | |
"MCLAREN", | |
"FERRARI", | |
"REDBULL", | |
"TOROROSSO", | |
"MERCEDES", | |
"RENAULT", | |
"HAAS", | |
"FORCEINDIA", | |
"SAUBER", | |
"WILLIAMS" | |
] | |
} | |
} | |
} |
Hi @averyfreeman,
Thanks, glad you liked it!
I've noticed a trend recently where many newer tools come with configuration files that use a JSON-schema automatically, no user intervention needed.
As for a way to automatically link the schemas listed on schemastore.org to a .json
file in your editor, I don't know. Maybe the folks in the official JSON-schema slack chat know more.
Sounds good, I'll track them down. Thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Liked the article, thanks for sharing. Is there a resource for a generic list of all the schemas listed at https://schemastore.org so I don't have to populate them all myself, though?