encoding/openapi: support nested defintitions
This perpares for Protobuf remodeling, where the nested
definitions of protobufs are are also nested within the
corresponding CUE types.
- Use Dereference
- Get comments from definitions, not fields, if applicable
- Allow embedded closed disjunctions.
- Allow nested types.
- Don't expand array element references.
Note that this removes the simplification in the openapi.cue
test: nested closed structs were not handled correctly by
this optimization.
Change-Id: Ie6adf44b37ac72139e21539094df5a728a309bd1
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/5405
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/encoding/openapi/testdata/oneof.cue b/encoding/openapi/testdata/oneof.cue
index 6fa37d4..a78285d 100644
--- a/encoding/openapi/testdata/oneof.cue
+++ b/encoding/openapi/testdata/oneof.cue
@@ -47,9 +47,15 @@
a?: int
close({}) |
- close({b: int}) |
+ close({b: T}) |
close({c: int})
+ T :: {b?: int}
+
+ close({}) |
+ close({d: T}) |
+ close({e: int})
+
// TODO: maybe support builtin to write this as
// oneof({},
// {b: int},