swaggo / swag

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

swag init #1820

Closed Jerry-yz closed 6 days ago

Jerry-yz commented 1 month ago

Describe the bug A clear and concise description of what the bug is. when i use swag init generate docs.go, but this file has error, swag.Spec struct has not LeftDelim field and RightDelim field how can i fix it var SwaggerInfo = &swag.Spec{ Version: "", Host: "", BasePath: "", Schemes: []string{}, Title: "", Description: "", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, LeftDelim: "{{", RightDelim: "}}", } To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Your swag version e.g. 1.4.1 swag version v1.16.3 Your go version e.g. 1.12.0 go version go1.22.3 linux/amd64 Desktop (please complete the following information):

Additional context Add any other context about the problem here.

DrowningOtter commented 1 month ago

how to fix this ?

buckldav commented 1 month ago

As a workaround, I just removed those lines in my Dockerfile and everything ran fine.

RUN swag init
RUN sed -i s/LeftDelim.*//g ./docs/docs.go
RUN sed -i s/RightDelim.*//g ./docs/docs.go

My versions

DrowningOtter commented 1 month ago

got it, thanks!

Jerry-yz commented 1 month ago

As a workaround, I just removed those lines in my Dockerfile and everything ran fine.

RUN swag init
RUN sed -i s/LeftDelim.*//g ./docs/docs.go
RUN sed -i s/RightDelim.*//g ./docs/docs.go

My versions

  • github.com/swaggo/echo-swagger v1.4.1
  • github.com/swaggo/swag v1.16.3
  • go version go1.22.4 linux/amd64

only manual processing? have other methods? has bug in source code?

Danli741 commented 1 week ago

Please have a look at this closed issue: https://github.com/swaggo/swag/issues/1568

The solution with go get -u has worked by me