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.
(from https://github.com/orgs/json-schema-org/discussions/323)
This is a ruleset for Spectral that covers
enum
/const
do not require additional validation #1$schema
unless an object is a resource root (has$id
) #3if
withoutthen
orelse
(and vice versa) is unnecessary #5$id
#16$schema
at the root #17I've been using the Spectral VSCode extension to write them. There are a couple gotchas when using it, though:
.spectral.yml
file to be at the root of the workspace, so you'll need to open the /spectral folder instead of the repo root.The approach I'm using in designing these rules is to get VSCode to highlight the problem keyword specifically. For example, highlighting
if
(or its value) if there isn't also athen
orelse
. This provides a better dev experience by showing where the problem is rather than just telling them.For many of these rules I found simpler ways to express the rule, but those ways seemed to highlight more of the JSON than was necessary (e.g. highlighting the entire subschema that contains the
if
doesn't tell you that theif
is the problem).We will be looking for a way to properly publish these, but for now this gets them off of my local computer.
I'll also include a readme in the spectral folder.