Open smatric opened 2 years ago
Exactly the same issue for me. There is no way to specify a rule
We release https://github.com/swaggo/swag/pull/1209 in 1.8.4
Not sure if I'm doing something wrong, but it still doesn't work for me with 1.8.4. Swagger still shows null.String
like this in the example value:
{
"title": {
"string": "string",
"valid": true
},
}
What it should look like:
{
"title": "string"
}
I tried all variations listed above in the .swaggo
file:
replace null.String string
replace gopkg.in/guregu/null.v4/null.String string
replace gopkg.in/guregu/null.v4@v4.0.0/null.String string
replace gopkg.in/guregu/null.v4.null.String string
replace gopkg.in/guregu/null.v4@v4.0.0.null.String string
The struct looks like this (other fields omitted):
type Employee struct {
Title null.String `db:"title" json:"title"`
}
I updated the module to 1.8.4 and running the command didn't work either. I had to recompile the executable:
$ go get -u github.com/swaggo/swag/cmd/swag
$ go install github.com/swaggo/swag/cmd/swag@latest
Then running the following command worked for me:
swag init -g api.go --outputTypes "go,json" --overridesFile docs/.swaggo
My .swaggo file:
replace null.String string
(The first line in yours looks fine.)
My struct:
type params struct {
Test null.String `json:"test" form:"test" validate:"gte=-999,lte=999"`
// other fields
}
Interesting. I'll try this tomorrow! Thanks for sharing.
Works just fine, thanks again.
Makes sense you have to update the CLI as well, oversight on my part.
I am unable to override
null.Int
in .swaggo file.handler.go:
I tried running swag init with any of the lines below in .swaggo and none of them worked (I also tried "integer" instead of "int"):
output:
Swag version: 1.8.1 Go version: go1.17.5 darwin/arm64 OS: macOS 12.3.1