Skip to content

--schemafile from $schema #416

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

Closed
6nv opened this issue Apr 9, 2024 · 1 comment
Closed

--schemafile from $schema #416

6nv opened this issue Apr 9, 2024 · 1 comment

Comments

@6nv
Copy link

6nv commented Apr 9, 2024

Hi, can check-jsonschema automatically detect which schema to validate against based on the value in $schema? I found --check-metaschema which is almost exactly what I want, but not quite. I want to write a pipeline to automatically validate all json files against their respective schemas without having to write a new check each time I add a new file.


a.json:

{
 "$schema": "../schema/a.json"
}

b.json:

{
 "$schema": "../schema/b.json"
}

(...you could imagine I have several more json files, each with their own schema.)

../schema/a.json

{
 "$schema": "http://json-schema.org/draft-04/schema#",
 ...
}

../schema/b.json

{
 "$schema": "http://json-schema.org/draft-04/schema#",
 ...
}

I want to write something like this:

$ check-jsonschema database/*.json
# Usage: check-jsonschema [OPTIONS] INSTANCEFILES...
# Error: Either --schemafile, --builtin-schema, or --check-metaschema must be provided

But currently I need to write this:

$ check-jsonschema --schemafile schema/a.json database/a.json
$ check-jsonschema --schemafile schema/b.json database/a.json
$ check-jsonschema --schemafile schema/c.json database/c.json
...

I tried --builtin-schema which looked promising but still not quite what I'm looking for. Do I have any options right now or is this not currently a feature of this tool? Thanks!

Might be a duplicate of #310

@6nv 6nv changed the title Value in $schema is the schema file --schemafile from $schema Apr 9, 2024
@sirosen
Copy link
Member

sirosen commented Apr 9, 2024

I think this is the same feature as requested in #310.

Current status is that I haven't been working on it. I've been stretched a bit thin since midwinter this past year and unable to make much progress on most FOSS projects. I'm going to close to consolidate with #310, but feel free to either add detail there if you think there's important information missing from that conversation, or to reopen this if you think I'm wrong and it's not a duplicate.

@sirosen sirosen closed this as completed Apr 9, 2024
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