Skip to content

Commit 5fb793d

Browse files
mvdancueckoo
authored andcommitted
encoding/openapi: add regression test for a fixed issue
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 Dispatch-Trailer: {"type":"trybot","CL":1214391,"patchset":1,"ref":"refs/changes/91/1214391/1","targetBranch":"master"}
1 parent 3ba376f commit 5fb793d

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
+54
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)