Skip to content

Commit 655236e

Browse files
committed
encoding/openapi: add test cases for non-empty lists
An upcoming change to the CUE API to make lists consistent with structs for concreteness exposed a reliance of encoding/openapi on the current inconsistency. It also showed that despite there being logic in encoding/openapi for dealing with non-empty lists, that logic isn't tested anyway. Add a couple of test cases so that the behavior change in the upcoming CL will be clear. Note that the results here are not actually valid in OpenAPI 3.0, which does not support the form of `items` generated here (see #3480). For #3481 Signed-off-by: Roger Peppe <rogpeppe@gmail.com> Change-Id: Ib477e11388715482d48c8101d67a47c8efc69f60 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202243 Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com> TryBot-Result: CUEcueckoo <cueckoo@cuelang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
1 parent 4ae206d commit 655236e

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

encoding/openapi/testdata/array.cue

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import "list"
77
baz?: list.UniqueItems()
88

99
qux?: list.MinItems(1) & list.MaxItems(3)
10+
11+
closedConcreteList?: [1, 2, 3]
12+
openConcreteList?: [1, 2, 3, ...]
1013
}
1114

1215
#Arrays: {

encoding/openapi/testdata/array.json

+65
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,71 @@
3030
"type": "array",
3131
"minItems": 1,
3232
"maxItems": 3
33+
},
34+
"closedConcreteList": {
35+
"type": "array",
36+
"items": [
37+
{
38+
"type": "integer",
39+
"enum": [
40+
1
41+
]
42+
},
43+
{
44+
"type": "integer",
45+
"enum": [
46+
2
47+
]
48+
},
49+
{
50+
"type": "integer",
51+
"enum": [
52+
3
53+
]
54+
}
55+
],
56+
"enum": [
57+
[
58+
1,
59+
2,
60+
3
61+
]
62+
],
63+
"default": [
64+
1,
65+
2,
66+
3
67+
]
68+
},
69+
"openConcreteList": {
70+
"type": "array",
71+
"minItems": 3,
72+
"items": [
73+
{
74+
"type": "integer",
75+
"enum": [
76+
1
77+
]
78+
},
79+
{
80+
"type": "integer",
81+
"enum": [
82+
2
83+
]
84+
},
85+
{
86+
"type": "integer",
87+
"enum": [
88+
3
89+
]
90+
}
91+
],
92+
"default": [
93+
1,
94+
2,
95+
3
96+
],
97+
"additionalItems": {}
3398
}
3499
}
35100
},

0 commit comments

Comments
 (0)