cuelang.org/go@v0.13.0/encoding/jsonschema/testdata/txtar/list.txtar (about)

     1  -- schema.yaml --
     2  $schema: http://json-schema.org/draft-07/schema#
     3  type: object
     4  
     5  properties:
     6    foo:
     7      type: array
     8      items:
     9        type: string
    10  
    11    tuple:
    12      type: array
    13      items:
    14        - type: string
    15        - type: integer
    16        - const: 2
    17  
    18    has:
    19      type: array
    20      contains:
    21        const: 3
    22  
    23    too:
    24      type: array
    25      contains:
    26        type: string
    27  
    28    size:
    29      type: array
    30      minItems: 3
    31      maxItems: 9
    32      uniqueItems: true
    33  
    34    additional:
    35      type: array
    36      items:
    37        - type: integer
    38        - type: integer
    39      additionalItems:
    40        type: string
    41  
    42  additionalProperties: false
    43  
    44  -- out/decode/extract --
    45  import "list"
    46  
    47  @jsonschema(schema="http://json-schema.org/draft-07/schema#")
    48  
    49  close({
    50  	foo?: [...string]
    51  	tuple?: [string, int, 2, ...]
    52  	has?: list.MatchN(>=1, 3)
    53  	too?: list.MatchN(>=1, string)
    54  	size?: list.MaxItems(9) & list.UniqueItems() & [_, _, _, ...]
    55  	additional?: [int, int, ...string]
    56  })
    57  -- out/decode/testerr/err-foo-not-string --
    58  foo.0: conflicting values true and string (mismatched types bool and string):
    59      generated.cue:5:1
    60      generated.cue:6:9
    61      generated.cue:6:12
    62      test/err-foo-not-string.json:2:10
    63  -- test/empty.json --
    64  {}
    65  -- test/foo-items.json --
    66  {
    67  	"foo": ["x", "y"]
    68  }
    69  -- test/err-foo-not-string.json --
    70  {
    71  	"foo": [true]
    72  }