datacontract/datacontract-cli

JSON Schema output on stdout produces invalid JSON

Closed this issue · 3 comments

hqm42 commented

datacontract export --format jsonschema ... produced invalid json when it contains long strings (comments for example). Long strings get word wrapped at 80 characters. This prevents the output of the command to be used in other commands expecting json:

check-jsonschema --schemafile <(datacontract datacontract export --format jsonschema my_datacontract) my_data.json

This can be easily tested with jq for example:

datacontract datacontract export --format jsonschema my_datacontract | jq .

This happens when you run the application in docker. The number of columns is limited to 80.

You can use the --output option to output into a file.

duplicates #156

hqm42 commented

Thank you for the quick response!

If there was a --quiet option to disable info logging, I could prevent creating temp files and use /dev/stdout as a parameter for --output. Right now I get this:

$ datacontract export --format jsonschema --output /dev/stdout my_datacontract
{
  // json schema
}Written result to /dev/stdout

Logging the info "Written result to /dev/stdout" to stderr instead of stdout would be an easy fix for this too.