kroto-plus icon indicating copy to clipboard operation
kroto-plus copied to clipboard

CoroutineGrpc generated only when asciipb format is used

Open AlexeySoshin opened this issue 5 years ago • 3 comments

Object named <ServiceName>CoroutineGrpc is generated only when ascipb format is used. In both json and yml formats it's not present. Example project: https://github.com/alexeysoshin/KotlinGrpcKroto

My guess is that it has something to do with upper-case and lower case names.

AlexeySoshin avatar Jul 23 '19 20:07 AlexeySoshin

Has to do with empty arrays: "grpcCoroutines": [] doesn't generate the file, but "grpcCoroutines": [{}] does, in JSON format.

AlexeySoshin avatar Jul 23 '19 20:07 AlexeySoshin

Looking at it now, it makes sense. The generator being enabled relies on the existence of at least one configuration being present. The empty {} serializes to one configuration. These two configurations are equivalent.

// asciipb
grpc_coroutines{}
grpc_coroutines{}
{
    "grpcCoroutines":[
       {},
       {}
    ]
}

To your point though, the configuration for json and yaml is confusing. I think this could potentially be fixed by checking if the message is set in the filter utils, but this would need to be tested. In theory it should work since message fields still support hasX checks in proto3. https://github.com/protocolbuffers/protobuf/issues/249

marcoferrer avatar Jul 23 '19 21:07 marcoferrer

grpcCoroutines: [] is working in yaml version with proto3 with 0.5.0

malachid avatar Oct 18 '19 17:10 malachid