Open dreamlu opened 1 year ago
hi @dreamlu can you provide your API swagger spec(swagger comments)? I think the problem is you use interface type in your spec.
I use this project, master branch: https://github.com/flipped-aurora/gin-vue-admin cd server go mod tidy
`
go install github.com/swaggo/swag/cmd/swag@v1.16.1
swag init
or
go install github.com/swaggo/swag/cmd/swag@v1.8.12
swag init
`
then, I met this bug in linux, I ask that project issue, they use mac and windows is right
Ok, @dreamlu but, as @jamshidi799 suggests, can you provide your API swagger spec(swagger comments)?
I have the same problem (paths is empty) while generating swagger spec for BFF kind of service. In this service repository root I have a bunch of directories like this:
./
./datauploader/handlers.go
./service1/handlers.go
./service2/handlers.go
...
Where each handlers.go
structured like this:
package datauploader
import (
"net/http"
// ...
)
type Handlers struct {
// ...
}
// CreateSignalsUploadsJson mlem mlem mlem
// @Router /signals/uploads/json [post]
// @Description uploads file with points for current user
// @Tags data-uploader
// @Accept multipart/form-data
// @Produce json
// @Success 202 {object} resputils.StdResp{result=*SignalsUploadWithJsonFormatResponse}
// @Failure default {object} resputils.ErrResp
// @Security Auth
func (h *Handlers) CreateSignalsUploadsJson(w http.ResponseWriter, r *http.Request) {
// ...
}
swag init --parseDependency --parseInternal --parseDepth 4 -o . -ot yaml
gives me swagger.yaml with paths: {}
for no obvious reason.
While swag fmt
is working for swag comments.
I have resolved my issue. Looks like swag
can't find Go executable, because this https://github.com/corpix/nixpkgs/commit/c0840ea4912ea1d691189c874e537c09f15f1441 fixed the issue (also swag
compiled from repository works fine)
I use this project, master branch: https://github.com/flipped-aurora/gin-vue-admin cd server go mod tidy
` go install github.com/swaggo/swag/cmd/swag@v1.16.1 swag init or
go install github.com/swaggo/swag/cmd/swag@v1.8.12 swag init ` then, I met this bug in linux, I ask that project issue, they use mac and windows is right
comment: // CreateApi // // @Tags SysApi // @Summary 创建基础api // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body system.SysApi true "api路径, api中文描述, api组, 方法" // @Success 200 {object} response.Response{msg=string} "创建基础api" // @Router /api/createApi [post] func (s SystemApiApi) CreateApi(c gin.Context) {
main: // @title Swagger Example API // @version 0.0.1 // @description This is a sample Server pets // @securityDefinitions.apikey ApiKeyAuth // @in header // @name x-token // @BasePath / func main() {
but use version swag v1.7.0 is ok related bug:https://github.com/flipped-aurora/gin-vue-admin/issues/1445 maybe this is swag bug os: debain golang: 1.20 swag: v1.7.0 is ok, v1.16.1 and v1.8.12 is has this bug
Describe the bug Unable to generate API in linux, swagger.json and swagger.yaml api is empty
To Reproduce Steps to reproduce the behavior:
Expected behavior generate api in docs/swagger.json
Screenshots
Your swag version v1.16.1
Your go version go 1.20.4
Desktop (please complete the following information):
Additional context v1.7.0 is right