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
cmd/protoc-gen-openapi: additional_bindings duplicate operationId #372
Comments
@silas, thanks for noting this. I think it's unfortunate that this violates the OpenAPI spec because it seems consistent with the meaning of |
@timburks I had I haven't really tested it in other tools yet. I'm using OpenAPI as a fallback for users that can't use supported clients, so to support the widest variety of tools I want it to follow the spec. I'll probably maintain a fork either way for my customizations, so I don't necessarily need this fixed upstream, just wanted to report it in case you considered it a bug/regression. |
It would certainly break code generators that use the operation ID and are not prepared to handle duplications. The easiest solution would probably be slapping a counter after the generated name for each additional binding.
Personally, I wouldn't worry about that much. Manually supplied |
@sagikazarmark How the protobuf definitions are currently defined there is no way for the user to fix it. It only allows you to define the service TestService {
rpc Test(TestRequest) returns (TestResponse) {
option (google.api.http) = {
get: "/test"
additional_bindings {
get: "/test2"
}
};
option (openapi.v3.operation) = {
operation_id: "test"
};
}
} The above will create two operations with the same |
But it's still because of the additional bindings which is a problem even without the custom operation id, isn't it? |
Correct. |
I'd treat it as a separate problem then (ie. see my earlier proposal for adding a counter at the end of the operation id). I guess you are aiming at allowing the operation id to be set for each additional binding which is probably doable, but can't be the only solution as not setting it can still yield duplications. |
The format of operationId can be changed like this, the first one is set as operationId, and the rest are set as operationId_method_path |
@Adol1111 The
|
This seems to be an unsolvable problem, unless we don't use additional_bindings, or there could be another field to be used as method name |
@silas @Adol1111 couldn't we allow users to set a comment with a custom |
@davikawasaki Lots of ways it could be solved, it's really whatever seems appropriate to the maintainers. I forked |
@silas is it a public fork that fix this issue? |
Sorry, no. In the end I just removed my usage of |
It looks like the changes merged in #367 generate duplicate
operationId
's.You can see this in the test example:
gnostic/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi.yaml
Line 13 in 3751138
gnostic/cmd/protoc-gen-openapi/examples/tests/additional_bindings/openapi.yaml
Line 37 in 3751138
According to the spec these must be unique:
In addition to the auto-generated
operationId
we'll need to figure out how to resolve it when manually applied:The text was updated successfully, but these errors were encountered: