-
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
fix: protoc-gen-swagger: get wrong second services method comments #1116
fix: protoc-gen-swagger: get wrong second services method comments #1116
Conversation
…s summary not right
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Hi! Thanks for the interest in the project! Instead of this, could you raise an issue with an example of how this bug exhibits itself? With a failing example it will be easy to create a test that we can test a fix against. You could try adding one to this PR too. The generation failure is because you haven't regenerated the files, please see the contribution documentation for a command that will help you do this. |
Hi, I have example of invalid output: contracts.proto syntax = "proto3";
package contracts;
option optimize_for = SPEED;
import "google/api/annotations.proto";
message M {}
service Service1 {
// Service1: Method1
rpc Method1 (M) returns (M) {
option (google.api.http) = {
post: "/Service1/Method1"
body: "*"
};
}
// Service1: Method2
rpc Method2 (M) returns (M) {
option (google.api.http) = {
post: "/Service1/Method2"
body: "*"
};
}
}
service Service2 {
// Service2: Method1
rpc Method1 (M) returns (M) {
option (google.api.http) = {
post: "/Service2/Method1"
body: "*"
};
}
// Service2: Method2
rpc Method2 (M) returns (M) {
option (google.api.http) = {
post: "/Service2/Method2"
body: "*"
};
}
} contracts.swagger.json {
"swagger": "2.0",
"info": {
"title": "contracts.proto",
"version": "version not set"
},
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/Service1/Method1": {
"post": {
"summary": "Service1: Method1",
"operationId": "Method1",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/contractsM"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/contractsM"
}
}
],
"tags": [
"Service1"
]
}
},
"/Service1/Method2": {
"post": {
"summary": "Service1: Method2",
"operationId": "Method2",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/contractsM"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/contractsM"
}
}
],
"tags": [
"Service1"
]
}
},
"/Service2/Method1": {
"post": {
"summary": "Service1: Method1",
"operationId": "Method1",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/contractsM"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/contractsM"
}
}
],
"tags": [
"Service2"
]
}
},
"/Service2/Method2": {
"post": {
"summary": "Service1: Method2",
"operationId": "Method2",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/contractsM"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/contractsM"
}
}
],
"tags": [
"Service2"
]
}
}
},
"definitions": {
"contractsM": {
"type": "object"
}
}
} |
Nice, so it's just the summary that's wrong? Could you try to add either this whole file or something equivalent to one of the existing files and write a test that errors? That'd be well on the way to a contribution to fix this. |
@googlebot I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
Could you please regenerate the files so we can see what difference this makes? See https://github.com/grpc-ecosystem/grpc-gateway/blob/master/CONTRIBUTING.md#i-want-to-regenerate-the-files-after-making-changes |
@johanbrandhorst Now I found the summary and description is wrong. |
You still need to regenerate the files or CI will not pass. |
@johanbrandhorst ok, I will regenerate the files. |
Codecov Report
@@ Coverage Diff @@
## master #1116 +/- ##
=======================================
Coverage 53.88% 53.88%
=======================================
Files 42 42
Lines 4166 4166
=======================================
Hits 2245 2245
Misses 1677 1677
Partials 244 244
Continue to review full report at Codecov.
|
@johanbrandhorst I have already regenerated the files. |
Thanks, this all looks correct! |
Please, write the test, that cover this case, @chinaran |
When a service.proto have more then one services, the protoc-gen-swagger tool can not find right other(not the first one) service's method comments.
I changed protoComments's argument, then the service.swagger.json's summary field was right.
But I'm not sure is the right way to fix it.
Please checkout, thanks.