Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support repeated options #1987

Open
smelukov opened this issue Apr 30, 2024 · 0 comments
Open

Support repeated options #1987

smelukov opened this issue Apr 30, 2024 · 0 comments

Comments

@smelukov
Copy link

smelukov commented Apr 30, 2024

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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant