Repository navigation
openapi: look up service comments by declaration index - #7600
Merged
johanbrandhorst merged 1 commit intoOct 29, 2026
Merged
johanbrandhorst merged 1 commit into
johanbrandhorst merged 1 commit into
Conversation
The registry leaves services without methods out of File.Services, but source code info paths use the index of the service declaration in the file. A service declared after an empty one therefore read the comments of the service before it: its tag got the empty service's description and its operations lost their summaries. Look the index up in the file's service declarations instead, in both protoc-gen-openapiv2 and protoc-gen-openapiv3. Co-Authored-By: Claude Opus 5.5 <[email protected]>
johanbrandhorst
enabled auto-merge (squash)
October 29, 2026 10:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
References to other Issues or PRs
Refs #746 (the case that still happens on main; the two-service example in the issue already works).
Have you read the Contributing Guidelines?
Yes.
Brief description of what is fixed or changed
The registry leaves services without methods out of
File.Services, but the source code info paths that hold comments use the index of the service declaration in the.protofile. Both generators used theFile.Servicesindex, so a service declared after an empty one reads the comments of the declaration before it:Here the
BookServicetag gets the description "Placeholder service." andGetBookhas no summary. WithEmpty, A, B, B's tag and operation get A's comments.The index is now looked up in the file's service declarations (
File.GetService()): in protoc-gen-openapiv2 throughfindServiceIndex, which replaces thesvcBaseIdxbookkeeping inrenderServices, and in protoc-gen-openapiv3 through aserviceIndexhelper used byserviceCommentsandmethodComments.Other comments
Added
TestGenerateCommentsAfterEmptyService(v2) andTestServiceAndMethodCommentsAfterEmptyService(v3); both fail without the change.I used Claude Code to write this change.