AnWeber / vscode-httpyac

Quickly and easily send REST, Soap, GraphQL, GRPC, MQTT and WebSocket requests directly within Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=anweber.vscode-httpyac
MIT License
237 stars 20 forks source link

[Feature Request] gRPCurl code generator #183

Open gianlucaparadise opened 1 year ago

gianlucaparadise commented 1 year ago

It would be nice to have the possibility to generate a gRPCurl command starting from an httpyac request. This feature should be similar to the generate shell - curl feature available for http requests.

The easiest structure of a grpcurl command is:

grpcurl \
    -H 'my-metadata: my-value' \
    -H 'my-other-metadata: my-other-value' \
    -d '{ "my_request_field": "my_request_value" }' \
    -plaintext {{host}} {{service}}/{{method}}

plaintext is needed for servers without TLS.

Examples

This:

GRPC grpcb.in:9000/grpcbin.GRPCBin/DummyUnary

{
    "fString": "my value"
}

Generates:

grpcurl \
    -d '{ "fString": "my value" }' \
    -plaintext grpcb.in:9000 grpcbin.GRPCBin/DummyUnary

And this:

GRPC grpcb.in:9000/grpcbin.GRPCBin/HeadersUnary
my-metadata: my-value

Generates:

grpcurl \
    -H 'my-metadata: my-value' \
    -plaintext grpcb.in:9000 grpcbin.GRPCBin/HeadersUnary