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

JSON Schema validation #1

Closed
garethsb opened this issue Nov 7, 2019 · 2 comments
Closed

JSON Schema validation #1

garethsb opened this issue Nov 7, 2019 · 2 comments

Comments

@garethsb
Copy link
Contributor

garethsb commented Nov 7, 2019

Follow-up to AMWA-TV/is-template#3.

In addition to the basic JSON linting performed as part of the CI, it would great to:

  • validate each example file in the examples/ directory in each spec repo against the appropriate schema in the APIs/schemas/ directory
  • validate each schema in the APIs/schemas/ directory against the meta schema (http://json-schema.org/draft-04/schema)

This would have prevented several mistakes previously made during schema design and spec version ups. Seems like there are several reasonable looking JSON Schema engines that could be used during CI.

Tricky bit is identifying which schema should be used to validate which example file, because our JSON formats do not contain embedded metadata to indicate that (and indeed that's recommended practice - instead, out-of-band mechanisms like Link response headers or IANA media-type parameters are usually needed).

We could rely on the RAML type indication but we'd have to make sure all files in examples/ were referenced from the RAML (or at least only validate the ones that were). Unused examples may be a mistake anyway...

The other obvious approach would rely on a .schemas.json file in each repo that simply mapped instances in examples/ to schemas in APIs/schemas, and error if the filenames didn't match up.

@garethsb
Copy link
Contributor Author

This issue should probably be in https://github.com/AMWA-TV/nmos-lint-scripts now...

I just managed to do some schema file renames that left a $ref or two pointing at nonexistent files. I suppose that a JSON Schema checker would have caught this.

@peterbrightwell
Copy link
Contributor

Moving this to AMWA-TV/nmos-lint-scripts#6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants