Open gotwarlost opened 1 year ago
I'd posit that a better CUE attribute would be @openapi(...)
which could support a variety of options, @extension
sounds a bit too generic for people to look at and understand what it is for
@openapi(extension:"x-name=value",extension:x-foo:bar)
works for me. Just need to get the functionality :)
Is your feature request related to a problem? Please describe.
I'm trying to create openAPI schemas from cue schemas and this works well. One limitation of the exporter is that there is no way to add extensions to the generated schema.
See: https://swagger.io/docs/specification/openapi-extensions/
The specific use-case that I'm struggling with is to declare an open struct in a Kubernetes CRD schema. Kubernetes will not allow an empty object spec unless it also has the extension
x-kubernetes-preserve-unknown-fields
set totrue
.Describe the solution you'd like
I'd like a way to tag a field in a cue schema such that the schema generator can write the extension when generating the type definition in openAPI.
Seems to me that this is expressed best as a cue attribute of the form
@extension("x-name=value")
which the openAPI exporter respects and emits in its output.Describe alternatives you've considered
There is no workaround for this at the cue level. I have a horrible
sed
hack that looks like this:Additional context
I think the above is self-explanatory. If not, please let me know.