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

[Bug] Incorrectly generated docs/docs.go file #1895

Closed
acraig-pytilia opened this issue Oct 4, 2024 · 4 comments
Closed

[Bug] Incorrectly generated docs/docs.go file #1895

acraig-pytilia opened this issue Oct 4, 2024 · 4 comments

Comments

@acraig-pytilia
Copy link

acraig-pytilia commented Oct 4, 2024

Describe the bug
swag init command generates incorrect docs.go file causing the application to crash upon importing

To Reproduce
Steps to reproduce the behavior:

  1. Document main function with godoc @tags
  2. Import the docs module
  3. Run swag init
  4. Run go run <main_file>.go
  5. See error (in screenshots section)

Expected behavior
The docs.go file should be be generated with all the correct fields

Actual behavior
The file is generated with fields that are not present in the struct definition
Perhaps these fields were removed in a previous release with the docs.go template not being updated?

Screenshots
image
image

Your swag version

  • 1.16.3 (latest at time of bug submission)
  • also present in 1.16.2

Your go version

  • 1.21.13

Desktop (please complete the following information):

  • OS: Debian 12 (Docker)
@ubogdan
Copy link
Contributor

ubogdan commented Oct 19, 2024

Actually, your app doesn't build 😄

I guess you are using the latest swag version and you missed updating swago/swag version in go.mod.
So go get github.com/swaggo/swag@latest in the project root directory should save you from the trouble.

@acraig-pytilia
Copy link
Author

@ubogdan
I don't think this is the case, as I hadn't touched any other version than latest, until I first encountered the issue.

And as I said before, I've been running this in docker, where on container start, it installs the latest version. This issue occurs on a fresh container build

@ubogdan
Copy link
Contributor

ubogdan commented Oct 21, 2024

It's ok not to believe me, The template delimiters were introduced in #1499 and they were released in v1.16.1,

Please look on go.mod and tell me what version of github.com/swaggo/swag you have.

@acraig-pytilia
Copy link
Author

My apologies, you were right. It seems to be fine now on the latest version, v1.16.4, after defining this in go.mod
I'm just confused how it could have installed a version other than the one specified with me always providing @latest?

In any case, it is working now. Thank you

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