Skip to content

Commit

Permalink
Update dependencies and fix tests (#835)
Browse files Browse the repository at this point in the history
Upgrade github.com/go-openapi/spec and golang.org/x/tools to latest
versions.

Upgrading github.com/go-openapi/spec v0.19.11 -> v.0.19.14 generates
empty "description" members for responses and empty "authorizationUrl"
members for securityDefinitions when they're missing. This causes tests
to fail. Fix by adding the missing empty definitions to expected test
results.
  • Loading branch information
akojo committed Nov 19, 2020
1 parent 3f47d68 commit 2ca4d38
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
6 changes: 4 additions & 2 deletions go.mod
Expand Up @@ -5,22 +5,24 @@ require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/ghodss/yaml v1.0.0
github.com/gin-gonic/gin v1.6.3
github.com/go-openapi/spec v0.19.11
github.com/go-openapi/spec v0.19.14
github.com/go-openapi/swag v0.19.11 // indirect
github.com/go-playground/validator/v10 v10.4.1 // indirect
github.com/gofrs/uuid v3.3.0+incompatible
github.com/golang/protobuf v1.4.3 // indirect
github.com/json-iterator/go v1.1.10 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/shopspring/decimal v1.2.0
github.com/stretchr/testify v1.6.1
github.com/swaggo/cli v1.22.2 // indirect
github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14
github.com/swaggo/gin-swagger v1.3.0
github.com/urfave/cli/v2 v2.2.0
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 // indirect
golang.org/x/net v0.0.0-20201027133719-8eef5233e2a1 // indirect
golang.org/x/sys v0.0.0-20201028094953-708e7fb298ac // indirect
golang.org/x/text v0.3.4 // indirect
golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb
golang.org/x/tools v0.0.0-20201118030313-598b068a9102
google.golang.org/protobuf v1.25.0 // indirect
)

Expand Down
12 changes: 12 additions & 0 deletions go.sum
Expand Up @@ -12,6 +12,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -45,6 +47,8 @@ github.com/go-openapi/spec v0.19.0 h1:A4SZ6IWh3lnjH0rG0Z5lkxazMGBECtrZcbyYQi+64k
github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
github.com/go-openapi/spec v0.19.11 h1:ogU5q8dtp3MMPn59a9VRrPKVxvJHEs5P7yNMR5sNnis=
github.com/go-openapi/spec v0.19.11/go.mod h1:vqK/dIdLGCosfvYsQV3WfC7N3TiZSnGY2RZKoFK7X28=
github.com/go-openapi/spec v0.19.14 h1:r4fbYFo6N4ZelmSX8G6p+cv/hZRXzcuqQIADGT1iNKM=
github.com/go-openapi/spec v0.19.14/go.mod h1:gwrgJS15eCUgjLpMjBJmbZezCsw88LmgeEip0M63doA=
github.com/go-openapi/swag v0.17.0 h1:iqrgMg7Q7SvtbWLlltPrkMs0UBJI6oTSs79JFRUi880=
github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg=
github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY=
Expand Down Expand Up @@ -125,8 +129,12 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand All @@ -137,6 +145,8 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/swaggo/cli v1.22.2 h1:HcOuWl50wxecZWnAA3eIrf2XcOki3XeRK7HljCzP9Vg=
github.com/swaggo/cli v1.22.2/go.mod h1:mod7cSpILRjdhkgSKDd1HJFDMN4hopy6uH5pkXELHkM=
github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14 h1:PyYN9JH5jY9j6av01SpfRMb+1DWg/i3MbGOKPxJ2wjM=
github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14/go.mod h1:gxQT6pBGRuIGunNf/+tSOB5OHvguWi8Tbt82WOkf35E=
github.com/swaggo/gin-swagger v1.3.0 h1:eOmp7r57oUgZPw2dJOjcGNMse9cvXcI4tTqBcnZtPsI=
Expand Down Expand Up @@ -221,6 +231,8 @@ golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b/go.mod h1:/rFqwRUd4F7ZHNgw
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb h1:KVWk3RW1AZlxWum4tYqegLgwJHb5oouozcGM8HfNQaw=
golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20201118030313-598b068a9102 h1:kr6Ik/EJgxdTSLX+rSiDounHdHWMBu9Ks/ghr2hWNpo=
golang.org/x/tools v0.0.0-20201118030313-598b068a9102/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
Expand Down
6 changes: 4 additions & 2 deletions operation_test.go
Expand Up @@ -582,7 +582,7 @@ func TestParseResponseCommentWithObjectTypeInSameFile(t *testing.T) {
fset := token.NewFileSet()
astFile, err := goparser.ParseFile(fset, "operation_test.go", `package swag
type testOwner struct {
}
`, goparser.ParseComments)
assert.NoError(t, err)
Expand Down Expand Up @@ -733,7 +733,9 @@ func TestParseEmptyResponseOnlyCode(t *testing.T) {

expected := `{
"responses": {
"200": {}
"200": {
"description": ""
}
}
}`
assert.Equal(t, expected, string(b))
Expand Down
24 changes: 18 additions & 6 deletions parser_test.go
Expand Up @@ -71,6 +71,7 @@ func TestParser_ParseGeneralApiInfo(t *testing.T) {
"OAuth2Application": {
"type": "oauth2",
"flow": "application",
"authorizationUrl": "",
"tokenUrl": "https://example.com/oauth/token",
"scopes": {
"admin": " Grants read and write access to administrative information",
Expand All @@ -89,6 +90,7 @@ func TestParser_ParseGeneralApiInfo(t *testing.T) {
"OAuth2Password": {
"type": "oauth2",
"flow": "password",
"authorizationUrl": "",
"tokenUrl": "https://example.com/oauth/token",
"scopes": {
"admin": " Grants read and write access to administrative information",
Expand Down Expand Up @@ -152,6 +154,7 @@ func TestParser_ParseGeneralApiInfoTemplated(t *testing.T) {
"OAuth2Application": {
"type": "oauth2",
"flow": "application",
"authorizationUrl": "",
"tokenUrl": "https://example.com/oauth/token",
"scopes": {
"admin": " Grants read and write access to administrative information",
Expand All @@ -170,6 +173,7 @@ func TestParser_ParseGeneralApiInfoTemplated(t *testing.T) {
"OAuth2Password": {
"type": "oauth2",
"flow": "password",
"authorizationUrl": "",
"tokenUrl": "https://example.com/oauth/token",
"scopes": {
"admin": " Grants read and write access to administrative information",
Expand Down Expand Up @@ -742,6 +746,7 @@ func TestParseSimpleApi_ForSnakecase(t *testing.T) {
"OAuth2Application": {
"type": "oauth2",
"flow": "application",
"authorizationUrl": "",
"tokenUrl": "https://example.com/oauth/token",
"scopes": {
"admin": " Grants read and write access to administrative information",
Expand All @@ -760,6 +765,7 @@ func TestParseSimpleApi_ForSnakecase(t *testing.T) {
"OAuth2Password": {
"type": "oauth2",
"flow": "password",
"authorizationUrl": "",
"tokenUrl": "https://example.com/oauth/token",
"scopes": {
"admin": " Grants read and write access to administrative information",
Expand Down Expand Up @@ -1198,6 +1204,7 @@ func TestParseSimpleApi_ForLowerCamelcase(t *testing.T) {
"OAuth2Application": {
"type": "oauth2",
"flow": "application",
"authorizationUrl": "",
"tokenUrl": "https://example.com/oauth/token",
"scopes": {
"admin": " Grants read and write access to administrative information",
Expand All @@ -1216,6 +1223,7 @@ func TestParseSimpleApi_ForLowerCamelcase(t *testing.T) {
"OAuth2Password": {
"type": "oauth2",
"flow": "password",
"authorizationUrl": "",
"tokenUrl": "https://example.com/oauth/token",
"scopes": {
"admin": " Grants read and write access to administrative information",
Expand Down Expand Up @@ -1576,9 +1584,9 @@ type Response struct {
Code int
Table [][]string
Data []struct{
Field1 uint
Field2 string
}
Field1 uint
Field2 string
}
}
// @Success 200 {object} Response
Expand Down Expand Up @@ -1653,7 +1661,7 @@ func Test(){
package rest
type ResponseWrapper struct {
Status string
Status string
Code int
Messages []string
Result interface{}
Expand Down Expand Up @@ -2275,7 +2283,9 @@ func Fun() {
}
],
"responses": {
"200": {}
"200": {
"description": ""
}
}
}
}
Expand Down Expand Up @@ -2383,7 +2393,9 @@ func TestParseJSONFieldString(t *testing.T) {
"$ref": "#/definitions/main.MyStruct"
}
},
"500": {}
"500": {
"description": ""
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions testdata/simple/expected.json
Expand Up @@ -698,6 +698,7 @@
"OAuth2Application": {
"type": "oauth2",
"flow": "application",
"authorizationUrl": "",
"tokenUrl": "https://example.com/oauth/token",
"scopes": {
"admin": " Grants read and write access to administrative information",
Expand All @@ -716,6 +717,7 @@
"OAuth2Password": {
"type": "oauth2",
"flow": "password",
"authorizationUrl": "",
"tokenUrl": "https://example.com/oauth/token",
"scopes": {
"admin": " Grants read and write access to administrative information",
Expand Down

0 comments on commit 2ca4d38

Please sign in to comment.