feat(sdkgen): Render anyOf properties as closed unions - #7
Merged
Conversation
jedevc
force-pushed
the
jedevc/sdkgen-unions
branch
from
September 3, 2026 10:22
07bb4fe to
76b1fb1
Compare
jedevc
marked this pull request as ready for review
September 3, 2026 10:23
The pinned version predates the goUnions helper: it landed on prod-staging after the commit this was pinned to, despite carrying an earlier commit date. Signed-off-by: Justin Chadwell <justin@unikraft.com>
A property declared as an anyOf of two shapes had no single Go type, so
it was degraded to interface{} and callers were left to hand-roll the
encoding. The sandbox plugin's signal parameter has been shipping that
way since it gained a name form.
Ports the union rendering the platform SDK's templates already do: a
marker interface, a named type per branch, and a decoder dispatching on
the JSON kind. Emitted into model.gen.go alongside the models rather
than one file per union, which is the shape sdkgen renders.
Signed-off-by: Justin Chadwell <justin@unikraft.com>
Every named schema that wasn't an enum became a struct, so a component declaring an array of strings generated an empty struct that no array could ever decode into. They are now the type they encode to, under a name of their own. This only surfaces through unions, where such a schema is the named branch a union takes its name from, but it was always wrong. Signed-off-by: Justin Chadwell <justin@unikraft.com>
jedevc
force-pushed
the
jedevc/sdkgen-unions
branch
from
September 3, 2026 10:24
76b1fb1 to
06b9900
Compare
craciunoiuc
approved these changes
Sep 3, 2026
craciunoiuc
left a comment
There was a problem hiding this comment.
All good here. Thanks! I love go templates.
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.com>
Approved-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An
anyOfproperty has no single Go type, so generated plugin SDKs degraded it tointerface{}and left callers to hand-roll the encoding — the sandbox plugin'ssignalhas been shipping that way. This ports the closed-union rendering the platform SDK's own templates already do, plus the non-object fix a named array branch needs.The go-sdk side: unikraft-cloud/go-sdk#234 and unikraft-cloud/go-sdk#250 added the union templates there, and unikraft-cloud/go-sdk#263 is the matching non-object fix.
The
openapi-genbump picks up unikraft-cloud/x#440, so the sandbox command line in https://github.com/unikraft-cloud/plugins/pull/23 generates asCommandLineUnionwithCommandLineShellandCommandLineArgsvariants.