protobuf.js icon indicating copy to clipboard operation
protobuf.js copied to clipboard

Support repeated options

Open smelukov opened this issue 1 year ago • 0 comments

protobuf.js version: 7.2.6

proto-files support repeated options that should be parsed as an array https://protobuf.com/docs/language-spec#resolving-option-names

foo.proto

syntax = "proto3";

import "google/protobuf/descriptor.proto";

extend google.protobuf.MessageOptions {
  repeated string fooOption = 80000;
}

message Foo {
  option fooOption = "some 1";
  option fooOption = "some 2";
}

foo.js

console.log('MESSAGE OPTIONS', root.lookupType('Foo').options);

The output is { fooOption: "some 2"} but should be { fooOption: ["some 1", "some 2"]}

For example, in java:

public class Main {
    public static void main(String[] args) {
        var fooExtension = Foo.getDescriptor().getOptions().getExtension(Foo.fooOption);
        for(var i : fooExtension) {
            System.out.println("i = " + i);
        }
    }
}

The output is:

some 1
some 2

smelukov avatar Apr 30 '24 10:04 smelukov