Skip to content

Merges multiple dependent .proto schema files into one .proto schema file

License

Notifications You must be signed in to change notification settings

build-failure/proto-merge

Repository files navigation

Build

Proto Merge

CLI utility to resolve and merge dependent .proto schema files based on protoc.

Produces self-contained .proto schema files while resolving import definitions.

Limitations

While protoc does the import definition resolution, proto-merge solely concatenates dependent files stripping out conflicting keywords defined within EXCLUDE_PATTERN environment variable.

Usage

docker run -v "./test/schema:/schema" buildfailure/proto-merge:latest /schema/organization.proto

Config

Argument Environment Variable Description Default
--debug DEBUG Enables debugging messages false
--print_stdout PRINT_STDOUT Prints results to stdout true
--exclude_pattern EXCLUDE_PATTERN Defines exclude regex pattern to strip conflicting schema keywords (e.g. import, syntax) import\s*
--proto_path_in PROTO_PATH_IN Defines .proto schema parent input dir /
--proto_path_out PROTO_PATH_OUT Defines .proto schema parent output dir /tmp

Example

Given

The schema with

and file structure

/test/schema/
            address.proto
            employee.proto          # depends on address.proto
            organization.proto      # depends on employee.proto

When

docker run -v "./test/schema:/schema" buildfailure/proto-merge:latest /schema/employee.proto

Then

message Address {

    required string city = 1;

    required string zip = 2;

    required string country = 3;

    required string street = 4;
}

message Employee {

    required string first_name = 1;

    required Address address = 2;
}

About

Merges multiple dependent .proto schema files into one .proto schema file

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published