zod-to-protobuf
v2.1.3
Published
A utility to convert Zod schemas to Protocol Buffers definitions.
Downloads
42
Maintainers
Readme
zod-to-protobuf
Summary
Convert Zod schemas to Protocol Buffers definitions.
Installation
npm install zod-to-protobuf
Usage
import { z } from 'zod'
import { zodToProtobuf } from 'zod-to-protobuf'
const schema = z.object({
name: z.string(),
age: z.number()
})
const proto = zodToProtobuf(schema)
console.log(proto)
Expected Output
syntax = "proto3";
package default;
message Message {
string name = 1;
double age = 2;
}
Options
| Option | Description | Default |
|-------------------|--------------------------------------------|------------------|
| packageName
| Name of the protobuf package | default
|
| rootMessageName
| Name of the protobuf message | Message
|
| typePrefix
| Prefix for each type | (empty string) |
Contributing
Contributions are welcome! Please open an issue or submit a pull request.