sourcemeta / jsonschema

The CLI for working with JSON Schema. Covers formatting, linting, testing, bundling, and more for both local development and CI/CD pipelines
GNU Affero General Public License v3.0
64 stars 7 forks source link

Add YAML support #91

Open jviotti opened 5 months ago

UnleashSpirit commented 4 months ago

Need it too, VSCode extension YAML of redhat does it but we need a cli docker tool for CI :)

jviotti commented 4 months ago

I'm on vacations at the moment, but I'll take care of it very soon!

akselerando commented 2 weeks ago

YAML support would be much appreciated!

robbat2 commented 1 week ago

another +1 on yaml; to save the yq conversion before running jsonschema

jviotti commented 1 week ago

I promise I'll get into it soon! I gave it a shot back then, but correctly implementing commands like fmt on YAML proved to be a bit of a challenge. I think I'll implement it at least for the commands that it's easier to do as a first step. If you are aware of a YAML parser/stringifier in C/C++ that is dependency-free, please let me know!

robbat2 commented 1 week ago

I promise I'll get into it soon! I gave it a shot back then, but correctly implementing commands like fmt on YAML proved to be a bit of a challenge. I think I'll implement it at least for the commands that it's easier to do as a first step.

I agree fmt is a challenge, but maybe leave that out as a later part. Focusing on reading / convert to JSON / validate. There are a lot of options & ways to format YAML that are all "correct" but stylistic choices that make more sense in some documents than others (e.g. a short array being inlined, but a longer array being split over lines).

If you are aware of a YAML parser/stringifier in C/C++ that is dependency-free, please let me know! Quick research for you:

project license dependencies notes
https://github.com/jbeder/yaml-cpp MIT cmake not maintained anymore? concerns about const-correctness https://github.com/jbeder/yaml-cpp/issues/1275
https://github.com/pantoniou/libfyaml/ MIT+GPL2+BSD-2-Clause xxhash bundled not sure how alive upstream is
https://pyyaml.org/wiki/LibYAML MIT cmake make "stable"
https://github.com/tlsa/libcyaml ISC libyaml & make most active library I can see
jviotti commented 1 week ago

Thanks a lot for the research @robbat2 ! Worth giving libYAML and libcyaml a shot