cue icon indicating copy to clipboard operation
cue copied to clipboard

encoding/jsonschema: support native conversion from CUE to jsonschema

Open cueckoo opened this issue 3 years ago • 13 comments

Originally opened by @myitcv in https://github.com/cuelang/cue/issues/929

An issue to capture https://github.com/cuelang/cue/discussions/663

cueckoo avatar Jul 03 '21 10:07 cueckoo

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?

magick93 avatar Sep 24 '21 23:09 magick93

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

I believe that it is not natively implemented based on: https://github.com/cue-lang/cue/discussions/663#discussioncomment-960087

verdverm avatar Sep 24 '21 23:09 verdverm

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

myitcv avatar Oct 26 '21 13:10 myitcv

@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?

codewithcheese avatar Jan 19 '22 12:01 codewithcheese

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.

loewenstein avatar Mar 16 '22 16:03 loewenstein

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.

from-nibly avatar Jul 12 '22 17:07 from-nibly

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.

sdboyer avatar Feb 09 '23 11:02 sdboyer

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.

stevehipwell avatar Oct 26 '23 10:10 stevehipwell

FWIW @stevehipwell I explored the alternative of enabling native CUE support for Helm validation in https://github.com/helm/helm/compare/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.

loewenstein avatar Oct 28 '23 08:10 loewenstein

@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).

stevehipwell avatar Oct 31 '23 16:10 stevehipwell