You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[proto-gen-openapi] Wrong message included when message with same name exists in imported proto #392
We just noticed that gnostic's proto-gen-openapi may create a wrong OpenAPI v3 spec when a message with identical name exists in an imported proto even though the messages belong to different packages. This happens although the message from the imported proto is not used at all in the base proto.
The generated API spec only includes HelloWorld from bar.proto (which is not used anywhere). I would expect it to include HelloWorld from foo.proto instead. Even using the fully-qualified name com.example.foo.HelloWorld in FooResponse does not fix this.
Setting option fq_schema_naming=true fixes it but I think even without this option proto-gen-openapi should not create a wrong specification. It should at least give a warning or throw an error when a message/schema name is ambiguous.
I imported openapiv3/annotations.proto which has a message named Contact (actually in openapiv3/OpenAPIv3.proto) to set option (openapi.v3.document). And this Contact is not used in my own foo.proto.
At the same time, Contact has been defined and used in foo.proto (package foo)
proto-gen-openapi unexpectedly treats foo.Contact as openapi.v3.Contact completely when fq_schema_naming=false.
Activity
zaakn commentedon Nov 7, 2023
As a similar case:
I imported
openapiv3/annotations.protowhich has a message namedContact(actually inopenapiv3/OpenAPIv3.proto) to setoption (openapi.v3.document). And thisContactis not used in my ownfoo.proto.At the same time,
Contacthas been defined and used infoo.proto(package foo)proto-gen-openapiunexpectedly treatsfoo.Contactasopenapi.v3.Contactcompletely whenfq_schema_naming=false.fix: Select the corret schemas that correspond to the messages used