simple-icons/.jsonschema.json
Eric Cornelissen 39269e7d39
Add icon license to JSON linting (and change JSON linting dependency) (#4945)
* Add "license" object to the data file JSON schema

* Add license to GNU and GNU social

As an example, based on the discussion in:
https://github.com/simple-icons/simple-icons/issues/1167

* Use `"additionalProperties": false` in JSON schema

... to detect properties in the data file that shouldn't be there.

For more info, see:
https://json-schema.org/understanding-json-schema/reference/object.html

* Update JSON scheme descriptions

* Switch from jsonlint2 to jsonschema

This gives is better support for advanced features of JSON schema.

A couple of clarifications:
- There does exist a jsonschema-cli package, but it is rather limited
  and crucially doens't exit with a non-zero exit code if there is an
  error. (it is also pretty old and not maintained), hence the custom
  script.
- I renamed .jsonlintschema 1) for clarity (lint is no longer accurate)
  and 2) the .json extension allows easy imorting in the script and 3)
  it adds syntax highlighting.
- The script outputs the number of errors in the end because the output
  gets pretty big pretty quickly, this way you can see it easily from
  your CLI.
- We could customize how the errors are logged, but I feel that is
  beyond this PR.

* Two minor changes

* Use `oneOf` to require URL for custom licenses

The updated configuration allows the `"license"` field to be either
1) a SPDX license, optional with a URL
2) a "custom" license with a required URL

Read more about the "oneOf" feature of jsonschema at:
https://json-schema.org/understanding-json-schema/reference/combining.html#oneof

* Include license field in Contributing Guidelines
2021-02-19 15:19:22 +01:00

163 lines
4.9 KiB
JSON

{
"title": "Simple Icons",
"definitions": {
"brand": {
"description": "A single brand",
"type": "object",
"required": ["title", "hex", "source"],
"properties": {
"title": {
"description": "The name of the brand",
"type": "string"
},
"slug": {
"description": "The brand name slug (used as filename in icons/)",
"type": "string",
"pattern": "^[a-z0-9\\-]+_[a-z0-9\\-]+$",
"required": false
},
"hex": {
"description": "The brand color as a 6-character value (without #)",
"type": "string",
"pattern": "^[0-9A-F]{6}$"
},
"source": {
"description": "The website from which the icon was sourced",
"$ref": "#/definitions/url"
},
"guidelines": {
"description": "The brand guidelines",
"$ref": "#/definitions/url"
},
"license": {
"description": "The license for the icon",
"oneOf": [
{
"type": "object",
"required": ["type", "url"],
"properties": {
"type": {
"description": "The license name or 'custom'",
"type": "string",
"enum": ["custom"]
},
"url": {
"description": "The URL to the license text by the brand",
"$ref": "#/definitions/url"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": ["type"],
"properties": {
"type": {
"description": "An SPDX License Identifier",
"type": "string",
"enum": [
"0BSD",
"AAL",
"AFL-1.1",
"AFL-1.2",
"AFL-2.0",
"AFL-3.0",
"Afmparse",
"AGPL-1.0-only",
"AGPL-1.0-or-later",
"AGPL-3.0-only",
"AGPL-3.0-or-later",
"Aladdin",
"AML",
"AMPAS",
"Apache-1.0",
"Apache-1.1",
"Apache-2.0",
"APL-1.0",
"Artistic-1.0",
"Artistic-1.0-cl8",
"Artistic-1.0-Perl",
"Artistic-2.0",
"CC-BY-1.0",
"CC-BY-2.0",
"CC-BY-2.5",
"CC-BY-3.0",
"CC-BY-4.0",
"CC-BY-NC-ND-1.0",
"CC-BY-NC-ND-2.0",
"CC-BY-NC-ND-2.5",
"CC-BY-NC-ND-3.0",
"CC-BY-NC-ND-4.0",
"CC-BY-NC-SA-1.0",
"CC-BY-NC-SA-2.0",
"CC-BY-NC-SA-2.5",
"CC-BY-NC-SA-3.0",
"CC-BY-NC-SA-4.0",
"CC-BY-ND-1.0",
"CC-BY-ND-2.0",
"CC-BY-ND-2.5",
"CC-BY-ND-3.0",
"CC-BY-ND-4.0",
"CC-BY-SA-1.0",
"CC-BY-SA-2.0",
"CC-BY-SA-2.5",
"CC-BY-SA-3.0",
"CC-BY-SA-4.0",
"CC-PDDC",
"CC0-1.0",
"CDDL-1.0",
"CDDL-1.1",
"ClArtistic",
"copyleft-next-0.3.0",
"copyleft-next-0.3.1",
"CPAL-1.0",
"CPL-1.0",
"CPOL-1.02",
"EUPL-1.0",
"EUPL-1.1",
"EUPL-1.2",
"GPL-1.0-only",
"GPL-1.0-or-later",
"GPL-2.0-only",
"GPL-2.0-or-later",
"GPL-3.0-only",
"GPL-3.0-or-later",
"LAL-1.2",
"LAL-1.3",
"NLPL",
"OPL-1.0",
"Unlicense",
"UPL-1.0",
"WTFPL"
]
},
"url": {
"description": "The URL to the license text by the brand",
"$ref": "#/definitions/url"
}
},
"additionalProperties": false
}
]
}
},
"additionalProperties": false
},
"url": {
"$id": "#url",
"type": "string",
"pattern": "^https?://[^\\s]+$"
}
},
"type": "object",
"properties": {
"icons": {
"description": "A list of brands",
"type": "array",
"items": { "$ref": "#/definitions/brand" }
}
}
}