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

Expose extended options to plugins #332

Closed
kerinin opened this issue Apr 4, 2017 · 1 comment
Closed

Expose extended options to plugins #332

kerinin opened this issue Apr 4, 2017 · 1 comment

Comments

@kerinin
Copy link

kerinin commented Apr 4, 2017

It's possible there's a way to do this that I've just missed, but...

Given a custom option like so:

syntax = "proto3";

import "google/protobuf/descriptor.proto";

extend google.protobuf.FileOptions {
  string foo = 50001;
}

option (foo) = "bar";

It would be really nice if the value bar could be extracted from an instance of plugin.CodeGeneratorRequest. The value exists in plugin.CodeGeneratorRequest.ProtoFile.*.Options.XXX_InternalExtensions, however there's no way to access it - proto.GetExtensions requires a proto.ExtensionDesc, but the values returned by proto.ExtensionDescs and friends return values containing just the "Field" field, which causes a panic if passed to proto.GetExtensions. In theory the extensions could be registered by importing the generated code, but that can't be done dynamically.

WRT motivation for such a change, I'm working on a documentation generator and I would like to do things like:

  • Annotate fields as "private" to omit them from generated docs
  • Annotate fields for generating "fake" example data, ie string address = 1 [(generator) = "email"];
  • Annotate the authentication requirements of RPC services and methods
  • Annotate endpoints for RPC services
  • Annotate field / message validation constraints
@dsnet
Copy link
Member

dsnet commented Mar 8, 2018

Support for plugins in general needs to be discussed. If we decide to provide first-class support for plugins, there will probably be an entire redesign.

Closing this in favor of the umbrella issue #547.

@dsnet dsnet closed this as completed Mar 8, 2018
@golang golang locked as resolved and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants