The Protobuf to Zod Converter is a Rust-based tool designed to transform Protocol Buffer (protobuf) definitions into Zod schemas. This project aims to bridge the gap between the widely used protobuf format and the TypeScript-first schema validation library, Zod.
- Parse Protocol Buffer (version 3) files
- Support for messages, enums, nested types, and more
- Generate corresponding Zod schemas
- Robust error handling and reporting
To set up the Protobuf to Zod Converter, follow these steps:
-
Ensure you have Rust installed on your system. If not, install Rust.
-
Clone the repository:
git clone https://github.com/olegakbarov/protobuf_to_zod.git cd protobuf_to_zod
-
Build the project:
cargo build --release
RUST_LOG=trace cargo run
To use the Protobuf to Zod Converter:
-
Place your
.proto
file in thefiles
directory. The project currently includes a samplesimple.proto
file. -
Run the converter:
cargo run
-
The program will read the
simple.proto
file, parse it, and output "Success!" if the parsing is successful.
Note: The current implementation focuses on parsing the protobuf file. Generation of Zod schemas is a planned feature.
The project is structured as follows:
/src
: Contains the main source codemain.rs
: Entry point of the applicationlib.rs
: Defines the library and error types/parser
: Contains the protobuf parser implementationmod.rs
: Defines the parser moduleast.rs
: Abstract Syntax Tree definitionslexer.rs
: Tokenizer for protobuf fileserror.rs
: Error handling for the parser
/intermediate
: Contains intermediate representation (currently a placeholder)
/files
: Contains sample protobuf filesCargo.toml
: Rust package manifest
Contributions to the Protobuf to Zod Converter are welcome! Here's how you can contribute:
- Fork the repository
- Create a new branch (
git checkout -b feature/amazing-feature
) - Make your changes
- Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Please ensure your code adheres to the existing style and passes all tests.
This project is licensed under the MIT License.
Built with ❤️ by Oleg Akbarov in a beautiful city of San Franciso