From c508ac64f881ae23ecde123763b3794ace740fd1 Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Sat, 30 Aug 2025 13:27:19 +0200 Subject: [PATCH] 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 --- contact_info.go | 4 ++-- go.mod | 12 +++++++++--- go.sum | 24 ++++++++++++++++++------ header.go | 4 ++-- header_test.go | 6 +++--- helpers_spec_test.go | 8 ++++---- helpers_test.go | 4 ++-- info.go | 4 ++-- items.go | 4 ++-- items_test.go | 10 +++++----- license.go | 4 ++-- operation.go | 4 ++-- parameter.go | 4 ++-- parameters_test.go | 6 +++--- path_item.go | 4 ++-- paths.go | 4 ++-- resolver.go | 4 ++-- response.go | 4 ++-- responses.go | 4 ++-- schema.go | 7 ++++--- schema_loader.go | 10 ++++++---- schema_test.go | 6 +++--- security_scheme.go | 4 ++-- swagger.go | 4 ++-- swagger_test.go | 4 ++-- tag.go | 4 ++-- validations_test.go | 20 ++++++++++---------- 27 files changed, 99 insertions(+), 78 deletions(-) diff --git a/contact_info.go b/contact_info.go index 2f7bb21..3eaa41e 100644 --- a/contact_info.go +++ b/contact_info.go @@ -17,7 +17,7 @@ package spec import ( "encoding/json" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // ContactInfo contact information for the exposed API. @@ -53,5 +53,5 @@ func (c ContactInfo) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - return swag.ConcatJSON(b1, b2), nil + return jsonutils.ConcatJSON(b1, b2), nil } diff --git a/go.mod b/go.mod index 13b7fa1..f2b30cb 100644 --- a/go.mod +++ b/go.mod @@ -1,15 +1,21 @@ module github.com/go-openapi/spec require ( - github.com/go-openapi/jsonpointer v0.21.2 - github.com/go-openapi/jsonreference v0.21.0 - github.com/go-openapi/swag v0.23.1 + github.com/go-openapi/jsonpointer v0.22.0 + github.com/go-openapi/jsonreference v0.21.1 + github.com/go-openapi/swag/conv v0.24.0 + github.com/go-openapi/swag/jsonname v0.24.0 + github.com/go-openapi/swag/jsonutils v0.24.0 + github.com/go-openapi/swag/loading v0.24.0 + github.com/go-openapi/swag/stringutils v0.24.0 github.com/stretchr/testify v1.11.1 gopkg.in/yaml.v3 v3.0.1 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-openapi/swag/typeutils v0.24.0 // indirect + github.com/go-openapi/swag/yamlutils v0.24.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/mailru/easyjson v0.9.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect diff --git a/go.sum b/go.sum index ce1c1fa..b4a24c0 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-openapi/jsonpointer v0.21.2 h1:AqQaNADVwq/VnkCmQg6ogE+M3FOsKTytwges0JdwVuA= -github.com/go-openapi/jsonpointer v0.21.2/go.mod h1:50I1STOfbY1ycR8jGz8DaMeLCdXiI6aDteEdRNNzpdk= -github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ= -github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4= -github.com/go-openapi/swag v0.23.1 h1:lpsStH0n2ittzTnbaSloVZLuB5+fvSY/+hnagBjSNZU= -github.com/go-openapi/swag v0.23.1/go.mod h1:STZs8TbRvEQQKUA+JZNAm3EWlgaOBGpyFDqQnDHMef0= +github.com/go-openapi/jsonpointer v0.22.0 h1:TmMhghgNef9YXxTu1tOopo+0BGEytxA+okbry0HjZsM= +github.com/go-openapi/jsonpointer v0.22.0/go.mod h1:xt3jV88UtExdIkkL7NloURjRQjbeUgcxFblMjq2iaiU= +github.com/go-openapi/jsonreference v0.21.1 h1:bSKrcl8819zKiOgxkbVNRUBIr6Wwj9KYrDbMjRs0cDA= +github.com/go-openapi/jsonreference v0.21.1/go.mod h1:PWs8rO4xxTUqKGu+lEvvCxD5k2X7QYkKAepJyCmSTT8= +github.com/go-openapi/swag/conv v0.24.0 h1:ejB9+7yogkWly6pnruRX45D1/6J+ZxRu92YFivx54ik= +github.com/go-openapi/swag/conv v0.24.0/go.mod h1:jbn140mZd7EW2g8a8Y5bwm8/Wy1slLySQQ0ND6DPc2c= +github.com/go-openapi/swag/jsonname v0.24.0 h1:2wKS9bgRV/xB8c62Qg16w4AUiIrqqiniJFtZGi3dg5k= +github.com/go-openapi/swag/jsonname v0.24.0/go.mod h1:GXqrPzGJe611P7LG4QB9JKPtUZ7flE4DOVechNaDd7Q= +github.com/go-openapi/swag/jsonutils v0.24.0 h1:F1vE1q4pg1xtO3HTyJYRmEuJ4jmIp2iZ30bzW5XgZts= +github.com/go-openapi/swag/jsonutils v0.24.0/go.mod h1:vBowZtF5Z4DDApIoxcIVfR8v0l9oq5PpYRUuteVu6f0= +github.com/go-openapi/swag/loading v0.24.0 h1:ln/fWTwJp2Zkj5DdaX4JPiddFC5CHQpvaBKycOlceYc= +github.com/go-openapi/swag/loading v0.24.0/go.mod h1:gShCN4woKZYIxPxbfbyHgjXAhO61m88tmjy0lp/LkJk= +github.com/go-openapi/swag/stringutils v0.24.0 h1:i4Z/Jawf9EvXOLUbT97O0HbPUja18VdBxeadyAqS1FM= +github.com/go-openapi/swag/stringutils v0.24.0/go.mod h1:5nUXB4xA0kw2df5PRipZDslPJgJut+NjL7D25zPZ/4w= +github.com/go-openapi/swag/typeutils v0.24.0 h1:d3szEGzGDf4L2y1gYOSSLeK6h46F+zibnEas2Jm/wIw= +github.com/go-openapi/swag/typeutils v0.24.0/go.mod h1:q8C3Kmk/vh2VhpCLaoR2MVWOGP8y7Jc8l82qCTd1DYI= +github.com/go-openapi/swag/yamlutils v0.24.0 h1:bhw4894A7Iw6ne+639hsBNRHg9iZg/ISrOVr+sJGp4c= +github.com/go-openapi/swag/yamlutils v0.24.0/go.mod h1:DpKv5aYuaGm/sULePoeiG8uwMpZSfReo1HR3Ik0yaG8= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= diff --git a/header.go b/header.go index 5957fa2..55c415e 100644 --- a/header.go +++ b/header.go @@ -19,7 +19,7 @@ import ( "strings" "github.com/go-openapi/jsonpointer" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) const ( @@ -161,7 +161,7 @@ func (h Header) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - return swag.ConcatJSON(b1, b2, b3), nil + return jsonutils.ConcatJSON(b1, b2, b3), nil } // UnmarshalJSON unmarshals this header from JSON diff --git a/header_test.go b/header_test.go index 2aad150..c0753e7 100644 --- a/header_test.go +++ b/header_test.go @@ -18,7 +18,7 @@ import ( "encoding/json" "testing" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -172,6 +172,6 @@ func TestWithHeader(t *testing.T) { } func TestHeaderWithValidation(t *testing.T) { - h := new(Header).WithValidations(CommonValidations{MaxLength: swag.Int64(15)}) - assert.Equal(t, swag.Int64(15), h.MaxLength) + h := new(Header).WithValidations(CommonValidations{MaxLength: conv.Pointer(int64(15))}) + assert.Equal(t, conv.Pointer(int64(15)), h.MaxLength) } diff --git a/helpers_spec_test.go b/helpers_spec_test.go index 4dd12c5..8999f0e 100644 --- a/helpers_spec_test.go +++ b/helpers_spec_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/go-openapi/spec" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/loading" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -21,10 +21,10 @@ var ( func init() { // mimics what the go-openapi/load does testLoader = func(path string) (json.RawMessage, error) { - if swag.YAMLMatcher(path) { - return swag.YAMLDoc(path) + if loading.YAMLMatcher(path) { + return loading.YAMLDoc(path) } - data, err := swag.LoadFromFileOrHTTP(path) + data, err := loading.LoadFromFileOrHTTP(path) if err != nil { return nil, err } diff --git a/helpers_test.go b/helpers_test.go index f16a4dd..4eaf8b4 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/loading" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -15,7 +15,7 @@ import ( var rex = regexp.MustCompile(`"\$ref":\s*"(.*?)"`) func jsonDoc(path string) (json.RawMessage, error) { - data, err := swag.LoadFromFileOrHTTP(path) + data, err := loading.LoadFromFileOrHTTP(path) if err != nil { return nil, err } diff --git a/info.go b/info.go index 582f0fd..695cd9a 100644 --- a/info.go +++ b/info.go @@ -20,7 +20,7 @@ import ( "strings" "github.com/go-openapi/jsonpointer" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // Extensions vendor specific extensions @@ -172,7 +172,7 @@ func (i Info) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - return swag.ConcatJSON(b1, b2), nil + return jsonutils.ConcatJSON(b1, b2), nil } // UnmarshalJSON marshal this from JSON diff --git a/items.go b/items.go index 7404bee..0224673 100644 --- a/items.go +++ b/items.go @@ -19,7 +19,7 @@ import ( "strings" "github.com/go-openapi/jsonpointer" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) const ( @@ -213,7 +213,7 @@ func (i Items) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - return swag.ConcatJSON(b4, b3, b1, b2), nil + return jsonutils.ConcatJSON(b4, b3, b1, b2), nil } // JSONLookup look up a value by the json property name diff --git a/items_test.go b/items_test.go index c1d3954..ed21795 100644 --- a/items_test.go +++ b/items_test.go @@ -18,7 +18,7 @@ import ( "encoding/json" "testing" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -142,8 +142,8 @@ func TestItemsBuilder(t *testing.T) { }, CommonValidations: CommonValidations{ Enum: []interface{}{[]string{"abc", "efg"}, []string{"hij"}}, - MinItems: swag.Int64(1), - MaxItems: swag.Int64(4), + MinItems: conv.Pointer(int64(1)), + MaxItems: conv.Pointer(int64(4)), UniqueItems: true, }, }, @@ -195,6 +195,6 @@ func TestJSONLookupItems(t *testing.T) { } func TestItemsWithValidation(t *testing.T) { - i := new(Items).WithValidations(CommonValidations{MaxLength: swag.Int64(15)}) - assert.Equal(t, swag.Int64(15), i.MaxLength) + i := new(Items).WithValidations(CommonValidations{MaxLength: conv.Pointer(int64(15))}) + assert.Equal(t, conv.Pointer(int64(15)), i.MaxLength) } diff --git a/license.go b/license.go index b42f803..09f54fe 100644 --- a/license.go +++ b/license.go @@ -17,7 +17,7 @@ package spec import ( "encoding/json" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // License information for the exposed API. @@ -52,5 +52,5 @@ func (l License) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - return swag.ConcatJSON(b1, b2), nil + return jsonutils.ConcatJSON(b1, b2), nil } diff --git a/operation.go b/operation.go index 5c7b6c6..9826219 100644 --- a/operation.go +++ b/operation.go @@ -21,7 +21,7 @@ import ( "sort" "github.com/go-openapi/jsonpointer" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) func init() { @@ -141,7 +141,7 @@ func (o Operation) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - concated := swag.ConcatJSON(b1, b2) + concated := jsonutils.ConcatJSON(b1, b2) return concated, nil } diff --git a/parameter.go b/parameter.go index 1363a2d..1dd8311 100644 --- a/parameter.go +++ b/parameter.go @@ -19,7 +19,7 @@ import ( "strings" "github.com/go-openapi/jsonpointer" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // QueryParam creates a query parameter @@ -322,5 +322,5 @@ func (p Parameter) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - return swag.ConcatJSON(b3, b1, b2, b4, b5), nil + return jsonutils.ConcatJSON(b3, b1, b2, b4, b5), nil } diff --git a/parameters_test.go b/parameters_test.go index 04955b2..2a730ff 100644 --- a/parameters_test.go +++ b/parameters_test.go @@ -18,7 +18,7 @@ import ( "encoding/json" "testing" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -163,6 +163,6 @@ func TestParameterGobEncoding(t *testing.T) { } func TestParametersWithValidation(t *testing.T) { - p := new(Parameter).WithValidations(CommonValidations{MaxLength: swag.Int64(15)}) - assert.Equal(t, swag.Int64(15), p.MaxLength) + p := new(Parameter).WithValidations(CommonValidations{MaxLength: conv.Pointer(int64(15))}) + assert.Equal(t, conv.Pointer(int64(15)), p.MaxLength) } diff --git a/path_item.go b/path_item.go index 68fc8e9..e51b810 100644 --- a/path_item.go +++ b/path_item.go @@ -18,7 +18,7 @@ import ( "encoding/json" "github.com/go-openapi/jsonpointer" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // PathItemProps the path item specific properties @@ -82,6 +82,6 @@ func (p PathItem) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - concated := swag.ConcatJSON(b3, b4, b5) + concated := jsonutils.ConcatJSON(b3, b4, b5) return concated, nil } diff --git a/paths.go b/paths.go index 42f65ff..b95eadc 100644 --- a/paths.go +++ b/paths.go @@ -19,7 +19,7 @@ import ( "fmt" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // Paths holds the relative paths to the individual endpoints. @@ -93,6 +93,6 @@ func (p Paths) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - concated := swag.ConcatJSON(b1, b2) + concated := jsonutils.ConcatJSON(b1, b2) return concated, nil } diff --git a/resolver.go b/resolver.go index 47d1ee1..dd577b0 100644 --- a/resolver.go +++ b/resolver.go @@ -3,7 +3,7 @@ package spec import ( "fmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) func resolveAnyWithBase(root interface{}, ref *Ref, result interface{}, options *ExpandOptions) error { @@ -45,7 +45,7 @@ func ResolveRef(root interface{}, ref *Ref) (*Schema, error) { return sch, nil case map[string]interface{}: newSch := new(Schema) - if err = swag.DynamicJSONToStruct(sch, newSch); err != nil { + if err = jsonutils.FromDynamicJSON(sch, newSch); err != nil { return nil, err } return newSch, nil diff --git a/response.go b/response.go index d71226f..edb60a5 100644 --- a/response.go +++ b/response.go @@ -18,7 +18,7 @@ import ( "encoding/json" "github.com/go-openapi/jsonpointer" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // ResponseProps properties specific to a response @@ -108,7 +108,7 @@ func (r Response) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - return swag.ConcatJSON(b1, b2, b3), nil + return jsonutils.ConcatJSON(b1, b2, b3), nil } // WithDescription sets the description on this response, allows for chaining diff --git a/responses.go b/responses.go index c133b17..337c6b1 100644 --- a/responses.go +++ b/responses.go @@ -21,7 +21,7 @@ import ( "strconv" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // Responses is a container for the expected responses of an operation. @@ -83,7 +83,7 @@ func (r Responses) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - concated := swag.ConcatJSON(b1, b2) + concated := jsonutils.ConcatJSON(b1, b2) return concated, nil } diff --git a/schema.go b/schema.go index c1043bc..0a49f2d 100644 --- a/schema.go +++ b/schema.go @@ -20,7 +20,8 @@ import ( "strings" "github.com/go-openapi/jsonpointer" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonname" + "github.com/go-openapi/swag/jsonutils" ) // BooleanProperty creates a boolean property @@ -593,7 +594,7 @@ func (s Schema) MarshalJSON() ([]byte, error) { } b6 = jj } - return swag.ConcatJSON(b1, b2, b3, b4, b5, b6), nil + return jsonutils.ConcatJSON(b1, b2, b3, b4, b5, b6), nil } // UnmarshalJSON marshal this from JSON @@ -621,7 +622,7 @@ func (s *Schema) UnmarshalJSON(data []byte) error { delete(d, "$ref") delete(d, "$schema") - for _, pn := range swag.DefaultJSONNameProvider.GetJSONNames(s) { + for _, pn := range jsonname.DefaultJSONNameProvider.GetJSONNames(s) { delete(d, pn) } diff --git a/schema_loader.go b/schema_loader.go index 3011ecd..328e5b8 100644 --- a/schema_loader.go +++ b/schema_loader.go @@ -22,7 +22,9 @@ import ( "reflect" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" + "github.com/go-openapi/swag/loading" + "github.com/go-openapi/swag/stringutils" ) // PathLoader is a function to use when loading remote refs. @@ -34,7 +36,7 @@ import ( // this value with its own default (a loader to retrieve YAML documents as // well as JSON ones). var PathLoader = func(pth string) (json.RawMessage, error) { - data, err := swag.LoadFromFileOrHTTP(pth) + data, err := loading.LoadFromFileOrHTTP(pth) if err != nil { return nil, err } @@ -166,7 +168,7 @@ func (r *schemaLoader) resolveRef(ref *Ref, target any, basePath string) error { return err } } - return swag.DynamicJSONToStruct(res, target) + return jsonutils.FromDynamicJSON(res, target) } func (r *schemaLoader) load(refURL *url.URL) (any, url.URL, bool, error) { @@ -208,7 +210,7 @@ func (r *schemaLoader) isCircular(ref *Ref, basePath string, parentRefs ...strin foundCycle = true return } - foundCycle = swag.ContainsStrings(parentRefs, normalizedRef) // normalized windows url's are lower cased + foundCycle = stringutils.ContainsStrings(parentRefs, normalizedRef) // normalized windows url's are lower cased if foundCycle { r.context.circulars[normalizedRef] = true } diff --git a/schema_test.go b/schema_test.go index 9f83de9..9b41d37 100644 --- a/schema_test.go +++ b/schema_test.go @@ -18,7 +18,7 @@ import ( "encoding/json" "testing" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -214,8 +214,8 @@ func BenchmarkSchemaUnmarshal(b *testing.B) { } func TestSchemaWithValidation(t *testing.T) { - s := new(Schema).WithValidations(SchemaValidations{CommonValidations: CommonValidations{MaxLength: swag.Int64(15)}}) - assert.Equal(t, swag.Int64(15), s.MaxLength) + s := new(Schema).WithValidations(SchemaValidations{CommonValidations: CommonValidations{MaxLength: conv.Pointer(int64(15))}}) + assert.Equal(t, conv.Pointer(int64(15)), s.MaxLength) val := mkVal() s = new(Schema).WithValidations(val) diff --git a/security_scheme.go b/security_scheme.go index 9d0bdae..2dfe934 100644 --- a/security_scheme.go +++ b/security_scheme.go @@ -18,7 +18,7 @@ import ( "encoding/json" "github.com/go-openapi/jsonpointer" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) const ( @@ -158,7 +158,7 @@ func (s SecurityScheme) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - return swag.ConcatJSON(b1, b2), nil + return jsonutils.ConcatJSON(b1, b2), nil } // UnmarshalJSON marshal this from JSON diff --git a/swagger.go b/swagger.go index 977c2f0..0e73759 100644 --- a/swagger.go +++ b/swagger.go @@ -22,7 +22,7 @@ import ( "strconv" "github.com/go-openapi/jsonpointer" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // Swagger this is the root document object for the API specification. @@ -54,7 +54,7 @@ func (s Swagger) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - return swag.ConcatJSON(b1, b2), nil + return jsonutils.ConcatJSON(b1, b2), nil } // UnmarshalJSON unmarshals a swagger spec from json diff --git a/swagger_test.go b/swagger_test.go index da260dd..265311a 100644 --- a/swagger_test.go +++ b/swagger_test.go @@ -129,7 +129,7 @@ const specJSON = `{ expectedType := reflect.TypeOf(expected) if reflect.TypeOf(actual).ConvertibleTo(expectedType) { expectedValue := reflect.ValueOf(expected) - if swag.IsZero(expectedValue) && swag.IsZero(reflect.ValueOf(actual)) { + if typeutil.IsZero(expectedValue) && typeutils.IsZero(reflect.ValueOf(actual)) { return true } @@ -162,7 +162,7 @@ const specJSON = `{ expectedType := reflect.TypeOf(expected) if reflect.TypeOf(actual).ConvertibleTo(expectedType) { expectedValue := reflect.ValueOf(expected) - if swag.IsZero(expectedValue) && swag.IsZero(reflect.ValueOf(actual)) { + if typeutils.IsZero(expectedValue) && typeutils.IsZero(reflect.ValueOf(actual)) { return "" } diff --git a/tag.go b/tag.go index 33ae73d..baf1f3d 100644 --- a/tag.go +++ b/tag.go @@ -18,7 +18,7 @@ import ( "encoding/json" "github.com/go-openapi/jsonpointer" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // TagProps describe a tag entry in the top level tags section of a swagger spec @@ -63,7 +63,7 @@ func (t Tag) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - return swag.ConcatJSON(b1, b2), nil + return jsonutils.ConcatJSON(b1, b2), nil } // UnmarshalJSON marshal this from JSON diff --git a/validations_test.go b/validations_test.go index e2d9d8c..2649e9f 100644 --- a/validations_test.go +++ b/validations_test.go @@ -3,32 +3,32 @@ package spec import ( "testing" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/stretchr/testify/require" ) func mkVal() SchemaValidations { return SchemaValidations{ CommonValidations: CommonValidations{ - Maximum: swag.Float64(2.5), + Maximum: conv.Pointer(2.5), ExclusiveMaximum: true, - Minimum: swag.Float64(3.4), + Minimum: conv.Pointer(3.4), ExclusiveMinimum: true, - MaxLength: swag.Int64(15), - MinLength: swag.Int64(16), + MaxLength: conv.Pointer(int64(15)), + MinLength: conv.Pointer(int64(16)), Pattern: "abc", - MaxItems: swag.Int64(17), - MinItems: swag.Int64(18), + MaxItems: conv.Pointer(int64(17)), + MinItems: conv.Pointer(int64(18)), UniqueItems: true, - MultipleOf: swag.Float64(4.4), + MultipleOf: conv.Pointer(4.4), Enum: []interface{}{"a", 12.5}, }, PatternProperties: SchemaProperties{ "x": *BooleanProperty(), "y": *BooleanProperty(), }, - MinProperties: swag.Int64(19), - MaxProperties: swag.Int64(20), + MinProperties: conv.Pointer(int64(19)), + MaxProperties: conv.Pointer(int64(20)), } }