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

encoding/jsonschema: support native conversion from CUE to jsonschema #929

Open
cueckoo opened this issue Jul 3, 2021 · 11 comments
Open

Comments

@cueckoo
Copy link
Collaborator

cueckoo commented Jul 3, 2021

Originally opened by @myitcv in cuelang/cue#929

An issue to capture cuelang/cue#663

@magick93
Copy link

Hello

As encoding/jsonschema: support native conversion from CUE to jsonschema cuelang/cue#929 is closed, does that mean there is now support for generating jsonschema?

@verdverm
Copy link

The issue was closed on the old repository and has been copied here.

I believe that it is not natively implemented based on: #663 (reply in thread)

@myitcv
Copy link
Member

myitcv commented Oct 26, 2021

@verdverm is correct. This issue exists in order to capture the missing export capability for JSONSchema.

@codewithcheese
Copy link

@myitcv @mpvl I am interested in working on this jsonschema codec if possible. Is it correct that the openapi schema implementation could be extracted out as a jsonschema encoder? Has there been any further design work on how to implement the jsonschema codec that I should be aware about? Is the current implementation style still favored or do you have a better approach in mind?

@loewenstein
Copy link

I’d be interested to be able to round-trip jsonschema -> cue -> jsonschema natively in cue.

My use case being that Helm supports jsonschema to validate provided values, we have a Helm chart that already has a schema defined and I’d like to try out cue as the source of truth.

Hence, I’d like to cue import the schema, work on the cue file henceforth and derive a schema that the Helm chart then uses for validating user input.

@from-nibly
Copy link

I'm working on a schema registry for my company and would like to have cuelang be the source of truth but serve up jsonschema for compatibility with various services. Having this built into the cue cli would allow us to make that all happen with culang tool commands really easily.

@sdboyer
Copy link

sdboyer commented Feb 9, 2023

FWIW the JSON Schema encoding package in Thema amounts to a generic CUE->JSON Schema converter - it takes OpenAPI 3.0 output (as produced by the cue stdlib openapi encoder) and transforms it to be valid JSON Schema.

There are some knotty bits we're still working out, primarily grafana/thema#99, but the logic has seen use in part of larger production code generation pipelines.

@stevehipwell
Copy link

Similar to @loewenstein I'm interested in this as part of a Helm solution. I'd like to POC a Helm plugin to treat cue as the source of truth for a Helm chart and use it to generate the YAML values and JSON schema prior to publishing.

@loewenstein
Copy link

FWIW @stevehipwell I explored the alternative of enabling native CUE support for Helm validation in helm/helm@main...loewenstein:helm:cue

I didn't proceed any further yet, as neither the Helm nor the CUE community seemed very interested.
Validation should be a pretty low hanging fruit if Helm maintainers would accept an additional explicit language for value validation.
I also started exploring replacing gotemplate as the templating language with CUE, but that's is likely to be more involved.

@stevehipwell
Copy link

@loewenstein this probably falls more into the security area. Personally I'd like to keep the DX of being able to easily modify chart values while being able to lock them down with a schema at point of publishing. For example I'd like image digests to be fixed in the schema with the repo location customisable; for debug usage the ignore schema flag could be used. Longer term helm could nativity support this but a simple plugin to run pre-publish could add functionality without needing any changes to Helm (it could also generate Artifact Hub metadata).

@konsalex
Copy link

+1 for this feature. It is really nice also for having the runtime validation in CUE, but produce assets that enable IDE autocomplete, which is where JSONschema has really good adoption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests