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

Add YAML support #91

Closed
jviotti opened this issue Jun 14, 2024 · 12 comments · Fixed by #212
Closed

Add YAML support #91

jviotti opened this issue Jun 14, 2024 · 12 comments · Fixed by #212

Comments

@jviotti
Copy link
Member

jviotti commented Jun 14, 2024

No description provided.

@UnleashSpirit
Copy link

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

@jviotti
Copy link
Member Author

jviotti commented Jul 1, 2024

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

@akselerando
Copy link

YAML support would be much appreciated!

@robbat2
Copy link

robbat2 commented Nov 6, 2024

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

@jviotti
Copy link
Member Author

jviotti commented Nov 6, 2024

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
Copy link

robbat2 commented Nov 9, 2024

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 jbeder/yaml-cpp#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
https://github.com/tlsa/libcyaml ISC libyaml & make most active library I can see

@jviotti
Copy link
Member Author

jviotti commented Nov 11, 2024

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

jviotti added a commit to sourcemeta/core that referenced this issue Jan 14, 2025
jviotti added a commit to sourcemeta/core that referenced this issue Jan 14, 2025
jviotti added a commit to sourcemeta/core that referenced this issue Jan 14, 2025
jviotti added a commit to sourcemeta/core that referenced this issue Jan 14, 2025
jviotti added a commit to sourcemeta/core that referenced this issue Jan 14, 2025
jviotti added a commit to sourcemeta/core that referenced this issue Jan 14, 2025
jviotti added a commit to sourcemeta/core that referenced this issue Jan 14, 2025
jviotti added a commit to sourcemeta/core that referenced this issue Jan 14, 2025
jviotti added a commit to sourcemeta/core that referenced this issue Jan 14, 2025
jviotti added a commit to sourcemeta/core that referenced this issue Jan 14, 2025
jviotti added a commit to sourcemeta/core that referenced this issue Jan 14, 2025
jviotti added a commit to sourcemeta/core that referenced this issue Jan 14, 2025
jviotti added a commit to sourcemeta/core that referenced this issue Jan 14, 2025
jviotti added a commit to sourcemeta/core that referenced this issue Jan 14, 2025
jviotti added a commit that referenced this issue Jan 15, 2025
Fixes: #91
Signed-off-by: Juan Cruz Viotti <[email protected]>
jviotti added a commit that referenced this issue Jan 15, 2025
Fixes: #91
Signed-off-by: Juan Cruz Viotti <[email protected]>
jviotti added a commit that referenced this issue Jan 15, 2025
Fixes: #91
Signed-off-by: Juan Cruz Viotti <[email protected]>
@jviotti
Copy link
Member Author

jviotti commented Jan 15, 2025

@robbat2 Thanks for the help again! I implemented basic YAML interoperability support based in libyaml here: https://github.com/sourcemeta/jsontoolkit/tree/main/src/yaml.

The next version of this CLI, which I hope to release in a bit, will include YAML support in most commands, with the exception of fmt and the --fix option in lint. Hopefully we can make those work once I add support for converting back into YAML.

@jviotti
Copy link
Member Author

jviotti commented Jan 15, 2025

Done! Check out v5.0.0 (https://github.com/sourcemeta/jsonschema/releases/tag/v5.0.0) and please let me know if you encounter any issues! 🙏🏻

@robbat2
Copy link

robbat2 commented Jan 22, 2025

@jviotti thank you for this! It makes a huge improvement in our tooling.

@jviotti
Copy link
Member Author

jviotti commented Jan 22, 2025

Glad to hear that @robbat2 ! What tooling are you working on btw? Would love to learn more and how we can continue improving this CLI to solve any challenge you have!

@robbat2
Copy link

robbat2 commented Jan 22, 2025

This replaces most of https://github.com/RoadieHQ/roadie-backstage-plugins/tree/main/utils/roadie-backstage-entity-validator - converting code-based checks into pure JSONSchema

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

Successfully merging a pull request may close this issue.

4 participants