Skip to content

fix(gen): emit map[string]any for free-form object schemas - #90

Merged
ysyneu merged 2 commits into
mainfrom
fix/free-form-object-schema
Oct 9, 2026
Merged

ysyneu merged 2 commits into
mainfrom
fix/free-form-object-schema

Conversation

@ysyneu

@ysyneu ysyneu commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

A named schema that is a bare object with additionalProperties: true and no fixed properties was emitted as type X struct{}. Any value placed in it is dropped on marshal. CustomFieldValues is the only such schema today, so custom field values could not be sent on:

  • CreateIncidentRequest.Fields
  • AckIncidentRequest.CustomFields
  • ResolveIncidentRequest.CustomFields

The generator now emits these schemas as map[string]any. Schemas whose additionalProperties is itself a schema still go through the existing typed-map branch.

Changes

  • internal/cmd/gen/main.go: new named-schema case for additionalProperties: true with no properties.
  • models_gen.go: regenerated. Only CustomFieldValues changes.
  • flashduty_test.go: TestCustomFieldValuesReachTheWire covers create, ack, and resolve. Against the previous code it does not compile, because a struct with no fields cannot hold values.

Test plan

  • go test -race ./...
  • go build ./...
  • golangci-lint: left to CI. The local install failed its checksum download.

A named schema that is a bare object with `additionalProperties: true`
and no fixed properties was emitted as an empty struct, so every value
put in it was dropped on the wire. CustomFieldValues was the one such
schema: the custom field values on CreateIncidentRequest.Fields and on
AckIncidentRequest/ResolveIncidentRequest.CustomFields could not be
sent. Emit it as map[string]any instead.
The lint job followed setup-go 'stable'. When stable moved to a Go
newer than the one the pinned golangci-lint was built with, type
checking failed on stdlib imports (export data version mismatch) on
every PR. Pin the lint job to go.mod, as flashduty-cli already does.
@ysyneu
ysyneu merged commit a9d1144 into main Oct 9, 2026
4 checks passed
@ysyneu
ysyneu deleted the fix/free-form-object-schema branch October 9, 2026 04:03
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.

1 participant