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

result of running CLI without options? #706

Closed
sloanlance opened this issue Jul 18, 2020 · 9 comments
Closed

result of running CLI without options? #706

sloanlance opened this issue Jul 18, 2020 · 9 comments

Comments

@sloanlance
Copy link

If I run the jsonschema CLI with the name of a schema file, but I don't give any options, it doesn't seem to do anything. That is:

jsonschema schema_file.json

There's no output.

What is it doing, if anything?

@Julian
Copy link
Member

Julian commented Jul 18, 2020

Hi. With no instances specified, essentially just validating your schema.

@sloanlance
Copy link
Author

What do you think of having it validate stdin against the schema if no -i option is given?

If you like that idea, I'm interested in implementing this feature and opening a PR back to this repo.

@Julian
Copy link
Member

Julian commented Jul 18, 2020

Thanks for the offer!

That's actually already implemented :), it's just not released yet. It's on master though. Part of the reason for the release delay is I'd love some slightly further improvements to the CLI before a release, but I may not get the time, and may just have to push it out.

But certainly if you're offering to help it would be more than appreciated!

@sloanlance
Copy link
Author

I don't know what time frame you have in mind, but I'd be happy to take a look at the CLI issues (or maybe others) and see whether I can help. Can you tell me links to the issues you had in mind?

@Julian
Copy link
Member

Julian commented Jul 19, 2020

That'd be amazing! The time frame is likely less of a big deal, as unfortunately is usual at this point, at some point either enough time will go by that I'll have to release without the improvements and then add them in when they get done, or the release will keep dragging :/

As for the concrete ones, so there are definitely some (underspecified) issues that I have in mind -- #672 is one. But I think more important than adding even more output renderers is essentially cleaning up the one new one that was added. Specifically, here's some example output from the new pretty renderer:

⊙  printf '7' | jsonschema --output pretty <(printf '{"minimum": 9, "multipleOf": 3, "not": {"const": 7}}')                                                                        julian@Air
===[ValidationError]===(<stdin>)===

7 is less than the minimum of 9

Failed validating 'minimum' in schema:
    {'minimum': 9, 'multipleOf': 3, 'not': {'const': 7}}

On instance:
    7
-----------------------------
===[ValidationError]===(<stdin>)===

7 is not a multiple of 3

Failed validating 'multipleOf' in schema:
    {'minimum': 9, 'multipleOf': 3, 'not': {'const': 7}}

On instance:
    7
-----------------------------
===[ValidationError]===(<stdin>)===

{'const': 7} is not allowed for 7

Failed validating 'not' in schema:
    {'minimum': 9, 'multipleOf': 3, 'not': {'const': 7}}

On instance:
    7
-----------------------------

where some things that rub me a bit wrong visually are:

  • the width of the ascii dividers (right now it's a bit arbitrary and you can see it doesn't match between the = and - lines -- particularly so if it's a SchemaError vs a ValidationError)
  • not using unicode box characters
  • needing a bit of vertical space between each error
  • the fact that, though it's not obvious there, in the exception message, what's there is reprs of Python objects. Even though usually that's what I want shown because jsonschema normally deals with Python objects, not JSON, here that's not the case -- here in fact the reverse is true -- the CLI takes JSON, and does the deserialization itself. So when showing errors back to users of the CLI, it should show JSON, not Python objects.

Obviously the above are just some quick scribbles, which is a bit unfortunate, but maybe you see one or two small ways to make that nicer looking? Definitely happy to give some more pointers, the offer is as I say definitely appreciated!

@sloanlance
Copy link
Author

This sounds like a good first issue for me to get an idea of what this project is like internally. I've already forked the repo, so a good next step for me is to try building in my environment from the master branch.

Do you have an issue for cleaning up pretty? You could assign it to me, if you'd like. We can use comments there to communicate about it or you can contact me directly.

@Julian
Copy link
Member

Julian commented Jul 20, 2020

Awesome! There isn't an existing one -- if it's useful obviously feel free to just copy paste the above into a new one definitely sounds like a good way to communicate.

@sloanlance
Copy link
Author

I've opened #708 for this purpose.

@Julian
Copy link
Member

Julian commented Jul 24, 2020

Gonna close this one since we're discussing on #708 and the issue originally here hopefully will go out on next release.

@Julian Julian closed this as completed Jul 24, 2020
Julian added a commit that referenced this issue Jan 16, 2024
544f7c3d Merge pull request #712 from otto-ifak/main
9dad3ebe Add tests for enum with array of bool
589a0858 Merge pull request #706 from marksparkza/unevaluated-before-ref
64d5cab9 Merge pull request #710 from spacether/patch-1
418cdbd6 Removes idea folder
e0a9e066 Updates all other tests to mention grapheme/graphemes
69136952 Update minLength.json
4a2c61e8 Test unevaluatedItems|Properties before $ref

git-subtree-dir: json
git-subtree-split: 544f7c3df93b69f84f587b345f2835c380e43226
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