Skip to content

Commit e935aa9

Browse files
committed
chore: adopted swag v0.24.0 modules
go-openapi has introduced a new API to better insulate dependencies. We move to the new modules, even though at this stage this doesn't change our indirect dependencies. Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
1 parent 26ddb24 commit e935aa9

27 files changed

+99
-78
lines changed

contact_info.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package spec
1717
import (
1818
"encoding/json"
1919

20-
"github.com/go-openapi/swag"
20+
"github.com/go-openapi/swag/jsonutils"
2121
)
2222

2323
// ContactInfo contact information for the exposed API.
@@ -53,5 +53,5 @@ func (c ContactInfo) MarshalJSON() ([]byte, error) {
5353
if err != nil {
5454
return nil, err
5555
}
56-
return swag.ConcatJSON(b1, b2), nil
56+
return jsonutils.ConcatJSON(b1, b2), nil
5757
}

go.mod

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
module github.com/go-openapi/spec
22

33
require (
4-
github.com/go-openapi/jsonpointer v0.21.2
5-
github.com/go-openapi/jsonreference v0.21.0
6-
github.com/go-openapi/swag v0.23.1
4+
github.com/go-openapi/jsonpointer v0.22.0
5+
github.com/go-openapi/jsonreference v0.21.1
6+
github.com/go-openapi/swag/conv v0.24.0
7+
github.com/go-openapi/swag/jsonname v0.24.0
8+
github.com/go-openapi/swag/jsonutils v0.24.0
9+
github.com/go-openapi/swag/loading v0.24.0
10+
github.com/go-openapi/swag/stringutils v0.24.0
711
github.com/stretchr/testify v1.11.1
812
gopkg.in/yaml.v3 v3.0.1
913
)
1014

1115
require (
1216
github.com/davecgh/go-spew v1.1.1 // indirect
17+
github.com/go-openapi/swag/typeutils v0.24.0 // indirect
18+
github.com/go-openapi/swag/yamlutils v0.24.0 // indirect
1319
github.com/josharian/intern v1.0.0 // indirect
1420
github.com/mailru/easyjson v0.9.0 // indirect
1521
github.com/pmezard/go-difflib v1.0.0 // indirect

go.sum

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
22
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3-
github.com/go-openapi/jsonpointer v0.21.2 h1:AqQaNADVwq/VnkCmQg6ogE+M3FOsKTytwges0JdwVuA=
4-
github.com/go-openapi/jsonpointer v0.21.2/go.mod h1:50I1STOfbY1ycR8jGz8DaMeLCdXiI6aDteEdRNNzpdk=
5-
github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ=
6-
github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4=
7-
github.com/go-openapi/swag v0.23.1 h1:lpsStH0n2ittzTnbaSloVZLuB5+fvSY/+hnagBjSNZU=
8-
github.com/go-openapi/swag v0.23.1/go.mod h1:STZs8TbRvEQQKUA+JZNAm3EWlgaOBGpyFDqQnDHMef0=
3+
github.com/go-openapi/jsonpointer v0.22.0 h1:TmMhghgNef9YXxTu1tOopo+0BGEytxA+okbry0HjZsM=
4+
github.com/go-openapi/jsonpointer v0.22.0/go.mod h1:xt3jV88UtExdIkkL7NloURjRQjbeUgcxFblMjq2iaiU=
5+
github.com/go-openapi/jsonreference v0.21.1 h1:bSKrcl8819zKiOgxkbVNRUBIr6Wwj9KYrDbMjRs0cDA=
6+
github.com/go-openapi/jsonreference v0.21.1/go.mod h1:PWs8rO4xxTUqKGu+lEvvCxD5k2X7QYkKAepJyCmSTT8=
7+
github.com/go-openapi/swag/conv v0.24.0 h1:ejB9+7yogkWly6pnruRX45D1/6J+ZxRu92YFivx54ik=
8+
github.com/go-openapi/swag/conv v0.24.0/go.mod h1:jbn140mZd7EW2g8a8Y5bwm8/Wy1slLySQQ0ND6DPc2c=
9+
github.com/go-openapi/swag/jsonname v0.24.0 h1:2wKS9bgRV/xB8c62Qg16w4AUiIrqqiniJFtZGi3dg5k=
10+
github.com/go-openapi/swag/jsonname v0.24.0/go.mod h1:GXqrPzGJe611P7LG4QB9JKPtUZ7flE4DOVechNaDd7Q=
11+
github.com/go-openapi/swag/jsonutils v0.24.0 h1:F1vE1q4pg1xtO3HTyJYRmEuJ4jmIp2iZ30bzW5XgZts=
12+
github.com/go-openapi/swag/jsonutils v0.24.0/go.mod h1:vBowZtF5Z4DDApIoxcIVfR8v0l9oq5PpYRUuteVu6f0=
13+
github.com/go-openapi/swag/loading v0.24.0 h1:ln/fWTwJp2Zkj5DdaX4JPiddFC5CHQpvaBKycOlceYc=
14+
github.com/go-openapi/swag/loading v0.24.0/go.mod h1:gShCN4woKZYIxPxbfbyHgjXAhO61m88tmjy0lp/LkJk=
15+
github.com/go-openapi/swag/stringutils v0.24.0 h1:i4Z/Jawf9EvXOLUbT97O0HbPUja18VdBxeadyAqS1FM=
16+
github.com/go-openapi/swag/stringutils v0.24.0/go.mod h1:5nUXB4xA0kw2df5PRipZDslPJgJut+NjL7D25zPZ/4w=
17+
github.com/go-openapi/swag/typeutils v0.24.0 h1:d3szEGzGDf4L2y1gYOSSLeK6h46F+zibnEas2Jm/wIw=
18+
github.com/go-openapi/swag/typeutils v0.24.0/go.mod h1:q8C3Kmk/vh2VhpCLaoR2MVWOGP8y7Jc8l82qCTd1DYI=
19+
github.com/go-openapi/swag/yamlutils v0.24.0 h1:bhw4894A7Iw6ne+639hsBNRHg9iZg/ISrOVr+sJGp4c=
20+
github.com/go-openapi/swag/yamlutils v0.24.0/go.mod h1:DpKv5aYuaGm/sULePoeiG8uwMpZSfReo1HR3Ik0yaG8=
921
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
1022
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
1123
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=

header.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"strings"
2020

2121
"github.com/go-openapi/jsonpointer"
22-
"github.com/go-openapi/swag"
22+
"github.com/go-openapi/swag/jsonutils"
2323
)
2424

2525
const (
@@ -161,7 +161,7 @@ func (h Header) MarshalJSON() ([]byte, error) {
161161
if err != nil {
162162
return nil, err
163163
}
164-
return swag.ConcatJSON(b1, b2, b3), nil
164+
return jsonutils.ConcatJSON(b1, b2, b3), nil
165165
}
166166

167167
// UnmarshalJSON unmarshals this header from JSON

header_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"encoding/json"
1919
"testing"
2020

21-
"github.com/go-openapi/swag"
21+
"github.com/go-openapi/swag/conv"
2222
"github.com/stretchr/testify/assert"
2323
"github.com/stretchr/testify/require"
2424
)
@@ -172,6 +172,6 @@ func TestWithHeader(t *testing.T) {
172172
}
173173

174174
func TestHeaderWithValidation(t *testing.T) {
175-
h := new(Header).WithValidations(CommonValidations{MaxLength: swag.Int64(15)})
176-
assert.Equal(t, swag.Int64(15), h.MaxLength)
175+
h := new(Header).WithValidations(CommonValidations{MaxLength: conv.Pointer(int64(15))})
176+
assert.Equal(t, conv.Pointer(int64(15)), h.MaxLength)
177177
}

helpers_spec_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"testing"
99

1010
"github.com/go-openapi/spec"
11-
"github.com/go-openapi/swag"
11+
"github.com/go-openapi/swag/loading"
1212
"github.com/stretchr/testify/assert"
1313
"github.com/stretchr/testify/require"
1414
)
@@ -21,10 +21,10 @@ var (
2121
func init() {
2222
// mimics what the go-openapi/load does
2323
testLoader = func(path string) (json.RawMessage, error) {
24-
if swag.YAMLMatcher(path) {
25-
return swag.YAMLDoc(path)
24+
if loading.YAMLMatcher(path) {
25+
return loading.YAMLDoc(path)
2626
}
27-
data, err := swag.LoadFromFileOrHTTP(path)
27+
data, err := loading.LoadFromFileOrHTTP(path)
2828
if err != nil {
2929
return nil, err
3030
}

helpers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import (
77
"strings"
88
"testing"
99

10-
"github.com/go-openapi/swag"
10+
"github.com/go-openapi/swag/loading"
1111
"github.com/stretchr/testify/assert"
1212
"github.com/stretchr/testify/require"
1313
)
1414

1515
var rex = regexp.MustCompile(`"\$ref":\s*"(.*?)"`)
1616

1717
func jsonDoc(path string) (json.RawMessage, error) {
18-
data, err := swag.LoadFromFileOrHTTP(path)
18+
data, err := loading.LoadFromFileOrHTTP(path)
1919
if err != nil {
2020
return nil, err
2121
}

info.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"strings"
2121

2222
"github.com/go-openapi/jsonpointer"
23-
"github.com/go-openapi/swag"
23+
"github.com/go-openapi/swag/jsonutils"
2424
)
2525

2626
// Extensions vendor specific extensions
@@ -172,7 +172,7 @@ func (i Info) MarshalJSON() ([]byte, error) {
172172
if err != nil {
173173
return nil, err
174174
}
175-
return swag.ConcatJSON(b1, b2), nil
175+
return jsonutils.ConcatJSON(b1, b2), nil
176176
}
177177

178178
// UnmarshalJSON marshal this from JSON

items.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"strings"
2020

2121
"github.com/go-openapi/jsonpointer"
22-
"github.com/go-openapi/swag"
22+
"github.com/go-openapi/swag/jsonutils"
2323
)
2424

2525
const (
@@ -213,7 +213,7 @@ func (i Items) MarshalJSON() ([]byte, error) {
213213
if err != nil {
214214
return nil, err
215215
}
216-
return swag.ConcatJSON(b4, b3, b1, b2), nil
216+
return jsonutils.ConcatJSON(b4, b3, b1, b2), nil
217217
}
218218

219219
// JSONLookup look up a value by the json property name

items_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"encoding/json"
1919
"testing"
2020

21-
"github.com/go-openapi/swag"
21+
"github.com/go-openapi/swag/conv"
2222
"github.com/stretchr/testify/assert"
2323
"github.com/stretchr/testify/require"
2424
)
@@ -142,8 +142,8 @@ func TestItemsBuilder(t *testing.T) {
142142
},
143143
CommonValidations: CommonValidations{
144144
Enum: []interface{}{[]string{"abc", "efg"}, []string{"hij"}},
145-
MinItems: swag.Int64(1),
146-
MaxItems: swag.Int64(4),
145+
MinItems: conv.Pointer(int64(1)),
146+
MaxItems: conv.Pointer(int64(4)),
147147
UniqueItems: true,
148148
},
149149
},
@@ -195,6 +195,6 @@ func TestJSONLookupItems(t *testing.T) {
195195
}
196196

197197
func TestItemsWithValidation(t *testing.T) {
198-
i := new(Items).WithValidations(CommonValidations{MaxLength: swag.Int64(15)})
199-
assert.Equal(t, swag.Int64(15), i.MaxLength)
198+
i := new(Items).WithValidations(CommonValidations{MaxLength: conv.Pointer(int64(15))})
199+
assert.Equal(t, conv.Pointer(int64(15)), i.MaxLength)
200200
}

0 commit comments

Comments
 (0)