google / google/gnostic

[proto-gen-openapi] Wrong message included when message with same name exists in imported proto

Open
#392 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.3k
Forks
279
PR merge metrics
No merged PRs in 30d

Description

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.

Reproduction: https://github.com/n0v1/gnostic-gen-openapi-naming-issue-repro (see readme and proto files for details)

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.

Relates to issues #309 and #353.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.