encoding/jsonschema: initial JSON Schema to CUE conversion

This does not yet introduce the API, but merely the
conversion of JSON Schema to CUE.
Also, several things, like formats, are not yet supported.

Note that the input to the conversion is CUE itself.
This allows any of the encodings (like YAML or JSON)
to be used as a base. The conversion will preserve line
information from the original file. That is, if a YAML file
was converted to CUE, which is then converted to OpenAPI, the line information in the resulting AST
corresponds to the original YAML.

Change-Id: I512502ce3d98443a530e75f606ca3c533b0c4299
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/4604
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/encoding/jsonschema/testdata/def.txtar b/encoding/jsonschema/testdata/def.txtar
new file mode 100644
index 0000000..d5d92e9
--- /dev/null
+++ b/encoding/jsonschema/testdata/def.txtar
@@ -0,0 +1,63 @@
+// This test tests the conversion and ordering of definitions.
+
+-- definition.json --
+{
+  "$schema": "http://json-schema.org/draft-07/schema#",
+
+  "$id": "http://cuelang.org/go/encoding/openapi/testdata/order.json",
+
+  "definitions": {
+    "address": {
+      "type": "object",
+      "properties": {
+        "street_address": { "type": "string" },
+        "city":           { "type": "string" },
+        "state":          { "type": "string" }
+      },
+      "required": ["street_address", "city", "state"]
+    },
+    "person": {
+      "type": "object",
+      "properties": {
+        "name": { "type": "string" },
+        "children": {
+          "type": "array",
+          "items": { "$ref": "#/definitions/person" },
+          "default": []
+        }
+      }
+    }
+  },
+
+  "type": "object",
+
+  "properties": {
+    "person": { "$ref": "#/definitions/person" },
+    "billing_address": { "$ref": "#/definitions/address" },
+    "shipping_address": { "$ref": "#/definitions/address" }
+  }
+}
+
+-- out.cue --
+package def
+
+Schema :: _ @jsonschema(schema="http://json-schema.org/draft-07/schema#",id="http://cuelang.org/go/encoding/openapi/testdata/order.json")
+Schema :: {
+	person?:           def.person
+	billing_address?:  def.address
+	shipping_address?: def.address
+	...
+}
+
+def: address :: {
+	street_address: string
+	city:           string
+	state:          string
+	...
+}
+
+def: person :: {
+	name?: string
+	children?: [...def.person]
+	...
+}