Skip to content

Permit specification of one top-level message type to generate Pub/Sub-compatible protobufs #19

@DazWilkin

Description

@DazWilkin

If a protocol buffer file includes multiple top-level messages, the plugin rejects the file.

Solutions:

  1. Extract top-level message into a separate file and use that
  2. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions