Skip to content

fix: support defaults for custom JSON wrappers - #1078

Open
deepakganesh78 wants to merge 1 commit into
danielgtaylor:mainfrom
deepakganesh78:fix/issue814-generic-default-wrapper
Open

fix: support defaults for custom JSON wrappers#1078
deepakganesh78 wants to merge 1 commit into
danielgtaylor:mainfrom
deepakganesh78:fix/issue814-generic-default-wrapper

Conversation

@deepakganesh78

Copy link
Copy Markdown

Summary

  • keep SchemaProvider defaults in their declared JSON Schema wire format
  • construct runtime defaults through the wrapper's existing json.Unmarshaler contract
  • preserve schema validation before conversion, so invalid defaults still fail registration

Root cause

Default tags were reflect-converted directly from the schema value to the Go field type. A custom schema can expose a primitive wire type while using a struct wrapper in Go, so the primitive value is not directly convertible to the wrapper.

Tests

  • go test . -run '^(TestSchema|TestFeatures)$' -count=1
  • go test . -count=1
  • go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.9.0 run

The full Windows suite was also attempted; unrelated platform-sensitive TestCLIShutdown and Fiber adapter tests timed out/failed, while the affected core package and configured lint pass.

Fixes #814

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.

default tag causes panic with generic wrapper types (e.g., OmittableNullable[string])

1 participant