Skip to content

fix: add JSON omitempty and omitzero tags to asyncapiv3 types#286

Merged
lerenn merged 2 commits into
lerenn:mainfrom
justenstall:add-json-omitempty
Jun 11, 2026
Merged

fix: add JSON omitempty and omitzero tags to asyncapiv3 types#286
lerenn merged 2 commits into
lerenn:mainfrom
justenstall:add-json-omitempty

Conversation

@justenstall

Copy link
Copy Markdown
Contributor

This PR adds omitempty and omitzero to the JSON struct tags for any fields that are not required according to the AsyncAPI specification. Some fields required the newer omitzero tag to be excluded without changing them to a pointer type, but I used omitempty for every other field for maximum backwards compatibility.

There is also a bug fix for the Operation.Description field, which was set to use string as its name in JSON.

I documented that the MessageTrait.Payload field should probably be removed, but kept it for now.

I also documented some nuances with the interpretation of the Operation.Messages field.

@lerenn

lerenn commented Oct 27, 2025

Copy link
Copy Markdown
Owner

Sorry about the delay, I had some changes in my life this 2 past months, I'll take a look ASAP.

@stavros-k

Copy link
Copy Markdown

Fixes also #300

justenstall and others added 2 commits June 11, 2026 22:39
Signed-off-by: Justen Stall <39888103+justenstall@users.noreply.github.com>
…tive

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 (raises the
  library's minimum Go version to 1.24)
- 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 and bundles Go 1.24)
- make the Dagger CI module self-contained: it imported the library only
  for two self-signed-certificate test helpers, which forced the Dagger
  engine to load the library's go 1.24 module with its older bundled Go
  and fail to bootstrap. Copy those helpers into the CI module and drop
  the parent dependency so the engine only loads the CI module itself.
- drop exportloopref (inactivated since Go 1.22 loopvar) and an unused
  funlen nolint directive surfaced by the newer linter; rewrap a few
  over-length doc comments.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lerenn lerenn force-pushed the add-json-omitempty branch from 704df0d to 4e189da Compare June 11, 2026 20:44
@lerenn lerenn merged commit 5490f22 into lerenn:main Jun 11, 2026
5 checks passed
lerenn added a commit that referenced this pull request Jun 11, 2026
Recognizes @justenstall for #286 (JSON omitempty/omitzero tags for the
asyncapiv3 types).

Co-authored-by: Louis FRADIN <louis.fradin@pm.me>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.

3 participants