-
Notifications
You must be signed in to change notification settings - Fork 496
Description
Title: Dynamic build not showing custom method options in .Options map
Description:
Hello, I’m running into a problem where custom method options (extensions on google.protobuf.MethodOptions) are not appearing in the .Options map in my template, even though I’ve built protoc-gen-doc with -tags dynamic.
Steps to Reproduce
-
Minimal .proto Files
test_extension.proto:syntax = "proto3"; package test.extensions; import "google/protobuf/descriptor.proto"; enum MyErrorCode { UNKNOWN = 0; BAD_REQUEST = 1; } extend google.protobuf.MethodOptions { string path = 50001; repeated MyErrorCode error_codes = 50002; }
test_service.proto:syntax = "proto3"; package test.service; import "test_extension.proto"; service MyService { rpc Foo (FooReq) returns (FooResp) { option (test.extensions.path) = "/foo"; option (test.extensions.error_codes) = BAD_REQUEST; option (test.extensions.error_codes) = UNKNOWN; } } message FooReq {} message FooResp {}
-
Template (
test_template.tmpl):{{ range .Files -}} ## File: {{ .Name }} {{ range .Services -}} ### Service: {{ .Name }} {{ range .Methods -}} - **Method**: {{ .Name }} - **Options**: {{ range $k, $v := .Options }} - `{{ $k }}` = `{{ $v }}` {{ end }} {{ end -}} {{ end -}} {{ end -}} -
Build protoc-gen-doc with dynamic tag:
cd protoc-gen-doc git checkout v1.5.1 # or tried main as well go build -tags dynamic -o protoc-gen-doc-dynamic ./cmd/protoc-gen-doc # Verified ./protoc-gen-doc-dynamic --version => 1.5.1 -
Run protoc:
--plugin=protoc-gen-doc=./protoc-gen-doc-dynamic \
-I=. \
--include_imports \
--doc_out=. \
--doc_opt=test_template.tmpl,output.md \
test_extension.proto \
test_service.proto
Expected Behaviour
The generated output.md should list the custom method options under - **Options**:.
For example:
### Service: MyService
- **Method**: Foo
- **Options**:
- `(test.extensions.path)` = `/foo`
- `(test.extensions.error_codes)` = `BAD_REQUEST`
- `(test.extensions.error_codes)` = `UNKNOWN`
Actual Behaviour
The output is:
For example:
## File: test_service.proto
### Service: MyService
- **Method**: Foo
- **Options**:
Additional Evidence
Decoded descriptor (protoc --decode_raw) does show 50001: "/foo" and 50002: "\001\000", indicating the custom fields are present in the compiled descriptor.
I’ve tried --include_imports, multiple versions of protoc-gen-doc, and ensuring the correct plugin is used (verified by absolute path).
The same result occurs with v1.5.1 and with main (when built with -tags dynamic).
Question / Request
Is this a known limitation or bug that method-level custom options are not populated into .Options even under the dynamic build?
Or is there a known workaround for reading these extension fields on RPC methods?