swaggo / swag

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

Swag ignores package path if it starts with vendor #1880

Open syed-shah-zepto opened 1 week ago

syed-shah-zepto commented 1 week ago

Describe the bug I was running swag in my package -> vendor-service. But due to a vendor prefix check, all the files are being ignored and swagger docs are not generated.

To Reproduce Steps to reproduce the behavior:

  1. Create a package with starts with "vendor"
  2. Add an API and swagger annotation to that API
  3. Run swag init
  4. Check docs/swagger.json does not have the swagger documentation data

Expected behavior Swagger documentation should get generated similar to packages that don't start with "vendor"

Your swag version v1.16.3

Your go version 1.21.6

syed-shah-zepto commented 1 week ago

As info.PackagePath will always have the prefix of the package where swag was run, do we need this check? If we do can we restrict it to vendor/ paths?

Would be happy to raise a PR to get this fixed.