How to get the diff between two CUE files? #725
-
Hi, In the project I am working on, we want to remove the default value from the API response (if the value in the response is the same as the default for the field). Now the API is defined in CUE, is there any way to do it efficiently? Maybe some operation like XOR between the 2 cue files? For example rules.cue {
address: string | *"1.2.3.4"
port: int | *8888
protocol: "udp"|*"tcp"
custom: string
// foo: 2 // uncomment this to get an error
} input.json {
"address": "1.2.3.4",
"port": 8888,
"protocol": "udp",
"custom": "1234"
} output.json {
"protocol": "udp",
"custom": "1234"
} Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
This is something that It always good to do a diff of the result as a sanity check. There is also a semantic diff package, but that is as of yet internal. The plan is to expose that though at some point. |
Beta Was this translation helpful? Give feedback.
-
This discussion has been migrated to cue-lang/cue#725. For more details about CUE's migration to a new home, please see cue-lang/cue#1078. |
Beta Was this translation helpful? Give feedback.
This is something that
cue trim
does. This is also available as a Go package in the repo undertools/trim
.It always good to do a diff of the result as a sanity check. There is also a semantic diff package, but that is as of yet internal. The plan is to expose that though at some point.