Skip to content

gRPC Support

EasyApi provides built-in support for gRPC services, allowing you to export gRPC service definitions and call gRPC endpoints directly from the IDE.

Enabling gRPC Support

  1. Open Preferences(Settings) > Other Settings > EasyApi > gRPC tab
  2. Enable gRPC support to recognize gRPC service classes (default: on)
  3. Optionally enable gRPC call to invoke gRPC endpoints from the IDE (default: off)

How gRPC Services Are Recognized

EasyApi recognizes gRPC services through multiple detection strategies:

1. Extending BindableService

A class is recognized as a gRPC service if it extends io.grpc.BindableService directly or through a generated ImplBase superclass anywhere in the hierarchy:

java
// Generated by protobuf: XxxGrpc.XxxImplBase extends AbstractStub implements BindableService
public class GreeterServiceImpl extends GreeterGrpc.GreeterImplBase {
    @Override
    public void sayHello(HelloRequest request, StreamObserver<HelloReply> responseObserver) {
        // ...
    }
}

The recognizer walks the full supertype hierarchy to find BindableService, so it works even when the implementation class doesn't directly implement it.

2. @GrpcService Annotation

Classes annotated with @GrpcService from grpc-spring-boot-starter are also recognized:

java
@GrpcService
public class GreeterServiceImpl extends GreeterGrpc.GreeterImplBase {
    // ...
}

Meta-annotations are also supported — if you create a custom annotation that is itself annotated with @GrpcService, classes using your custom annotation will be recognized.

3. Custom Rule Override

You can customize gRPC class recognition using the class.is.grpc rule:

properties
class.is.grpc=groovy:it.isExtend("io.grpc.BindableService")

gRPC Method Detection

EasyApi discovers RPC methods using two strategies:

Signature Pattern Matching

For instance methods, EasyApi detects the streaming type from the method signature:

PatternStreaming Type
void method(RequestType req, StreamObserver<Resp> resp)UNARY (or SERVER_STREAMING)
StreamObserver<Req> method(StreamObserver<Resp> resp)CLIENT_STREAMING (or BIDIRECTIONAL)

Note: At the implementation level, unary and server-streaming share the same Java signature. EasyApi defaults to UNARY. Similarly, client-streaming and bidirectional share the same signature and default to CLIENT_STREAMING.

@RpcMethod Annotation

For static methods or when signature detection is ambiguous, EasyApi reads the @RpcMethod annotation generated by gRPC:

java
@RpcMethod(
    fullMethodName = "com.example.Greeter/SayHello",
    requestType = HelloRequest.class,
    responseType = HelloReply.class,
    methodType = "UNARY"
)

This annotation provides precise streaming type information (UNARY, SERVER_STREAMING, CLIENT_STREAMING, BIDIRECTIONAL).

Protobuf Message Type Parsing

EasyApi parses protobuf-generated message classes to extract field information for request/response documentation:

  • Scalar fields → mapped to protobuf types (e.g., Stringstring, intint32)
  • Repeated fields (List<T>) → array types
  • Map fields (Map<K,V>) → map types
  • Nested message types → recursive parsing (up to depth 5)

Internal protobuf methods (like getDefaultInstance, getUnknownFields, getXxxBytes, getXxxCount) are automatically filtered out.

Exporting gRPC APIs

Once gRPC support is enabled, you can export gRPC service methods:

  • Export to Postman: gRPC methods will be included in the collection
  • Export to Markdown: gRPC service documentation will be generated
  • Export to Curl: gRPC endpoints can be exported as curl commands

Each exported endpoint includes:

  • gRPC service path (/{package}.{ServiceName}/{MethodName})
  • Streaming type
  • Request/response protobuf message types and fields

Calling gRPC Endpoints

When gRPC call is enabled, you can invoke gRPC methods directly from the IDE:

  1. Navigate to a gRPC service class
  2. Use the EasyApi Call action on a method
  3. Provide the request parameters in JSON format
  4. View the response

How gRPC Call Works

EasyApi uses dynamic class loading to invoke gRPC methods without requiring compile-time stubs:

  1. Resolves gRPC runtime JARs from local Maven/Gradle repositories
  2. Creates a gRPC channel to the target server
  3. Resolves the service descriptor (from .proto files or server reflection)
  4. Converts the JSON request to protobuf binary format
  5. Invokes the RPC method and converts the response back to JSON

Service Descriptor Resolution

EasyApi resolves gRPC service descriptors from multiple sources:

  • Proto files in the project: Parses .proto files to build service descriptors
  • Server reflection: Queries the gRPC server for service descriptors (if enabled)
  • Generated stub classes: Reads method info from @RpcMethod annotations

Configuration

gRPC Settings

SettingDefaultDescription
Enable gRPC supportOnRecognize gRPC service classes
Enable gRPC callOffAllow calling gRPC endpoints from the IDE
Auto DetectAutomatically detect gRPC runtime artifacts in project
Runtime PackagesgRPC runtime artifact configurations (group:artifact:version:enabled)
Additional JARsAdditional JAR files for gRPC runtime

Runtime Resolution

EasyApi searches for gRPC runtime JARs in the following locations:

  1. Maven local repository (~/.m2/repository)
  2. Gradle cache (~/.gradle/caches/modules-2/files-2.1)
  3. Custom configured repositories

The resolver selects the newest complete version that has all required artifacts:

ArtifactDescription
io.grpc:grpc-netty-shadedNetty transport (shaded)
io.grpc:grpc-apigRPC core API
io.grpc:grpc-protobufProtobuf codec
io.grpc:grpc-stubStub generation
io.grpc:grpc-coregRPC core
io.grpc:grpc-servicesServer reflection & health
com.google.protobuf:protobuf-javaProtobuf runtime
com.google.protobuf:protobuf-java-utilProtobuf JSON utilities
com.google.guava:guavaGuava (dependency)
com.google.guava:failureaccessFailure access (dependency)
com.google.code.gson:gsonGson (dependency)
io.perfmark:perfmark-apiPerformance marking (dependency)

Custom gRPC Recognition

properties
class.is.grpc=groovy:it.isExtend("io.grpc.BindableService") || it.hasAnn("net.devh.boot.grpc.server.service.GrpcService")

Ignore Internal gRPC Methods

properties
ignore=groovy:it.name() == "getServiceDescriptor" || it.name() == "bindService" || it.name() == "getMethodDescriptors"

Released under the Apache-2.0 License.