Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion protoc-gen-openapiv2/internal/genopenapi/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ func TestGenerateExtension(t *testing.T) {
name: "Test"
input_type: ".example.v1.Foo"
output_type: ".example.v1.Foo"
options: {}
options: {
[google.api.http]: {
get: "/v1/test"
}
}
}
}
options: {
Expand Down
6 changes: 6 additions & 0 deletions protoc-gen-openapiv2/internal/genopenapi/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,12 @@ func findServicesMessagesAndEnumerations(s []*descriptor.Service, reg *descripto
continue
}

// Only process methods with HTTP bindings (exposed via HTTP annotations)
// This prevents unused message definitions from appearing in the OpenAPI document
if len(meth.Bindings) == 0 {
continue
}

swgReqName, ok := fullyQualifiedNameToOpenAPIName(meth.RequestType.FQMN(), reg)
if !ok {
grpclog.Errorf("couldn't resolve OpenAPI name for FQMN %q", meth.RequestType.FQMN())
Expand Down
Loading