Skip to content

fix: add JSON omitempty/omitzero tags to asyncapiv3 types (Go 1.24)#307

Closed
lerenn wants to merge 2 commits into
mainfrom
feat/v3-json-omitempty-omitzero
Closed

fix: add JSON omitempty/omitzero tags to asyncapiv3 types (Go 1.24)#307
lerenn wants to merge 2 commits into
mainfrom
feat/v3-json-omitempty-omitzero

Conversation

@lerenn

@lerenn lerenn commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Adds omitempty/omitzero to the JSON struct tags of the asyncapiv3 types so the
spec types round-trip cleanly when marshaled (only non-required fields are emitted).
Also fixes the Operation.Description tag (was json:"string"), gives the private
dependencies field a json:"-" tag, and adds the SecuritySchemeType constants.

Continues and supersedes #286 by @justenstall (original commit preserved). Fixes #300.

Why the Go bump

Some fields require the newer omitzero option (binding structs, OAuthFlows,
Components, and Operation.Messages, which must distinguish [] from absent).
omitzero only works when the library is built with Go ≥ 1.24 — and the Dagger
CI pipeline compiles everything with pinned images. Without the bump the tags are
silently ignored. So this PR also:

  • bumps go.mod (go 1.211.24, toolchain go1.21.4go1.24.0) — this
    raises the minimum Go version for consumers of the library to 1.24;
  • bumps the Dagger CI images, which are the actual build/lint compilers:
    golang:1.21.4-alpinegolang:1.24-alpine, golangci-lint v1.62.0
    v1.64.8 (last v1, keeps the v1 .golangci.yml format and bundles Go 1.24);
  • drops exportloopref (fully inactivated since Go 1.22's loopvar fix) and an
    unused funlen nolint directive surfaced by the newer linter, and rewraps a few
    over-length doc comments.

Verification

  • go generate ./... → zero diff (generated code unchanged)
  • go build, go vet, gofmt, and the asyncapi/codegen unit tests pass
  • golangci-lint v1.64.8 run via the exact CI image → exit 0

🤖 Generated with Claude Code

justenstall and others added 2 commits June 11, 2026 22:20
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>
@lerenn

lerenn commented Jun 11, 2026

Copy link
Copy Markdown
Owner Author

Superseded: the Go 1.24 bump needed to make omitzero effective has been pushed directly onto #286, which now carries the full change. Merging from the original PR to preserve @justenstall's authorship.

@lerenn lerenn closed this Jun 11, 2026
@lerenn lerenn deleted the feat/v3-json-omitempty-omitzero branch June 11, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Operation's description has wrong json tag

2 participants