cuelang.org/go@v0.13.0/encoding/openapi/testdata/array.txtar (about)

     1  -- in.cue --
     2  import "list"
     3  
     4  #Arrays: {
     5  	bar?: [...#MyEnum]
     6  	foo?: [...#MyStruct]
     7  
     8  	baz?: list.UniqueItems()
     9  
    10  	qux?: list.MinItems(1) & list.MaxItems(3)
    11  
    12  	closedConcreteList?: [1, 2, 3]
    13  	openConcreteList?: [1, 2, 3, ...]
    14  }
    15  
    16  #Arrays: {
    17  	bar?: [...#MyEnum]
    18  	foo?: [...#MyStruct]
    19  }
    20  
    21  // MyStruct
    22  #MyStruct: {
    23  	a?: int
    24  	e?: [...#MyEnum]
    25  	e?: [...#MyEnum]
    26  }
    27  
    28  // MyEnum
    29  #MyEnum: *"1" | "2" | "3"
    30  
    31  -- out/TestGenerateOpenAPI/out.json --
    32  {
    33     "openapi": "3.0.0",
    34     "info": {
    35        "title": "Generated by cue.",
    36        "version": "no version"
    37     },
    38     "paths": {},
    39     "components": {
    40        "schemas": {
    41           "Arrays": {
    42              "type": "object",
    43              "properties": {
    44                 "bar": {
    45                    "type": "array",
    46                    "items": {
    47                       "$ref": "#/components/schemas/MyEnum"
    48                    }
    49                 },
    50                 "foo": {
    51                    "type": "array",
    52                    "items": {
    53                       "$ref": "#/components/schemas/MyStruct"
    54                    }
    55                 },
    56                 "baz": {
    57                    "type": "array",
    58                    "uniqueItems": true
    59                 },
    60                 "qux": {
    61                    "type": "array",
    62                    "minItems": 1,
    63                    "maxItems": 3
    64                 },
    65                 "closedConcreteList": {
    66                    "type": "array",
    67                    "items": [
    68                       {
    69                          "type": "integer",
    70                          "enum": [
    71                             1
    72                          ]
    73                       },
    74                       {
    75                          "type": "integer",
    76                          "enum": [
    77                             2
    78                          ]
    79                       },
    80                       {
    81                          "type": "integer",
    82                          "enum": [
    83                             3
    84                          ]
    85                       }
    86                    ],
    87                    "default": [
    88                       1,
    89                       2,
    90                       3
    91                    ]
    92                 },
    93                 "openConcreteList": {
    94                    "type": "array",
    95                    "minItems": 3,
    96                    "items": [
    97                       {
    98                          "type": "integer",
    99                          "enum": [
   100                             1
   101                          ]
   102                       },
   103                       {
   104                          "type": "integer",
   105                          "enum": [
   106                             2
   107                          ]
   108                       },
   109                       {
   110                          "type": "integer",
   111                          "enum": [
   112                             3
   113                          ]
   114                       }
   115                    ],
   116                    "default": [
   117                       1,
   118                       2,
   119                       3
   120                    ],
   121                    "additionalItems": {}
   122                 }
   123              }
   124           },
   125           "MyEnum": {
   126              "description": "MyEnum",
   127              "type": "string",
   128              "enum": [
   129                 "1",
   130                 "2",
   131                 "3"
   132              ],
   133              "default": "1"
   134           },
   135           "MyStruct": {
   136              "description": "MyStruct",
   137              "type": "object",
   138              "properties": {
   139                 "a": {
   140                    "type": "integer"
   141                 },
   142                 "e": {
   143                    "type": "array",
   144                    "items": {
   145                       "$ref": "#/components/schemas/MyEnum"
   146                    }
   147                 }
   148              }
   149           }
   150        }
   151     }
   152  }