GrpcDocServicePlugin implements DocServicePlugin { @VisibleForTesting static TypeSignature newFieldTypeInfo(FieldDescriptor fieldDescriptor) { if (fieldDescriptor.isMapField()) { return TypeSignature.ofMap( newFieldTypeInfo(fieldDescriptor.getMessageType().findFieldByNumber(1)), newFieldTypeInfo(fieldDescriptor.getMessageType().findFieldByNumber(2))); } final TypeSignature fieldType; switch (fieldDescriptor.getType()) { case BOOL: fieldType = BOOL; break; case BYTES: fieldType = BYTES; break; case DOUBLE: fieldType = DOUBLE; break; case FIXED32: fieldType = FIXED32; break; case FIXED64: fieldType = FIXED64; break; case FLOAT: fieldType = FLOAT; break; case INT32: fieldType = INT32; break; case INT64: fieldType = INT64; break; case SFIXED32: fieldType = SFIXED32; break; case SFIXED64: fieldType = SFIXED64; break; case SINT32: fieldType = SINT32; break; case SINT64: fieldType = SINT64; break; case STRING: fieldType = STRING; break; case UINT32: fieldType = UINT32; break; case UINT64: fieldType = UINT64; break; case MESSAGE: fieldType = namedMessageSignature(fieldDescriptor.getMessageType()); break; case GROUP: fieldType = UNKNOWN; break; case ENUM: fieldType = TypeSignature.ofNamed( fieldDescriptor.getEnumType().getFullName(), fieldDescriptor.getEnumType()); break; default: fieldType = UNKNOWN; break; } return fieldDescriptor.isRepeated() ? TypeSignature.ofContainer("repeated", fieldType) : fieldType; }  @Override String name(); @Override Set<Class<? extends Service<?, ?>>> supportedServiceTypes(); @Override ServiceSpecification generateSpecification(Set<ServiceConfig> serviceConfigs,
                                                      DocServiceFilter filter); @Override Map<String, String> loadDocStrings(Set<ServiceConfig> serviceConfigs); @Override Set<Class<?>> supportedExampleRequestTypes(); @Override String serializeExampleRequest(String serviceName, String methodName,
                                          Object exampleRequest);  }
@Test void newListInfo() throws Exception { final TypeSignature list = GrpcDocServicePlugin.newFieldTypeInfo( ReconnectInfo.getDescriptor().findFieldByNumber(ReconnectInfo.BACKOFF_MS_FIELD_NUMBER)); assertThat(list).isEqualTo(TypeSignature.ofContainer("repeated", GrpcDocServicePlugin.INT32)); }
@Test void newMapInfo() throws Exception { final TypeSignature map = GrpcDocServicePlugin.newFieldTypeInfo( StreamingOutputCallRequest.getDescriptor().findFieldByNumber( StreamingOutputCallRequest.OPTIONS_FIELD_NUMBER)); assertThat(map).isEqualTo(TypeSignature.ofMap(GrpcDocServicePlugin.STRING, GrpcDocServicePlugin.INT32)); }