Skip to content

AmirSoleimani/protoseye

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ProtosEye

Bird's-view of your proto RPCs in JSON.

Supports

✅ Supports google.protobuf.* types.

✅ Supports all standard protobuf types.

Installation

Here are two ways that you can install this tool.

  1. Go install:
go install github.com/AmirSoleimani/protoseye/cmd/...
  1. From source code:
git clone git@github.com:AmirSoleimani/protoseye.git
cd protoseye
go install ./cmd/...
protoc-gen-protoseye version

How to use!

Once you install it, You can easily use it with protoc

find . -name '*.proto' -exec protoc -I=. \
    --protoseye_out=./outputs {} \;

Example

E.g. Input:

message GetBirdRequest {
    string id = 1;
}

message GetBirdResponse {
    string id = 1;
    string name = 2;
    int age = 3;
    google.protobuf.Timestamp created_at = 4;
}

service BirdService {
    rpc GetBird(GetBirdRequest) GetBirdResponse;
}

Output:

// BirdService_bird.GetBirdRequest.json
{
    "id": "mystring"
}

// BirdService_bird.GetBirdResponse.json
{
    "id": "mystring",
    "name": "name",
    "age": 13,
    "created_at": {
        "nanos": 32,
        "seconds": 64
    }
}

Motivation

If you have a complex data structure, getting a good insight into the input and output of your RPCs won't be easy (It gets worse when you have an enormous payload). This tool helps you generate a JSON representation of the RPC request and response.

TODOs

  • Enhance test coverage.
  • Generate smarter and more specific random values.
  • Support custom and predefined field value.
  • Support Directory Tree style besides JSON.