swaggo / swag

Automatically generate RESTful API documentation with Swagger 2.0 for Go.
MIT License
10.49k stars 1.19k forks source link

Bug: --parseDependency generates documentation for external packages #1845

Closed dpanic closed 1 month ago

dpanic commented 1 month ago

Describe the bug When using Swaggo with the --parseDependency flag, route documentation is incorrectly generated from dependency packages. This behavior leads to unintended API routes being included in the generated documentation.

To Reproduce Steps to reproduce the behavior:

  1. Set up a basic Go project with external dependencies that have their own swagger annotations.
  2. Install Swaggo and run the command swag init --parseDependency.
  3. Observe that the generated docs include routes from the external dependencies.

Expected behavior I expected that only the routes from the main application would be documented. Routes from external dependencies should not be included unless explicitly specified.

Your swag version v1.16.3

Your go version go version go1.22.4 linux/amd64

Desktop (please complete the following information):

sdghchj commented 1 month ago

An alternative option can be used instead of --parseDependency. --parseDependencyLevel Parse go files inside dependency folder, 0 disabled, 1 only parse models, 2 only parse operations, 3 parse all. swag init --parseDependencyLevel 1

dpanic commented 1 month ago

An alternative option can be used instead of --parseDependency. --parseDependencyLevel Parse go files inside dependency folder, 0 disabled, 1 only parse models, 2 only parse operations, 3 parse all. swag init --parseDependencyLevel 1

Thank you, that works.