fix: respect parseDepth for operations in the go list dependency walk#2175
Open
sharunkumar wants to merge 1 commit into
Open
fix: respect parseDepth for operations in the go list dependency walk#2175sharunkumar wants to merge 1 commit into
sharunkumar wants to merge 1 commit into
Conversation
The go list dependency path (--parseGoList=true) parsed every package in the transitive closure for operations as well as models, ignoring --parseDepth (unlike the depth.Resolve walker, which honours it). In multi-binary repositories this pulls @Router/@id annotations from packages the target binary never registers, producing bloated specs and spurious "duplicated @id" errors. Fixes swaggo#1269 (and the related swaggo#1347). When --parseDepth is explicitly set, limit operation parsing to packages within that import distance of the root/search-dir packages, computed via a breadth-first walk over the go list import graph. Packages beyond the depth still contribute their type definitions (ParseModels is retained), so the full closure remains available for schema resolution and no go/loader fallback is reintroduced. When --parseDepth is not set, behaviour is unchanged (ParseDepthSet gates the new path). Co-authored-by: claude-opus-4-8
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.
Describe the PR
When
parseGoList=truewas specified,parseDepthwas no longer being respected. This PR fixes that in a backwards compatible waybenchmarked for speed & correctness (comparing swagger.json before/after) on a large internal repository
Related issue
Fixes #1269
Additional Context
#2174 (comment)