File: ref.txtar

package info (click to toggle)
golang-github-cue-lang-cue 0.12.0.-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,072 kB
  • sloc: sh: 57; makefile: 17
file content (111 lines) | stat: -rw-r--r-- 2,868 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// This test tests the conversion and ordering of $defs.

#noverify

-- schema.json --
{
  "$schema": "http://json-schema.org/draft-07/schema#",

  "$id": "http://cuelang.org/go/encoding/openapi/testdata/order.json",

  "$defs": {
    "address": {
      "type": "object",
      "properties": {
        "city": { "type": "string" }
      }
    },
    "int": {
      "type": "integer"
    },
    "string-int": {
      "type": [ "integer", "string" ]
    },
    "person": {
      "type": "object",
      "properties": {
        "name": { "type": "string" },
        "children": {
          "type": "object",
          "properties": {
              "x": { "$ref": "http://acme.com/external.json#/properties/foo" },

              "a": { "$ref": "#/$defs/int" },
              "b": { "$ref": "http://cuelang.org/person.json#/$defs/int" },
              "c": { "$ref": "http://cuelang.org/go/encoding/openapi/testdata/order.json#/$defs/int" },
              "d": { "$ref": "http://cuelang.org/go/encoding/openapi/testdata/order.json#/$defs/address" },
              "e": { "$ref": "http://cuelang.org/go/encoding/openapi/testdata/order.json#/$defs/string-int" },
              "f": { "$ref": "http://cuelang.org/person.json" },
              "g": { "$ref": "http://acme.com/external.json#/definitions/foo" },
              "h": { "$ref": "http://acme.com/external.json#/properties/foo" },
              "i": { "$ref": "http://acme.com/external.json" },
              "j": { "$ref": "http://acme.com/external-foo.json" },
              "k": { "$ref": "http://acme.com/external-bar.json" },
              "z": {}
          }
        }
      },
      "$id": "http://cuelang.org/person.json",
      "$defs": {
        "int": {
          "type": "integer"
        }
      }
    }
  },

  "type": "object",

  "properties": {
    "person": { "$ref": "#/$defs/person" },
    "billing_address": { "$ref": "#/$defs/address" },
    "shipping_address": { "$ref": "#/$defs/address" }
  }
}

-- out/decode/extract --
import (
	"acme.com/external.json:external"
	"acme.com/external-foo.json:schema"
	schema_1 "acme.com/external-bar.json:schema"
)

@jsonschema(schema="http://json-schema.org/draft-07/schema#")
@jsonschema(id="http://cuelang.org/go/encoding/openapi/testdata/order.json")
person?:           #person
billing_address?:  #address
shipping_address?: #address

#: "string-int": int | string

#address: {
	city?: string
	...
}

#int: int

#person: {
	@jsonschema(id="http://cuelang.org/person.json")
	name?: string
	children?: {
		x?: external._#defs."/properties/foo"
		a?: _#defs."/$defs/person/$defs/int"
		b?: _#defs."/$defs/person/$defs/int"
		c?: #int
		d?: #address
		e?: #."string-int"
		f?: #person
		g?: external.#foo
		h?: external._#defs."/properties/foo"
		i?: external
		j?: schema
		k?: schema_1
		z?: _
		...
	}
	...
}

_#defs: "/$defs/person/$defs/int": int
...