fix: add JSON omitempty/omitzero tags to asyncapiv3 types (Go 1.24)#307
Closed
lerenn wants to merge 2 commits into
Closed
fix: add JSON omitempty/omitzero tags to asyncapiv3 types (Go 1.24)#307lerenn wants to merge 2 commits into
lerenn wants to merge 2 commits into
Conversation
Signed-off-by: Justen Stall <39888103+justenstall@users.noreply.github.com>
The omitempty/omitzero tags added for asyncapiv3 use the `omitzero` option, which requires Go 1.24+. Without bumping the toolchain it is silently ignored, so the binding structs, OAuthFlows, Components and Operation.Messages would still serialize as zero values. - go.mod: go 1.21 -> 1.24, toolchain go1.21.4 -> go1.24.0 - Dagger CI images (the actual build/lint compilers): golang 1.21.4-alpine -> 1.24-alpine, golangci-lint v1.62.0 -> v1.64.8 (last v1, keeps the v1 .golangci.yml format, bundles Go 1.24) - drop exportloopref (fully inactivated since Go 1.22 loopvar) and the now-unused funlen nolint directive surfaced by the newer linter - rewrap over-length doc comments to satisfy lll Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
Author
|
Superseded: the Go 1.24 bump needed to make |
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.
Adds
omitempty/omitzeroto the JSON struct tags of the asyncapiv3 types so thespec types round-trip cleanly when marshaled (only non-required fields are emitted).
Also fixes the
Operation.Descriptiontag (wasjson:"string"), gives the privatedependenciesfield ajson:"-"tag, and adds theSecuritySchemeTypeconstants.Continues and supersedes #286 by @justenstall (original commit preserved). Fixes #300.
Why the Go bump
Some fields require the newer
omitzerooption (binding structs,OAuthFlows,Components, andOperation.Messages, which must distinguish[]from absent).omitzeroonly works when the library is built with Go ≥ 1.24 — and the DaggerCI pipeline compiles everything with pinned images. Without the bump the tags are
silently ignored. So this PR also:
go.mod(go 1.21→1.24,toolchain go1.21.4→go1.24.0) — thisraises the minimum Go version for consumers of the library to 1.24;
golang:1.21.4-alpine→golang:1.24-alpine,golangci-lint v1.62.0→v1.64.8(last v1, keeps the v1.golangci.ymlformat and bundles Go 1.24);exportloopref(fully inactivated since Go 1.22's loopvar fix) and anunused
funlennolint directive surfaced by the newer linter, and rewraps a fewover-length doc comments.
Verification
go generate ./...→ zero diff (generated code unchanged)go build,go vet,gofmt, and theasyncapi/codegenunit tests passgolangci-lint v1.64.8run via the exact CI image → exit 0🤖 Generated with Claude Code