-
Notifications
You must be signed in to change notification settings - Fork 0
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
Introduce generate option to customize output #23
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7328704
Allow parameter extraction to recognize new `:generate` option
darronschall a8b037c
Refactor: Extract service generation to `generate_service_class` helper.
darronschall c847c2c
Refactor: Extract client generation to `generate_client_class` helper.
darronschall bb21638
Implement conditional generation based on `generate` option value
darronschall 19f2138
Replace the "import_type_retention" example with "complex_example"
darronschall 8eec604
Add specs to cover the various `generate=` options.
darronschall e07b742
Document `generate=` options in README.md
darronschall 393768e
Update CHANGELOG.md
darronschall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
syntax = "proto3"; | ||
|
||
// This is a contrived example that demonstrates: | ||
// | ||
// 1. Code generation for multiple services, each with multiple rpcs | ||
// 2. Using imported types for request and response types | ||
// 3. Services proto in a completely different package | ||
// | ||
// This file does _not_ demonstrate best practices. | ||
|
||
package api; | ||
|
||
import "common/rpc/status.proto"; | ||
import "common/type/color.proto"; | ||
import "common/type/time_of_day.proto"; | ||
|
||
service GreetService { | ||
rpc SayHello(HelloRequest) returns (HelloResponse); | ||
rpc SayGoodbye(GoodbyeRequest) returns (GoodbyeResponse); | ||
rpc ChangeColor(.common.type.Color) returns (ChangeColorResponse); | ||
} | ||
|
||
service StatusService { | ||
rpc GetStatus(StatusRequest) returns (.common.rpc.Status); | ||
rpc GetTimeOfDay(TimeOfDayRequest) returns (common.type.TimeOfDay); | ||
} | ||
|
||
message HelloRequest { | ||
string name = 1; | ||
} | ||
|
||
message HelloResponse { | ||
string response = 1; | ||
.common.type.Color favorite_color = 2; | ||
} | ||
|
||
message GoodbyeRequest { | ||
string name = 1; | ||
} | ||
|
||
message GoodbyeResponse { | ||
string response = 1; | ||
} | ||
|
||
message ChangeColorResponse {} | ||
|
||
message StatusRequest {} | ||
|
||
message TimeOfDayRequest {} |
Binary file not shown.
Binary file added
BIN
+12 KB
spec/fixtures/complex_example/api_code_gen_request_skip_empty_generate_both_pb.bin
Binary file not shown.
Binary file added
BIN
+12 KB
spec/fixtures/complex_example/api_code_gen_request_skip_empty_generate_client_pb.bin
Binary file not shown.
Binary file added
BIN
+12 KB
spec/fixtures/complex_example/api_code_gen_request_skip_empty_generate_service_pb.bin
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
syntax = "proto3"; | ||
|
||
package common.rpc; | ||
|
||
import "google/protobuf/any.proto"; | ||
|
||
message Status { | ||
int32 code = 1; | ||
string message = 2; | ||
repeated google.protobuf.Any details = 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
syntax = "proto3"; | ||
|
||
package common.type; | ||
|
||
message Color { | ||
float red = 1; | ||
float green = 2; | ||
float blue = 3; | ||
float alpha = 4; | ||
} |
13 changes: 13 additions & 0 deletions
13
spec/fixtures/complex_example/common/type/time_of_day.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
syntax = "proto3"; | ||
|
||
package common.type; | ||
|
||
message TimeOfDay { | ||
enum Meridiem { | ||
UNKNOWN = 0; | ||
ANTE = 1; | ||
POST = 2; | ||
} | ||
|
||
Meridiem am_or_pm = 1; | ||
} |
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-1.28 KB
spec/fixtures/import_type_retention/example_code_gen_request_pb.bin
Binary file not shown.
Binary file removed
BIN
-1.29 KB
spec/fixtures/import_type_retention/example_code_gen_request_skip_empty_pb.bin
Binary file not shown.
9 changes: 0 additions & 9 deletions
9
spec/fixtures/import_type_retention/package/actions/asks.proto
This file was deleted.
Oops, something went wrong.
Binary file added
BIN
+1.03 KB
spec/fixtures/service_code_gen_request_generate_param_invalid_value_pb.bin
Binary file not shown.
Binary file added
BIN
+1.03 KB
spec/fixtures/service_code_gen_request_generate_param_missing_value_pb.bin
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤣