Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add options to limit generation of encode and decode methods to only specific message types #1085

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,14 @@ Generated code will be placed in the Gradle build directory.

This is useful if you want "only types".

- With `--ts_proto_opt=outputEncodeIncludeTypes=regex`, the `Message.encode` method will only be output for types whose name matches the provided regular expression.

This is useful if you want to limit `encode` methods to only select types.

- With `--ts_proto_opt=outputDecodeIncludeTypes=regex`, the `Message.decode` method will only be output for types whose name matches the provided regular expression.

This is useful if you want to limit `decode` methods to only select types.

- With `--ts_proto_opt=outputJsonMethods=false`, the `Message.fromJSON` and `Message.toJSON` methods for working with JSON-coded data will not be output.

This is also useful if you want "only types".
Expand Down
11 changes: 11 additions & 0 deletions integration/output-decode-include-types/encode.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";

import "google/protobuf/wrappers.proto";

message EncodeWithDecodeMethod {
string encode = 1;
}

message EncodeDontGenerateDecodeMethod {
string encode_dont_generate_decode_method = 1;
}
49 changes: 49 additions & 0 deletions integration/output-decode-include-types/encode.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions integration/output-decode-include-types/parameters.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
outputEncodeMethods=decode-only,outputPartialMethods=false,outputJsonMethods=false,nestJs=false,outputDecodeIncludeTypes=^EncodeWithDecodeMethod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
outputEncodeMethods=true,outputPartialMethods=false,outputJsonMethods=false,nestJs=false,outputEncodeIncludeTypes=^Request,outputDecodeIncludeTypes=^Response$
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
syntax = "proto3";

import "google/protobuf/wrappers.proto";

message Request {
string request_id = 1;

message Nested {
string more_data = 1;
}

Nested nested = 2;
}

message Response {
string response_id = 1;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions integration/output-encode-include-types/encode.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";

import "google/protobuf/wrappers.proto";

message Encode {
string encode = 1;
}

message DontGenerateEncode {
string dont_generate_encode = 1;
}
28 changes: 28 additions & 0 deletions integration/output-encode-include-types/encode.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions integration/output-encode-include-types/parameters.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
outputEncodeMethods=encode-only,outputPartialMethods=false,outputJsonMethods=false,nestJs=false,outputEncodeIncludeTypes=^Encode$
4 changes: 0 additions & 4 deletions integration/output-encode-only/encode.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 0 additions & 36 deletions integration/output-encode-only/google/protobuf/wrappers.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading