Add --keywords option to inspect command - #828
Conversation
|
|
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
8c15b64 to
a9a26a8
Compare
Count and print the occurrences of each JSON Schema keyword in a schema, grouped by vocabulary, using the existing SchemaIterator utility. The --keywords option cannot be combined with --json. Ref: sourcemeta#227 Signed-off-by: Nariman Sayed <narimansayed28@gmail.com>
There was a problem hiding this comment.
Note that on main we largely replaced the shell tests with a new .clitest runner format. Can you adopt those?
There was a problem hiding this comment.
Let's have tests for this in conjunction with --json?
There was a problem hiding this comment.
Let's have tests for this in conjunction with
--json?
I added fail_keywords_with_json.clitest for the --keywords + --json conflict case - let me know if you meant something else here.
|
Seems like CI is failing on a few OSes! |
Replace the old shell-script tests with the new .clitest DSL format used across the rest of the test suite, per review feedback. Also update the three help output .clitest fixtures to include the new --keywords/-k flag documentation. Signed-off-by: Nariman Sayed <narimansayed28@gmail.com>
a9a26a8 to
326fee2
Compare
| } | ||
|
|
||
| if (options.contains("keywords") && options.contains("json")) { | ||
| throw OptionConflictError{ |
There was a problem hiding this comment.
@Nariman-Sayed Can we actually support --json? The entire command does support it (as almost every other command in the tool). In this case, we can present the same keyword summary, but print it as a JSON object or something like that.
There was a problem hiding this comment.
Would be nice to have a test showing the schema from standard input too?
There was a problem hiding this comment.
Also maybe one that has unknown keywords. Also one where you pass a boolean schema, or a schema that is the empty object (in conjunction with --default-dialect). Overall thinking edge cases. Let's try to actually cover this feature in tests to try to surface any bug
Closes #227
Adds a
--keywordsflag toinspectthat counts keyword occurrences in a schema grouped by vocabulary, based on the approach in https://github.com/sourcemeta-research/jsonschema-keywordsUses SchemaIterator to walk the schema and count keywords per vocabulary. Made it conflict with --json since I wasn't sure how to combine keyword stats with the existing json output format, let me know if you had something else in mind.
Added tests for the normal case and the --json conflict, and updated the docs.