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

No struct definition in swagger generate #3107

Open
sandip-bhoi-od opened this issue May 2, 2024 · 2 comments
Open

No struct definition in swagger generate #3107

sandip-bhoi-od opened this issue May 2, 2024 · 2 comments

Comments

@sandip-bhoi-od
Copy link

Problem statement

I am generating the swagger json by running below command

swagger generate spec -m -o ./doc/swagger.json

It generates the json, however it does not include the fields in the definition and only includes

"definitions": {
  "MyStruct": {
    "x-go-package": "github.com/myorg/my-service-repo/model/"
  }
}

I have the struct with swagger comments as below

// swagger:model MyStruct
type MyStruct struct {
	Field1 string `json:"field1" binding:"required"`
	Field2 string `json:"field2" binding:"required"`
}

Steps to reproduce

Generate swagger from root directory

swagger generate spec -m -o ./doc/swagger.json

Environment

swagger version
version: v0.30.5
commit: ab6a7885723430004f1d7db6395369b6e7f3370b
go version
go version go1.20.5 darwin/amd64
sw_vers
ProductName:            macOS
ProductVersion:         14.4.1
BuildVersion:           23E224
@sandip-bhoi-od
Copy link
Author

by setting env variable export SWAGGER_GENERATE_EXTENSION=false it eliminates x-go-package but still keeps the definitions empty

"definitions": {
  "MyStruct": {    
  }
}

@sandip-bhoi-od
Copy link
Author

I confirm that the issue is with the binary built. It works fine with installing the go module

go install github.com/go-swagger/go-swagger/cmd/swagger@latest

Please release the proper binary.

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

1 participant