Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swaggo generates SwaggerInfo var in Mac, but it generates SwaggerInfo_swagger var in Windows 10 #1132

Closed
yusrilmr opened this issue Feb 9, 2022 · 2 comments

Comments

@yusrilmr
Copy link

yusrilmr commented Feb 9, 2022

Describe the bug
In mac, when I execute swag init, it generates docs/docs.go as it should.
I can also define in the runtime the host as described in the guideline
For example: docs.SwaggerInfo.Host = "petstore.swagger.io"

However, when I tried it in windows 10, it generates a different variable name, which is SwaggerInfo_swagger in docs/docs.go.
As a consequence, I have to update my runtime code to something like docs.SwaggerInfo_swagger.Host = "petstore.swagger.io"

To Reproduce
Steps to reproduce the behavior:

  1. Use Windows 10 OS
  2. Go to your Golang project that has Swaggo installed
  3. Execute swag init
  4. Try to set the host during run time (docs.SwaggerInfo.Host="petstore.swagger.io")
  5. It will complain that it cannot find SwaggerInfo, where in Mac environment, it works just fine.
  6. Then, you have to fix the one in windows by changing it to SwaggerInfo_swagger

Expected behavior
When generating in Windows 10, the variable name should be SwaggerInfo instead of SwaggerInfo_swagger.
This difference makes working in a team where we have different PCs (Windows and Mac) a bit more tricky since every time one of us generates the spec, we have to also update the runtime code.

Screenshots
In Mac, where it works perfect
Mac 1
Mac 2

In Windows 10, where it somehow adds this _swagger
windows 1
windows 2

Your swag version
v1.7.9

Your go version
1.17

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: irrelevant
  • Version: irrelevant
@ubogdan
Copy link
Contributor

ubogdan commented Feb 9, 2022

Please use swag 1.7.9-p1 so SwaggerInfo won't have the _swagger prefix.
see #1126

install via cmd line or download the binary from the release page.
go install github.com/swaggo/swag/cmd/swag@v1.7.9-p1

@yusrilmr
Copy link
Author

I just tested it and it works. Thanks!
Anw, thanks for the awesome library!

@ubogdan ubogdan closed this as completed Jun 18, 2022
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

No branches or pull requests

2 participants