Skip to content

fix: respect parseDepth for operations in the go list dependency walk#2175

Open
sharunkumar wants to merge 1 commit into
swaggo:masterfrom
sharunkumar:fix/golist-parsedepth-operation-scope
Open

fix: respect parseDepth for operations in the go list dependency walk#2175
sharunkumar wants to merge 1 commit into
swaggo:masterfrom
sharunkumar:fix/golist-parsedepth-operation-scope

Conversation

@sharunkumar

@sharunkumar sharunkumar commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Describe the PR
When parseGoList=true was specified, parseDepth was no longer being respected. This PR fixes that in a backwards compatible way

benchmarked for speed & correctness (comparing swagger.json before/after) on a large internal repository

Related issue
Fixes #1269

Additional Context

#2174 (comment)

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No longer respects --parseDepth when processing dependency tree

1 participant