Skip to content

Commit 8e4c818

Browse files
committed
encoding/openapi: add regression test for issue 1643
The issue was opened in early 2022, since the generated OpenAPI was empty, and that has been fixed as of May 2025. It's unclear what fixed it, as it could have been the new evaluator. It doesn't really matter as long as the behavior is correct. Closes #1643. Signed-off-by: Daniel Martí <[email protected]> Change-Id: Ibf2b412e7ab5aca501ad9ccb873ae6bf7e9771b9 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1214391 Reviewed-by: Roger Peppe <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 80ff2bd commit 8e4c818

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
-- in.cue --
2+
#One:{
3+
field1: #Id,
4+
if true { #Two}
5+
}
6+
#Two: { field2: string }
7+
#Id: 1 | 2
8+
9+
-- out/TestGenerateOpenAPI/out.json --
10+
{
11+
"openapi": "3.0.0",
12+
"info": {
13+
"title": "Generated by cue.",
14+
"version": "no version"
15+
},
16+
"paths": {},
17+
"components": {
18+
"schemas": {
19+
"Id": {
20+
"type": "integer",
21+
"enum": [
22+
1,
23+
2
24+
]
25+
},
26+
"One": {
27+
"type": "object",
28+
"required": [
29+
"field1",
30+
"field2"
31+
],
32+
"properties": {
33+
"field1": {
34+
"$ref": "#/components/schemas/Id"
35+
},
36+
"field2": {
37+
"type": "string"
38+
}
39+
}
40+
},
41+
"Two": {
42+
"type": "object",
43+
"required": [
44+
"field2"
45+
],
46+
"properties": {
47+
"field2": {
48+
"type": "string"
49+
}
50+
}
51+
}
52+
}
53+
}
54+
}

0 commit comments

Comments
 (0)