Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate with the JSON Schema CLI for formatting and linting #45

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jviotti
Copy link

@jviotti jviotti commented Jun 5, 2024

Hey there! This is a PR to mainly start a conversation. I'm a member of JSON Schema organization involved in maintaining various JSON Schema related tooling (like https://alterschema.sourcemeta.com) and documentation (like https://www.learnjsonschema.com), plus co-author of the recently published O'Reilly book touching on JSON Schema (https://www.oreilly.com/library/view/unifying-business-data/9781098144999/).

Based on our experience working with organizations maintaining repositories of schemas (like you!), we've been working on an open-source CLI tool that aims to simplify development and CI/CD when dealing with schemas. This CLI supports a growing amount of commands, but I'm proposing two for this repository to start with:

  • Formatting: making sure your schemas following a consistent style (i.e. indentation) plus a consistent ordering of keywords that was designed to make schemas easier to read

  • Linting: we are collecting common rules to highlight anti-patterns, common pitfalls, etc when using JSON Schema. There are not that many implement out there, but the linter already caught some issues

I would love to hear your feedback, feature requests, etc to help you make better use of JSON Schema with this CLI! We also have other things on the way, like a proper JSON Schema test runner that could eventually automatically validate the examples in the repo.

@conda-bot
Copy link
Contributor

We require contributors to sign our Contributor License Agreement and we don't have one on file for @jviotti.

In order for us to review and merge your code, please e-sign the Contributor License Agreement PDF. We then need to manually verify your signature, merge the PR (conda/infrastructure#953), and ping the bot to refresh the PR.

@jviotti
Copy link
Author

jviotti commented Jun 5, 2024

For the record, these were some of the linting warnings the tool already detected, which I fixed by using the --fix option:

$ jsonschema lint *.schema.json
channeldata-1.schema.json
    /properties/$schema Setting `type` alongside `const` is considered an anti-pattern, as the constant already implies its respective type (const_with_type)
channeldata-1.schema.json
    /properties/schema_version Setting `type` alongside `const` is considered an anti-pattern, as the constant already implies its respective type (const_with_type)
common-1.schema.json
    /definitions/ext Setting `type` alongside `enum` is considered an anti-pattern, as the enumeration choices already imply their respective types (enum_with_type)
common-1.schema.json
    /definitions/license_family Setting `type` alongside `enum` is considered an anti-pattern, as the enumeration choices already imply their respective types (enum_with_type)
common-1.schema.json
    /definitions/namespace Setting `type` alongside `enum` is considered an anti-pattern, as the enumeration choices already imply their respective types (enum_with_type)
common-1.schema.json
    /definitions/subdir Setting `type` alongside `enum` is considered an anti-pattern, as the enumeration choices already imply their respective types (enum_with_type)
info-security-1.schema.json
    /definitions/vuln_description_item_reference/properties/type Setting `type` alongside `enum` is considered an anti-pattern, as the enumeration choices already imply their respective types (enum_with_type)
info-security-1.schema.json
    /properties/$schema Setting `type` alongside `const` is considered an anti-pattern, as the constant already implies its respective type (const_with_type)
repodata-1.schema.json
    /properties/$schema Setting `type` alongside `const` is considered an anti-pattern, as the constant already implies its respective type (const_with_type)
repodata-1.schema.json
    /properties/repodata_version Setting `type` alongside `const` is considered an anti-pattern, as the constant already implies its respective type (const_with_type)
repodata-record-1.schema.json
    /properties/noarch Setting `type` alongside `enum` is considered an anti-pattern, as the enumeration choices already imply their respective types (enum_with_type)
repodata-record-1.schema.json
    /properties/record_version Setting `type` alongside `const` is considered an anti-pattern, as the constant already implies its respective type (const_with_type)

@jviotti
Copy link
Author

jviotti commented Jun 5, 2024

BTW, I also added this repo to my https://github.com/sourcemeta/awesome-jsonschema

Hey there! This is a PR to mainly start a conversation. I'm a member of
JSON Schema organization involved in maintaining various JSON Schema
related tooling (like https://alterschema.sourcemeta.com) and
documentation (like https://www.learnjsonschema.com), plus co-author of
the recently published O'Reilly book touching on JSON Schema
(https://www.oreilly.com/library/view/unifying-business-data/9781098144999/).

Based on our experience working with organizations maintaining
repositories of schemas (like you!), we've been working on an
open-source CLI tool that aims to simplify development and CI/CD when
dealing with schemas. This CLI supports a growing amount of commands,
but I'm proposing two for this repository to start with:

- Formatting: making sure your schemas following a consistent style
  (i.e. indentation) plus a consistent ordering of keywords that was
  designed to make schemas easier to read

- Linting: we are collecting common rules to highlight anti-patterns,
  common pitfalls, etc when using JSON Schema. There are not that many
  implement out there, but the linter already caught some issues

I would love to hear your feedback, feature requests, etc to help you
make better use of JSON Schema with this CLI! We also have other things
on the way, like a proper JSON Schema test runner that could eventually
automatically validate the examples in the repo.

Signed-off-by: Juan Cruz Viotti <[email protected]>
@travishathaway
Copy link

@conda-bot check

@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Status: 🆕 New
Development

Successfully merging this pull request may close these issues.

3 participants