JSON Schema Linting - A call for rules #323
Replies: 17 comments 20 replies
-
We'll also need a place to store and publish the rule set. Let's discuss that here. |
Beta Was this translation helpful? Give feedback.
-
I see a lot of schemas where the author has specified an {
"type": "string",
"enum": [
"one",
"two",
3
]
} (This example is at the root schema, but it can occur in a subschema, too.) The problem here is that This rule would enforce that every value present in an |
Beta Was this translation helpful? Give feedback.
-
Validation keywords that don't operate on the specified type should be removed. For example: {
"type": "object",
"minimum": 5
}
This would be a family of rules. |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
Disallow We can't really identify places in an object where schemas are expected with Spectral. We can only really check for whether there's an |
Beta Was this translation helpful? Give feedback.
-
(from https://ajv.js.org/strict-mode.html#ignored-additionalitems-keyword)
|
Beta Was this translation helpful? Give feedback.
-
(from https://ajv.js.org/strict-mode.html#ignored-if-then-else-keywords)
|
Beta Was this translation helpful? Give feedback.
-
(from https://ajv.js.org/strict-mode.html#ignored-contains-maxcontains-and-mincontains-keywords)
|
Beta Was this translation helpful? Give feedback.
-
(from https://ajv.js.org/strict-mode.html#unknown-formats) Unknown |
Beta Was this translation helpful? Give feedback.
-
(from https://ajv.js.org/strict-mode.html#defined-required-properties) Properties listed in |
Beta Was this translation helpful? Give feedback.
-
(from https://ajv.js.org/strict-mode.html#contradictory-types) Contradictory types between a keyword and a subschema of an adjacent applicator.
Not sure how we'll be able to identify this one in a rule... |
Beta Was this translation helpful? Give feedback.
-
(from https://ajv.js.org/strict-mode.html#require-applicable-types) In conjuction with https://github.com/orgs/json-schema-org/discussions/323#discussioncomment-4899030, being able to suggest |
Beta Was this translation helpful? Give feedback.
-
Do we need to try to isolate some of these to consider the spec version? This could help isolate vocab things, like how |
Beta Was this translation helpful? Give feedback.
-
Values in Perhaps a warning here. |
Beta Was this translation helpful? Give feedback.
-
Range issues:
Haven't tested this in Spectral yet to determine feasibility. |
Beta Was this translation helpful? Give feedback.
-
Suggest Not sure how intrusive we should be with these. Info, maybe? |
Beta Was this translation helpful? Give feedback.
-
Suggest meta-data like Not sure how intrusive we should be with these. Info, maybe? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
We're looking at putting together some official JSON Schema linting rules for Spectral!
Rules can be things like, "Your schema should have a
$schema
at the root." (I've already included this one.)To propose a rule, please create a new thread. We'll discuss each rule in the thread.EDIT: A new repo has been created for this: https://github.com/json-schema-org/json-schema-linting Please create issues there for new proposals. The proposals here will be migrated to issues there.
Beta Was this translation helpful? Give feedback.
All reactions