I wrote a small Java library that can do this:
https://github.com/perezd/protopoet


On Mon, Oct 2, 2023 at 11:14 PM 'Ran Volkovich' via Protocol Buffers <
[email protected]> wrote:

> Hi,
>  i have a need to generate dynamically .proto files descriptor
> and i didnt find any api/tools to do so
> the only thing that near to that was with
> use the jar: "com.google.protobuf" % "protobuf-java" % "3.18.1"
> val fileDescriptorProto = FileDescriptorProto.newBuilder()
> .setName("a")
> .setSyntax("proto3")
> .setPackage("b")
> .addMessageType(DescriptorProto.newBuilder()
> .setName("c")
> .addField(FieldDescriptorProto.newBuilder()
> .setName("d")
> .setType(FieldDescriptorProto.Type.TYPE_STRING)
> .build())
> .build())
> .build()
>
> the output look like this:
> name: "a"
>
> package: "b"
>
> message_type {
>
>   name: "c"
>
>   field {
>
>     name: "d"
>
>     type: TYPE_STRING
>
>   }
>
> }
>
> syntax: "proto3"
>
> when i want to get this:
> syntax = "proto3";
> message c {
>   repeated google.protobuf.StringValue d = 1;
>  }
>
> anyone have idea where to look or what can i do?
>
> thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/8107cc4c-a790-4868-9e6f-89a754036b63n%40googlegroups.com
> <https://groups.google.com/d/msgid/protobuf/8107cc4c-a790-4868-9e6f-89a754036b63n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CAD7-yfv-FZDmgZvYKzRbs%2By2cSBAPqZF8941fs93%3DYMW_9XKWw%40mail.gmail.com.

Reply via email to