feat(gen): split ,omitempty policy by request/response direction#6
Merged
Conversation
Request structs KEEP ,omitempty: combined with the nullable→pointer
rewrite, a nil pointer is omitted while &false/&0 is still sent
(tri-state), and a non-nullable zero is genuinely "unset".
Response structs DROP ,omitempty: the API returns the field and the CLI
re-serializes the decoded struct (--json/--toon), so ,omitempty would
silently swallow false/0/[]/{} state fields the help advertises as
present (e.g. rule.enabled=false on a disabled rule). An agent reading a
response field would get a missing key instead of the real value.
The generator already classifies direction (inReq via reqGoNames/
reqSynth, used for the int64-timestamp and nullable-pointer rules); this
just threads the same flag into the struct-tag emit. toon tag retained
on both sides (snake_case keys unchanged). Regenerated models_gen.go;
build + round-trip test green. No spec change, untagged (no release).
ysyneu
added a commit
that referenced
this pull request
Jun 2, 2026
…68) (#7) Re-vendored openapi/ from flashduty-docs main after #68 removed the 6 dead /channel/notify/rule/* endpoints (backend routes deleted 2023-08, absent from the pgy registry). Regenerated: operations 254→248, the 6 ChannelNotifyRule* SDK methods drop from channels.go. No model change (they referenced only shared schemas); the #6 omitempty split is intact. Untagged — no release.
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.
What
Makes the generator's
,omitemptydecision direction-aware:,omitempty— with the existing nullable→pointer rewrite, a nil pointer is omitted while&false/&0is still sent (tri-state filters / partial-update-to-zero), and a non-nullable zero is genuinely "unset".,omitempty— the API returns the field and the CLI re-serializes the decoded struct (--json/--toon). With,omitempty, afalse/0/[]/{}state field the help advertises as present (e.g.rule.enabled=falseon a disabled rule) gets silently swallowed, so an agent doing--json | jq '.enabled'seesnullinstead offalse.Why
Surfaced by the fduty CLI agent-eval: agents reverse-engineering missing keys from omitted zero-valued response fields. For an agent-facing SDK, response fidelity beats wire-minimalism; requests stay lean.
Implementation
The generator already classifies direction (
inReq := g.reqGoNames[name] || g.reqSynth[name], already driving the int64-timestamp and nullable-pointer rules). This just threads the same flag into the struct-tag emit. Thetoontag is retained on both sides (snake_case keys unchanged — no toon-key regression).Verification
go generate ./...: 27 services, 254 operations, 473 schemas.go build/go vet/go test ./...(round-trip type guard) all green.ListIncidentsRequest(request) keepsacker_ids,omitempty;IncidentInfo(response) rendersaccount_id/ack_timewith no,omitempty.No spec change. Untagged — no release; CLI/MCP pick it up on their next
go getbump.