cue: Elem should return unevaluated value

This is tested in the openapi package

Change-Id: Idaadf085626de0d5a067b02d97b8da54510aacf0
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2347
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/types.go b/cue/types.go
index c05ca61..54e2c88 100644
--- a/cue/types.go
+++ b/cue/types.go
@@ -917,7 +917,7 @@
 // Elem returns the value of undefined element types of lists and structs.
 func (v Value) Elem() (Value, bool) {
 	ctx := v.ctx()
-	switch x := v.path.cache.(type) {
+	switch x := v.path.v.(type) {
 	case *structLit:
 		if x.template == nil {
 			break
diff --git a/encoding/openapi/openapi_test.go b/encoding/openapi/openapi_test.go
index 4f0542a..2376a40 100644
--- a/encoding/openapi/openapi_test.go
+++ b/encoding/openapi/openapi_test.go
@@ -43,6 +43,10 @@
 		in, out string
 		config  *Config
 	}{{
+		"oneof.cue",
+		"oneof.json",
+		defaultConfig,
+	}, {
 		"openapi.cue",
 		"openapi.json",
 		defaultConfig,
diff --git a/encoding/openapi/testdata/oneof.cue b/encoding/openapi/testdata/oneof.cue
new file mode 100644
index 0000000..d318c50
--- /dev/null
+++ b/encoding/openapi/testdata/oneof.cue
@@ -0,0 +1,13 @@
+MyString: {
+	exact: string
+} | {
+	regex: string
+}
+
+MyInt: int
+
+Foo: {
+	include: MyString
+	exclude: [...MyString]
+	count: MyInt
+}
diff --git a/encoding/openapi/testdata/oneof.json b/encoding/openapi/testdata/oneof.json
new file mode 100644
index 0000000..b805d2e
--- /dev/null
+++ b/encoding/openapi/testdata/oneof.json
@@ -0,0 +1,59 @@
+{
+   "openapi": "3.0.0",
+   "components": {
+      "schema": {
+         "MyString": {
+            "anyOf": [
+               {
+                  "type": "object",
+                  "required": [
+                     "exact"
+                  ],
+                  "properties": {
+                     "exact": {
+                        "type": "string"
+                     }
+                  }
+               },
+               {
+                  "type": "object",
+                  "required": [
+                     "regex"
+                  ],
+                  "properties": {
+                     "regex": {
+                        "type": "string"
+                     }
+                  }
+               }
+            ]
+         },
+         "MyInt": {
+            "type": "integer"
+         },
+         "Foo": {
+            "type": "object",
+            "required": [
+               "include",
+               "exclude",
+               "count"
+            ],
+            "properties": {
+               "count": {
+                  "$ref": "#/components/schema/MyInt"
+               },
+               "exclude": {
+                  "type": "array",
+                  "items": {
+                     "$ref": "#/components/schema/MyString"
+                  },
+                  "default": []
+               },
+               "include": {
+                  "$ref": "#/components/schema/MyString"
+               }
+            }
+         }
+      }
+   }
+}
\ No newline at end of file