Skip to content

Fix issues with JSON Schema + add schema linting to CI - #1476

Merged
andreynering merged 4 commits into
go-task:mainfrom
sirosen:jsonschema-improvements
Jan 19, 2024
Merged

andreynering merged 4 commits into
go-task:mainfrom
sirosen:jsonschema-improvements

Conversation

@sirosen

@sirosen sirosen commented Jan 18, 2024

Copy link
Copy Markdown
Contributor

Resolves #1474.
I've gone ahead and included a CI change to start running check-jsonschema against the schema in the docs dir, as mentioned in that issue, since it was part of how I validated this change.

I've tried to chunk the commits for easy review:

  • Remove "versioning" from jsonschema 'definitions' (remove the "3")
  • Dedent JSON Schema 'definitions' (git diff hates this one)
  • Fix malformed defer definition in JSON Schema ("string" -> {"type": "string"})
  • Add a linting step for the JSON Schema (.github/workflows/lint.yaml)

Aside:

I've been a little bit biased in check-jsonschema towards developers with workflows like my own and haven't thought hard enough about use-cases like this repo. I'll be thinking harder about providing docker containers to run the tool, perhaps some experimental binary builds (there are tools for this like pyinstaller) and maybe a GitHub Action too.

One thing which GitHub Actions has, which I would really like to be able to offer, is the integration with Dependabot to help you stay up to date as the tool evolves. So that's another angle on this.

I can't promise anything yet, but I'd like to make installing and using it easier for non-Python projects.

@andreynering

Copy link
Copy Markdown
Member

@sirosen I believe the CI failed because it missed the checkout step.

@sirosen

sirosen commented Jan 19, 2024

Copy link
Copy Markdown
Contributor Author

🤦 I feel silly for missing that; good catch! I've just pushed the added step as a fresh commit. I could squash it with the previous one if you have strong feelings about the git history and would like me to do so.

@andreynering

Copy link
Copy Markdown
Member

@sirosen Don't worry! A small mistake.

It'd be nice to have that commit squashed, if you don't mind. Also, adopting conventional commits for the commit messages would be great.

This removes the "3" nested in `definitions` which makes the contents
of `definitions` pass JSON Schema metaschema validation even when the
contents are not valid subschemas. `definitions` SHOULD contain
subschemas as its values, with no intermediate keys. (This is a MUST
in later JSON Schema spec versions, in which the key switches from
`definitions` to `$defs` as a related change.)

The contents are intentionally *not* dedented to make review easier.
The default git diff algorithm isn't great at showing this because
it incorrectly matches some closing blocks against other, distant,
closing blocks. But this is all just a two-space dedent.
The `defer` definition listed `"string"` where `{"type":"string"}`
was wanted.
This is written to use `check-jsonschema` on the (current) latest
version (0.27.3).

It checks that the JSON Schema published in the docs is valid
under its declared metaschema (`$schema`).
@sirosen
sirosen force-pushed the jsonschema-improvements branch from 517045f to 2dd909b Compare January 19, 2024 20:43
@sirosen

sirosen commented Jan 19, 2024

Copy link
Copy Markdown
Contributor Author

I just did a rebase to conventional-commits-ize the branch + squash those two commits. 👍

@andreynering andreynering added the area: json schema Changes related to the JSON schema. label Jan 19, 2024
@andreynering

Copy link
Copy Markdown
Member

Awesome, thanks @sirosen!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: json schema Changes related to the JSON schema.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Schema for defer_call contains invalid JSON Schema, causing some schema validators to fail

2 participants