Skip to content

Commit

Permalink
Custom Transformers & Fix OneOf fields (#19)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
ysurtayev-bold authored Sep 4, 2020
1 parent c30a481 commit 9df5010
Show file tree
Hide file tree
Showing 17 changed files with 1,470 additions and 306 deletions.
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=1.0.6-dev
VERSION=1.0.7-dev
BUILDTIME=$(shell date +"%Y-%m-%dT%T%z")
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)'

Expand All @@ -13,6 +13,21 @@ re-generate-example:

generate: version re-generate-example

re-generate-example-debug:
protoc \
--proto_path=$(GOPATH)/pkg/mod/github.com/gogo:. \
--struct-transformer_out=package=transform,debug=true,helper-package=helpers,goimports=true:. \
--gogofaster_out=Moptions/annotations.proto=github.com/bold-commerce/protoc-gen-struct-transformer/options:. \
./example/message.proto

generate-debug: version re-generate-example-debug

generate-annotations:
protoc \
--proto_path=$(GOPATH)/pkg/mod/github.com/gogo:. \
--gogofaster_out=Moptions/annotations.proto=github.com/bold-commerce/protoc-gen-struct-transformer/options:. \
./options/annotations.proto

install: setup
go install $(LDFLAGS)

Expand All @@ -25,4 +40,4 @@ version:

setup:
go mod download
go mod verify
go mod verify
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ message Product {
// field in model with arbitrary name.
// Both options "map_as" and "map_to" can be used independently.
string map_field_1 = 6 [ (transformer.map_as) = "MapField_1", (transformer.map_to) = "MapField1"];
// "custom" allows to use custom transformers for fields, which require extended transformation
// The plugin won't generate methods for this field,
// but rather expect it to be in the same package with the transformer file
CustomType custom_field [(transformer.custom) = true]
}
```
### Run protoc
Expand Down
Loading

0 comments on commit 9df5010

Please sign in to comment.