This repository has been archived by the owner on Nov 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
encoding/openapi: finalise when constructing openapi AST
When building OpenAPI enums from a CUE instance, specifically one that contains an enum imported from protobuf, we don't care about the definition-encoded integer enum value (introduced as part of dcfff00). Instead we only care about the final value of the enum. Prior to dcfff00, an imported protobuf enum would look like this: #CaptureMode: "DEFAULT" | "IPTABLES" | "NONE" Post dcfff00, it looks like: #CaptureMode: { "DEFAULT" #enumValue: 0 } | { "IPTABLES" #enumValue: 1 } | { "NONE" #enumValue: 2 } Therefore, in the process of building an enum we simply need to finalise the CUE Value prior to deriving its syntax. The test as part of this CL comes from a real Istio schema that uncovered this bug in the first place. Fixes #977 Change-Id: I5b4cbb2f35b0535488d8f77b1e2166f89ed2644d Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9843 Reviewed-by: CUE cueckoo <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]>
- Loading branch information
Showing
4 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#CaptureMode: { | ||
"DEFAULT" | ||
#enumValue: 0 | ||
} | { | ||
"IPTABLES" | ||
#enumValue: 1 | ||
} | { | ||
"NONE" | ||
#enumValue: 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"openapi": "3.0.0", | ||
"info": { | ||
"title": "Generated by cue.", | ||
"version": "no version" | ||
}, | ||
"paths": {}, | ||
"components": { | ||
"schemas": { | ||
"CaptureMode": { | ||
"type": "string", | ||
"enum": [ | ||
"DEFAULT", | ||
"IPTABLES", | ||
"NONE" | ||
] | ||
} | ||
} | ||
} | ||
} |