If a protocol buffer file includes multiple top-level messages, the plugin rejects the file.
Solutions:
- Extract top-level message into a separate file and use that
- Permit the specification of one top-level message type using e.g.
--pubsub-schema_opt=top-level-message=Foo
foo.proto:
syntax = "proto3";
message Foo {
}
message Bar {
}
But:
protoc \
--proto_path=${PWD} \
--pubsub-schema_out=${PWD} \
--pubsub-schema_opt=message-encoding-json \
--pubsub-schema_opt=schema-syntax=proto3 \
${PWD}/foo.proto
Yields:
--pubsub-schema_out: test/foo.proto: only one top-level type may be defined in a file (see https://cloud.google.com/pubsub/docs/schemas#schema_types). use nested types or imports (see https://developers.google.com/protocol-buffers/docs/proto)