-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go codegen using joinSchema creates an empty interface #124
Comments
Some more info after messing around trying to bypass this issue by hacking the values in the CUE linage at runtime before the codegen: using the Example: metadataVal := g.rt.Context().CompileString(`{
uid: string
finalizers: [...string]
}`)
sch := parsedLin.First()
for sch != nil {
v = v.FillPath(cue.MakePath(cue.Str("lineage"), cue.Str("seqs"), cue.Index(int(sch.Version()[0])), cue.Str("schemas"), cue.Index(int(sch.Version()[1])), cue.Str("metadata")), metadataVal)
sch = sch.Successor()
}
st := cueFmtState{} // have to use this with v.Format, because a fmt.Println(v) doesn't show the whole picture
v.Format(&st, 'v')
fmt.Println("under: ", string(st.Bytes())) Standard out:
This is similar to printing the value from the joinSchema, within {
metadata: {
uid: string
finalizers: [...string]
}
spec: {...}
[string]: {...}
}
With a schema of: {
spec: {
title: string
description: string
status: string
foo: [...string]
}
metadata: {
foo: string
}
status: {
foo: string
}
} Produces this
So it seems likely that the problem comes from having joined objects in the codegen. Interestingly, doing a {
uid: string
foo: string
finalizers: [...string]
...
} So it seems possible that the problem is actually in the cue |
OK, so the problem comes down to this: the openAPI encoder merges the openapi: 3.0.0
info:
title: Metadata
version: "0.0"
paths: {}
components:
schemas:
Metadata:
type: object
properties:
uid:
type: string
finalizers:
type: array
items:
type: string
foo:
description: 'bar: bool'
type: string
allOf:
- required:
- uid
- finalizers
- required:
- foo It doesn't seem 100% clear to me from the openAPI docs if this is a correct usage of allOf, but it does render properly in the swagger editor. In any case, deepmap/oapi-codegen treats |
It looks like there is an open issue and related PR in deepmap/oapi-codegen to resolve this issue with |
One quick comment - it occurs to me that we could resolve this issue, by deciding #76 in the direction of saying that This would make lineage authoring less magical, which i think could improve UX. |
I think this is probably the straw that leads us to fork oapi-codegen. Best to do it in an |
If I have a field which is declared by both the
joinSchema
and the actual schema in a lineage, the go codegen for that field selector ends up being an empty interface. I logged the actual cue value at the selector, and it has all the combined fields, so I'm not 100% sure what's happening behind the scenes. Example:Logging the full schema's
cue.Value
before passing it off to the theme codegen:I then use
The file contents I get back are:
Rather than the expected
The text was updated successfully, but these errors were encountered: