-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments of rpc method gets copied if multiple services are present in a proto file. #746
Comments
Thanks for raising this issue @princejha95. I'm guessing there's either some variable being overwritten incorrectly or an index not being used here. I predict that if we add a third service with the same method name it will also give that the comment from the first service. We'd be happy to review a PR to fix this. I think the first place to look would be https://github.com/grpc-ecosystem/grpc-gateway/blob/master/protoc-gen-swagger/main.go. |
I think we need to look at https://github.com/grpc-ecosystem/grpc-gateway/blob/master/protoc-gen-swagger/genswagger/template.go because this is where the comments part is dealt. Please have a look to this file. |
Can anyone tell me how can i debug files in grpc-gateway using a debugger ? Which file should be the starting point to start debugging ? |
@princejha95 What I did to start debugging was to set-up a failing test, but that was a bit harder than expected given I wan't sure how to construct a valid The index of the service gets passed to https://github.com/grpc-ecosystem/grpc-gateway/blob/master/protoc-gen-swagger/genswagger/template.go#L743 the values being 0 on the first pass and 1 on the second pass. Within that function, there's https://github.com/grpc-ecosystem/grpc-gateway/blob/master/protoc-gen-swagger/genswagger/template.go#L1238 which truncates the path from I think the missing piece is the
You should be able to make this change and test it against your proto file. I'd do it myself, but I'm having trouble getting code generation working at all. |
I have done and checked what you said and it's correct but this is working only for a single proto file. If i have multiple proto files in a directory, then it is displaying the comments of rpc methods of all the services only for a single proto file. The comments of rpc methods of remaining proto files is not getting displayed. |
What i observed is that when we have multiple proto files, then the title of the generated file is set to the name of that file which comes first in alphabetical order. So, in the above link, *p.File.Name in title represents the name of file coming first alphabetically due to which it traverses the rpc methods of services of only that file. Example: If i have two proto files say a.proto and b.proto. When i will generate swagger json file via merging both the proto files, then the title present in
So can somebody tell me how to pass services of all the proto files instead of single proto file ? |
Can anyone provide the solution for the above issue ? I tried but i was not able to figure it out. |
Reopening this as I've had to back out the latest change. @hexfusion I'd love to work together to get a fix in for this that maintains the comment merging behaviour. |
I have a proto file which consists of multiple services. When I generate the swagger json file from it,
the comment which are mentioned for the first service gets copied down to the second service in the json file.
Here is the proto file:
Here is the generated swagger json file:
Can anyone help in fixing this issue ?
I don't want the comments to get copied. The comments should be present as it is in json file for their respective rpc methods under their respective services.
The text was updated successfully, but these errors were encountered: