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

--verbose doesn't seem to be anymore verbose than without it #266

Closed
cidrbl0ck opened this issue May 16, 2023 · 3 comments
Closed

--verbose doesn't seem to be anymore verbose than without it #266

cidrbl0ck opened this issue May 16, 2023 · 3 comments
Labels
question Further information is requested

Comments

@cidrbl0ck
Copy link

First time using this tool so here goes: Syntax as follows

Schema validation errors were encountered.
  /tmp/inventory.json::$: 'all', 'firewalls', 'not_set', 'routers', 'switches', 'ups', 'wlc' do not match any of the regexes: '^\\w$', '_meta'```

```check-jsonschema -v --schemafile ./inventory_script_schema.json /tmp/inventory.json
Schema validation errors were encountered.
  /tmp/inventory.json::$: 'all', 'firewalls', 'not_set', 'routers', 'switches', 'ups', 'wlc' do not match any of the regexes: '^\\w$', '_meta'```

So Ill admit, I'n entirely clueless as to what the root problem is in my schema file, however unless I'm doing it wrong I expected more information from a `-v/--verbose`

Adding the `-v/--verbose` to the end did not return anything different.
@sirosen sirosen added the question Further information is requested label May 16, 2023
@sirosen
Copy link
Member

sirosen commented May 16, 2023

I'n entirely clueless as to what the root problem is in my schema file, however unless I'm doing it wrong I expected more information from a -v/--verbose

This puts me in a difficult position with respect to answering your question or regarding it as resolved.

-v/--verbose has significant impact on output in some cases, but not in others.
If schema validation encountered multiple errors, not all of them would be printed. But --verbose enables full output of all errors.

Let me break down the error message for you a little bit to help:

/tmp/inventory.json::$: 'all', 'firewalls', 'not_set', 'routers', 'switches', 'ups', 'wlc' do not match any of the regexes: '^\w$', '_meta'

  1. /tmp/inventory.json is the instance being checked.
  2. :: is a delimiter
  3. $ is the JSON Path within the instance to the failing component. $ in JSON Path means "the root of the document"
  4. : is another delimiter
  5. The rest of this is the message from the validation library, unmodified
    a. 'all', 'firewalls', 'not_set', 'routers', 'switches', 'ups', 'wlc' do not match any of the regexes might indicate a failure to match patternProperties? I'm guessing without seeing the schema or instance
    b. '^\\w$', '_meta' these two strings are apparently regexes in your schema (again, I'm guessing patternProperties)

-v or -vv could be made to turn on other behaviors, and I'm open to suggestions. It's only really been tuned for a couple of use-cases thusfar.
The only constraint I'll note is that I don't think we want it to reformat the existing output -- it should only add new lines of output.

@cidrbl0ck
Copy link
Author

Thanks @sirosen I know this is not an appropriate place to ask for help in resolving the problem with my json or schema files. I just wanted to ensure that either:
A: I was invoking verbosity correctly or
B: That the flag was working at is should.

Not having any prior experience using the tool makes me a poor source of suggestions for really anything potential changes. So I guess in this case, if you believe that -v is doing what it should then my question is solved, and now I just need to dig elsewhere.

@sirosen
Copy link
Member

sirosen commented May 17, 2023

Okay, I'm going to close this. If you continue using check-jsonschema (and I hope you do!) and have ideas later for more output that you'd like from --verbose, feel free to circle back with a new feature request. I'm always open to ideas.

If you're looking for a place to learn more about JSON Schema, you might want to visit the community Slack, which is very active. Spec maintainers often answer questions about how to structure schemas there.
There are also other validators you could try out to get another view of your schema and data. For example, there's a very cool fully in-browser one: https://json-everything.net/
(json-everything is made by one of the JSON Schema maintainers)

@sirosen sirosen closed this as completed May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants