You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+25-34
Original file line number
Diff line number
Diff line change
@@ -61,13 +61,13 @@ There are various ways you can contribute:
61
61
- Add positive/negative tests
62
62
- Refactor to pass under strict mode
63
63
64
-
Most people want to add a new schema. For steps on how to do this, read the [How to add a JSON Schema that's hosted in this repository](#how-to-add-a-json-schema-thats-hosted-in-this-repository) section below.
64
+
Most people want to add a new schema. For steps on how to do this, read the [How to add a JSON Schema that's hosted in this repository](#how-to-add-a-json-schema-thats-hosted-in-this-repository) section below. Find instructions for other tasks under the [How To](#how-to) section.
65
65
66
66
If you want to contribute, but not sure what needs fixing, see the [help wanted](https://github.com/SchemaStore/schemastore/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22) and [good first issue](https://github.com/SchemaStore/schemastore/issues?q=is%3Aopen+label%3A%22good+first+issue%22+sort%3Aupdated-desc) labels on GitHub.
67
67
68
68
## Overview
69
69
70
-
Schema files are located in `src/schemas/json`. Each schema file has a corresponding entry in the [Schema Catalog](src/api/json/catalog.json). Each catalog entry has a `fileMatch` field. IDEs use this field to know which files the schema should be used for (in autocompletion).
70
+
Schema files are located in `src/schemas/json`. Each schema file has a corresponding entry in the [Schema Catalog](src/api/json/catalog.json). Each catalog entry has a `fileMatch` field. IDEs and language servers use this field to know which files the schema should be used for (in autocompletion).
71
71
72
72
Some schema files have associated positive and negative tests, located at `src/test` and `src/negative_test`, respectively. These tests may be in JSON, YAML, or TOML format.
73
73
@@ -91,9 +91,24 @@ The goal of JSON Schemas in this repository is to correctly validate schemas tha
91
91
92
92
### Best practices
93
93
94
-
✔️ **Use** the most recent JSON Schema version (specified by `$schema`) that's widely supported by editors and IDEs. Currently, the best supported version is `draft-07`. Later versions of JSON Schema are not recommended for use in SchemaStore until editor/IDE support improves for those versions.
94
+
- We recommend using the `draft-07` JSON schema version. Later versions of JSON Schema are not yet recommended for use in SchemaStore until IDE and language support improves for those versions.
95
95
96
-
✔️ **Use**[`base.json`][base] schema for `draft-07` and [`base-04.json`][base-04] for `draft-04` with some common types for all schemas.
96
+
❌ **Don't forget** add test files.
97
+
98
+
### Useful Conventions
99
+
100
+
- Consider using documentation URLs in `"description"` to improve UX. Most schemas use the format `<description>\n<url>`. For example: `"Whether to ignore a theme configuration for the current site\nhttps://jekyllrb.com/docs/configuration/options/#global-configuration"`
101
+
- Consider using the [`base.json`][base] schema for `draft-07` or [`base-04.json`][base-04] for `draft-04` to use subschemas that are commonly used.
102
+
- When writing `description`, avoid phrases like "there are three possibilities" and "valid values are" in favor of adding the constraints to the schema directly.
103
+
- If you choose to use `title`, we recommend formatting it so that object values look like types in programming languages. This includes:
104
+
- Omitting leading articles and trailing punctuation
105
+
- Beginning it with a lowercase letter
106
+
- Using nouns instead of sentences
107
+
108
+
**Unofficial Strict Mode**
109
+
110
+
> [!WARNING]
111
+
> This "unofficial strict mode" may have bugs or be incomplete.
97
112
98
113
There is an [unofficial draft-07][draft-07-unofficial-strict] schema that uses JSON Schema to validate your JSON Schema. It checks that:
99
114
@@ -102,21 +117,7 @@ There is an [unofficial draft-07][draft-07-unofficial-strict] schema that uses J
102
117
-`type` can't be an array, which is intentional, `anyOf`/`oneOf` should be used in this case
103
118
- It links to [understanding-json-schema](https://json-schema.org/understanding-json-schema) for each hint/check
104
119
105
-
To check your schema against that schema, use `node cli.js check-strict --schema-name=<schemaName.json>`.
106
-
107
-
❌ **Don't forget** add test files.
108
-
109
-
- Always be consistent across your schema: order properties and describe in the same style.
110
-
- Always use `description`, `type`, `additionalProperties`.
111
-
- Always set `additionalProperties` to `false` unless documentation permits
112
-
additional properties explicitly. That tool the JSON schema is created for
113
-
can be changed in the future to allow wrong extra properties.
114
-
- Don't end `title`/`description` values with colon.
115
-
- Always omit leading articles for `title`-s and trailing punctuation to make
116
-
expected object values look more like types in programming languages. Also
117
-
start `title`-s with a lowercase letter and try use nouns for titles instead of sentences.
118
-
- Always add documentation url to descriptions when available in the following
119
-
format: `<description>\n<url>` like `"Whether to ignore a theme configuration for the current site\nhttps://jekyllrb.com/docs/configuration/options/#global-configuration"`.
120
+
To check your schema against that schema, use `node cli.js check-strict --schema-name=<schemaName.json>`. Note that this is NOT the same as Ajv strict mode.
@@ -129,13 +130,13 @@ Sometimes, constraints do more harm than good. For example, [cron strings](http:
129
130
- false positives are likely (due to their complexity or abundance of implementations)
130
131
- its error message is too confusing or not helpful
131
132
132
-
So, do not add regex patterns for any of the following:
133
+
So, we recommend avoiding regex patterns for:
133
134
134
135
- cron regexes
135
136
- string-embedded DSLs
136
137
- SSH URLs, HTTPS URLs, and other complex URIs
137
138
138
-
In addition, be wary when adding exhaustive support to enum-type fields. Often, when applications expand support (thus expanding the set of allowable enums), the schema will become invalid.
139
+
In addition, be wary when adding exhaustive support to enum-type fields (without a `"type": "string"` fallback). Often, when applications expand support (thus expanding the set of allowable enums), the schema will become invalid.
139
140
140
141
#### Undocumented Features
141
142
@@ -194,7 +195,7 @@ Note that JSON Schema draft `2019-09` adds support for a `deprecated` field:
194
195
}
195
196
```
196
197
197
-
While this would be the best option, most schemas in this repository are `draft-07`. As a result, _Editors and IDEs may not use it_.
198
+
While this would be the best option, most schemas in this repository are `draft-07`. As a result, _IDEs and language servers may not use it_.
198
199
199
200
#### API Compatibility
200
201
@@ -368,7 +369,7 @@ To actually run the validation checks, see [How to validate a JSON Schema](#how-
368
369
369
370
## About `catalog.json`
370
371
371
-
The `catalog.json` file is generally used by editors and extensions to determine which schemas apply to what files. Specifically:
372
+
The `catalog.json` file is generally used by IDEs and language servers to determine which schemas apply to what files. Specifically:
372
373
373
374
- VSCode ignores this file [see issue](https://github.com/microsoft/vscode/issues/26289)
374
375
-[RedHat's YAML language server](#redhat-developeryaml-language-server) uses this file ([see configuration](https://github.com/redhat-developer/vscode-yaml/blob/41e0be736f2d07cdf7489e1c1c591b35b990e096/package.json#L176))
@@ -468,17 +469,7 @@ To fix this, run the formatter manually:
468
469
npm run prettier:fix
469
470
```
470
471
471
-
Note this will also format the following files:
472
-
473
-
```sh
474
-
$ git status --short
475
-
M src/test/prettierrc/.prettierrc.yml
476
-
M src/test/prettierrc/prettierrc.json
477
-
```
478
-
479
-
_Do not_ add those two files; pre-commit.ci seems to have issue with them. (Undo modifications to those files by running `git restore -- 'src/test/prettierrc/*'`)
0 commit comments