Skip to content

Commit 9df5010

Browse files
Custom Transformers & Fix OneOf fields (#19)
- add custom (not generated) transformers for sub-messages - add transformer.custom attribute to mark fields which require custom transformers - limit oneOfDecl to the specific case it serves - extend makefile with more commands
1 parent c30a481 commit 9df5010

17 files changed

+1470
-306
lines changed

Makefile

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=1.0.6-dev
1+
VERSION=1.0.7-dev
22
BUILDTIME=$(shell date +"%Y-%m-%dT%T%z")
33
LDFLAGS= -ldflags '-X github.com/bold-commerce/protoc-gen-struct-transformer/generator.version=$(VERSION) -X github.com/bold-commerce/protoc-gen-struct-transformer/generator.buildTime=$(BUILDTIME)'
44

@@ -13,6 +13,21 @@ re-generate-example:
1313

1414
generate: version re-generate-example
1515

16+
re-generate-example-debug:
17+
protoc \
18+
--proto_path=$(GOPATH)/pkg/mod/github.com/gogo:. \
19+
--struct-transformer_out=package=transform,debug=true,helper-package=helpers,goimports=true:. \
20+
--gogofaster_out=Moptions/annotations.proto=github.com/bold-commerce/protoc-gen-struct-transformer/options:. \
21+
./example/message.proto
22+
23+
generate-debug: version re-generate-example-debug
24+
25+
generate-annotations:
26+
protoc \
27+
--proto_path=$(GOPATH)/pkg/mod/github.com/gogo:. \
28+
--gogofaster_out=Moptions/annotations.proto=github.com/bold-commerce/protoc-gen-struct-transformer/options:. \
29+
./options/annotations.proto
30+
1631
install: setup
1732
go install $(LDFLAGS)
1833

@@ -25,4 +40,4 @@ version:
2540

2641
setup:
2742
go mod download
28-
go mod verify
43+
go mod verify

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ message Product {
215215
// field in model with arbitrary name.
216216
// Both options "map_as" and "map_to" can be used independently.
217217
string map_field_1 = 6 [ (transformer.map_as) = "MapField_1", (transformer.map_to) = "MapField1"];
218+
// "custom" allows to use custom transformers for fields, which require extended transformation
219+
// The plugin won't generate methods for this field,
220+
// but rather expect it to be in the same package with the transformer file
221+
CustomType custom_field [(transformer.custom) = true]
218222
}
219223
```
220224
### Run protoc

0 commit comments

Comments
 (0)