-
Notifications
You must be signed in to change notification settings - Fork 130
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
Code generator plugin option to exclude rpc methods by default #290
Comments
Hey Taylor, there are some options:
Some background on option 4: If you run
service MyService {
rpc GetBar(Example) returns (Example) {
option (docs.client_accessible) = true;
}
} You would use the following command to compile all proto files into a file descriptor set in JSON format: buf build --output image.json This image contains your custom option as well: "service": [
{
"name": "MyService",
"method": [
{
"name": "GetBar",
"inputType": ".docs.Example",
"outputType": ".docs.Example",
"options": {
"[docs.client_accessible]": true
}
}
]
}
], You can remove the method from the image, then run There are caveats, though: The file descriptor set also contains comments, and if you remove just a few methods from a service, it is possible that comments for other methods on that service show the wrong comments. This would not matter if your custom option would apply to services. |
First of all thank you for developing this awesome library. I was able to integrate it into an existing stack which provides its own version of protoc and invokes the protoc-gen-ts binary directly. protoc-gen-ts is able to compile everything that I've thrown at it, and produces highly readable code.
At my company (Dropbox) it's a common practice to create services which contain rpc methods that are not intended for the browser. In order to use protobuf-ts's generated clients feature, I need some way to exclude such methods from the generated code.
I imagine that this could be represented as a custom option named
client_accessible
In practice, most of the rpc methods are not intended for the browser/client. The reason for this is Dropbox has hundreds of existing services owned by different teams, and many of these services contain rpc methods for generating page HTML content.
Therefore, a more ideal solution for my use case would be a new plugin option such as
exclude_rpc_methods_by_default
and for individual rpc methods to opt in to being picked up by the code generator.I can understand if this feature does not make sense to put into the core protobuf-ts plugin. Any guidance you can provide is greatly appreciated.
The text was updated successfully, but these errors were encountered: