Export: Protobuf
Converts the data contract to a Protocol Buffers schema.
datacontract export protobuf orders.odcs.yaml --output orders.proto
Running this against the example orders contract produces:
syntax = "proto3";
package example;
// One row per customer order.
message Orders {
// Unique identifier of the order.
string order_id = 1;
// Timestamp when the order was placed.
string order_timestamp = 2;
// Reference to the customer who placed the order.
string customer_id = 3;
// Total amount of the order in cents.
double order_total = 4;
// Current fulfilment status of the order.
string status = 5;
}
// One row per line item within an order.
message LineItems {
// Unique identifier of the line item.
string line_item_id = 1;
// Reference to the parent order.
string order_id = 2;
// Stock keeping unit of the purchased product.
string sku = 3;
// Number of units purchased.
int32 quantity = 4;
}
Configuration
You can customize the generated Protobuf package name using the data contract's customProperties:
kind: DataContract
apiVersion: v3.1.0
id: my-contract
version: 1.0.0
customProperties:
- property: protoPackageName
value: com.example.mydata
schema:
- name: Orders
properties:
# ... fields ...
Supported Properties
protoPackageName(optional) — The package name for the generated Protobuf file. Defaults to"example"if not specified.
All options: datacontract export protobuf.