Repository navigation
fix(gen): emit map[string]any for free-form object schemas - #90
Merged
Merged
Conversation
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.
Merged
6 tasks done
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.
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.
Summary
A named schema that is a bare object with
additionalProperties: trueand no fixed properties was emitted astype X struct{}. Any value placed in it is dropped on marshal.CustomFieldValuesis the only such schema today, so custom field values could not be sent on:CreateIncidentRequest.FieldsAckIncidentRequest.CustomFieldsResolveIncidentRequest.CustomFieldsThe generator now emits these schemas as
map[string]any. Schemas whoseadditionalPropertiesis itself a schema still go through the existing typed-map branch.Changes
internal/cmd/gen/main.go: new named-schema case foradditionalProperties: truewith no properties.models_gen.go: regenerated. OnlyCustomFieldValueschanges.flashduty_test.go:TestCustomFieldValuesReachTheWirecovers 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 ./...