You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please consider adding line numbers to the output when schema validation errors are detected.
It would be much easier to locate errors when running as a pre-commit hook, especially in big JSON files.
The text was updated successfully, but these errors were encountered:
Although I'd like to offer this, I'm not sure how it would be possible today. We'd need a line number recorded during parsing -- perhaps there's a suitable JSON parser -- and then we'd need to get those line numbers back from the jsonschema library.
There are two research areas here, and we need to be confident that both parts will succeed before trying anything. Help and information about how to preserve this information from the parse and associate it with validation errors would be welcome.
@sirosen
Well, I did some research, and it seems that tools like VS Code are able to show (underline) errors in the JSON file when validating against a schema file, so I assumed that this information is already in the parser.
But event if it is not, clearly it is implemented in yaml-language-server, which claims to be using JSON Schema specification, exactly as the jsonschema library (although different implementation for sure). So maybe the research you are talking about has already been completed, and we need only porting of the same solution?
Neither of those products are implemented in Python, which check-jsonschema is, so the fact that they have such capabilities isn't really topical or useful for this project.
The JSON parser in the Python stdlib doesn't preserve line numbers (and has no extension point for doing so). It is possible to do this with alternative parsers -- but most of them are many times slower, and several of the available implementations are abandonware.
If there is a Python or Rust parser with the right characteristics (correct, fast, currently maintained), I could look into using it. But it's only even worth doing so if the information can be returned from jsonschema on ValidationErrors.
Please consider adding line numbers to the output when schema validation errors are detected.
It would be much easier to locate errors when running as a pre-commit hook, especially in big JSON files.
The text was updated successfully, but these errors were encountered: