Protobuf


Glue supports protobuf as a code generation target, allowing you to generate .proto schemas from Glue models, enums, and services.

Simply run:

shell

#Configuration

You can configure the emitted protobuf package name:

yaml

#Example

For this Glue spec:

glue

...generating protobuf...

shell

...will produce:

proto

Enum constants are generated in CONSTANT_CASE from the Glue string values. Values that normalize to the same Protobuf identifier are rejected because Protobuf enum value names share the package scope.

#Field tags

By default, Glue assigns Protobuf field tags from field declaration order, starting at 1. You do not need to annotate fields for simple or early schemas.

Use @field(proto_tag=<number>) when you need stable Protobuf wire compatibility across field reordering:

glue

If one field in a message has proto_tag, every field in that message must have one. Untagged messages keep source-order numbering.

proto_tag can use folded int constant expressions, including model-scoped constants:

glue

#Optional fields

Optional Glue fields generate optional Protobuf fields:

glue
proto

Protobuf does not track field presence for repeated or map fields, so optional repeated/map Glue fields are emitted as regular repeated and map fields.

#Services

Glue services generate Protobuf service definitions:

glue
proto

#Notes

  • Endpoint declarations are ignored by the Protobuf generator.

#Current limitations

  • Record<K, V> is emitted as map<K, V> for supported Protobuf key/value types.
  • Anonymous structs are emitted as generated messages named from the owning field path.
  • Unions are emitted as oneof only when every member is valid inside a Protobuf oneof; repeated fields, maps, optional members, and explicit proto_tag unions are rejected with an error.
  • RPC body and returns must be message types.