encoding/openapi: add Info and DescriptorFunc features

Two settings added to Generator:

- Info adds the OpenAPI info section.
- DescriptorFunc allows for custom descriptions, given
  a value.

If the All API is used, an empty info section will be added
if the user hasn't given any. This is to reflect the fact
that info.version and info.title are required.

Issue #56

Change-Id: Ief29b40bf6be9c8026052588f6de9fb06d41095f
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2442
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/encoding/openapi/openapi_test.go b/encoding/openapi/openapi_test.go
index e1fd2e3..6e41e2d 100644
--- a/encoding/openapi/openapi_test.go
+++ b/encoding/openapi/openapi_test.go
@@ -20,6 +20,7 @@
 	"flag"
 	"io/ioutil"
 	"path/filepath"
+	"strings"
 	"testing"
 
 	"cuelang.org/go/cue"
@@ -30,8 +31,9 @@
 var update *bool = flag.Bool("update", false, "update the test output")
 
 func TestParseDefinitions(t *testing.T) {
+	info := OrderedMap{KeyValue{"title", "test"}, KeyValue{"version", "v1"}}
 	defaultConfig := &Config{}
-	resolveRefs := &Config{ExpandReferences: true}
+	resolveRefs := &Config{Info: info, ExpandReferences: true}
 
 	testCases := []struct {
 		in, out string
@@ -56,6 +58,18 @@
 		"openapi.cue",
 		"openapi-norefs.json",
 		resolveRefs,
+	}, {
+		"oneof.cue",
+		"oneof-funcs.json",
+		&Generator{
+			Info: info,
+			ReferenceFunc: func(inst *cue.Instance, path []string) string {
+				return strings.ToUpper(strings.Join(path, "_"))
+			},
+			DescriptionFunc: func(v cue.Value) string {
+				return "Randomly picked description from a set of size one."
+			},
+		},
 	}}
 	for _, tc := range testCases {
 		t.Run(tc.out, func(t *testing.T) {