Commit ac560bb
fix(encoding): generate transitive MarshalJSON for wrapper messages with int64_encoding=NUMBER nested fields (#125)
* test(httpgen,clientgen): add golden test cases for int64 nested encoding in wrapper responses
Add SensorReading (inner, direct NUMBER fields) and GetSensorReadingResponse/GetMultiSensorResponse
(wrapper messages) test proto. Golden files for both httpgen and clientgen cover the new cases.
Test cases added to both golden_test.go files.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(httpgen): generate transitive MarshalJSON for wrapper messages with nested NUMBER fields
When a wrapper/response message contains a field whose type has int64_encoding=NUMBER fields,
protojson.Marshal bypasses the inner message's MarshalJSON — producing strings instead of numbers.
Fix adds a two-phase collection in generateInt64EncodingFile:
- Phase 1 (existing): collect messages with direct NUMBER fields
- Phase 2 (new): collect wrapper messages whose fields reference phase-1 types
Wrapper messages get generated MarshalJSON/UnmarshalJSON that use protojson for base
serialization, then re-marshal each nested NUMBER field via json.Marshal to trigger
the inner message's custom MarshalJSON.
Closes #124
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(clientgen): generate transitive MarshalJSON for wrapper messages with nested NUMBER fields
Identical fix to httpgen: two-phase collection detects wrapper messages containing fields
whose type has int64_encoding=NUMBER, generating MarshalJSON/UnmarshalJSON that re-marshal
those nested fields via json.Marshal to trigger the inner message's custom marshaling.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore(examples): update protovalidate dependency to latest version
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(lint): apply golines formatting to long function signatures in encoding.go
golangci-lint (golines) flagged collectWrapperMessages and two gf.P() calls
in generateWrapperMarshalJSON/UnmarshalJSON for exceeding the line length limit.
Auto-fixed with golangci-lint --fix; golden files regenerated to match.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 917521f commit ac560bb
File tree
23 files changed
+2126
-15
lines changed- examples
- error-handler
- market-data-unwrap
- multi-service-api
- nested-resources
- restful-crud
- rn-client-demo
- simple-api
- ts-client-demo
- validation-showcase
- internal
- clientgen
- testdata
- golden
- proto
- httpgen
- testdata
- golden
- proto
23 files changed
+2126
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
0 commit comments