encoding/openapi: support Definitions

Fixes #131

Change-Id: Ic7581a22dddb0c6b01707c78ea9b051abfa0e0e2
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/3584
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/encoding/openapi/testdata/cue.mod b/encoding/openapi/testdata/cue.mod
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/encoding/openapi/testdata/cue.mod
diff --git a/encoding/openapi/testdata/issue131.cue b/encoding/openapi/testdata/issue131.cue
new file mode 100644
index 0000000..5a8dd88
--- /dev/null
+++ b/encoding/openapi/testdata/issue131.cue
@@ -0,0 +1,7 @@
+package ext
+
+import "example.com/blocks"
+
+Blocks :: {
+	block1: blocks.Block
+}
diff --git a/encoding/openapi/testdata/issue131.json b/encoding/openapi/testdata/issue131.json
new file mode 100644
index 0000000..1fc5e56
--- /dev/null
+++ b/encoding/openapi/testdata/issue131.json
@@ -0,0 +1,40 @@
+{
+   "openapi": "3.0.0",
+   "info": {
+      "title": "test",
+      "version": "v1"
+   },
+   "paths": {},
+   "components": {
+      "schemas": {
+         "Blocks": {
+            "type": "object",
+            "required": [
+               "block1"
+            ],
+            "properties": {
+               "block1": {
+                  "$ref": "#/components/schemas/Block"
+               }
+            }
+         },
+         "Block": {
+            "type": "object",
+            "required": [
+               "a",
+               "b"
+            ],
+            "properties": {
+               "a": {
+                  "type": "number",
+                  "exclusiveMinimum": 50
+               },
+               "b": {
+                  "type": "number",
+                  "exclusiveMaximum": 10
+               }
+            }
+         }
+      }
+   }
+}
\ No newline at end of file
diff --git a/encoding/openapi/testdata/oneof.cue b/encoding/openapi/testdata/oneof.cue
index d318c50..768b442 100644
--- a/encoding/openapi/testdata/oneof.cue
+++ b/encoding/openapi/testdata/oneof.cue
@@ -1,10 +1,10 @@
-MyString: {
+MyString :: {
 	exact: string
 } | {
 	regex: string
 }
 
-MyInt: int
+MyInt :: int
 
 Foo: {
 	include: MyString
diff --git a/encoding/openapi/testdata/pkg/example.com/blocks/blocks.cue b/encoding/openapi/testdata/pkg/example.com/blocks/blocks.cue
new file mode 100644
index 0000000..fe9b8ce
--- /dev/null
+++ b/encoding/openapi/testdata/pkg/example.com/blocks/blocks.cue
@@ -0,0 +1,6 @@
+package blocks
+
+Block :: {
+	a: >50
+	b: <10
+}