diff --git a/bytestream.go b/bytestream.go index f8fb482..98e9618 100644 --- a/bytestream.go +++ b/bytestream.go @@ -22,7 +22,7 @@ import ( "io" "reflect" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) func defaultCloser() error { return nil } @@ -206,7 +206,7 @@ func ByteStreamProducer(opts ...byteStreamOpt) Producer { return err case t.Kind() == reflect.Struct || t.Kind() == reflect.Slice: - b, err := swag.WriteJSON(data) + b, err := jsonutils.WriteJSON(data) if err != nil { return err } diff --git a/file.go b/file.go index 397d8a4..1bc6aab 100644 --- a/file.go +++ b/file.go @@ -14,6 +14,6 @@ package runtime -import "github.com/go-openapi/swag" +import "github.com/go-openapi/swag/fileutils" -type File = swag.File +type File = fileutils.File diff --git a/go.mod b/go.mod index e6d6590..064d006 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/go-openapi/loads v0.22.0 github.com/go-openapi/spec v0.21.0 github.com/go-openapi/strfmt v0.23.0 - github.com/go-openapi/swag v0.24.1 + github.com/go-openapi/swag/fileutils v0.24.0 github.com/go-openapi/validate v0.24.0 github.com/opentracing/opentracing-go v1.2.0 github.com/stretchr/testify v1.11.1 @@ -25,15 +25,15 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.22.0 // indirect github.com/go-openapi/jsonreference v0.21.1 // indirect + github.com/go-openapi/swag v0.24.1 // indirect github.com/go-openapi/swag/cmdutils v0.24.0 // indirect - github.com/go-openapi/swag/conv v0.24.0 // indirect - github.com/go-openapi/swag/fileutils v0.24.0 // indirect + github.com/go-openapi/swag/conv v0.24.0 github.com/go-openapi/swag/jsonname v0.24.0 // indirect - github.com/go-openapi/swag/jsonutils v0.24.0 // indirect + github.com/go-openapi/swag/jsonutils v0.24.0 github.com/go-openapi/swag/loading v0.24.0 // indirect github.com/go-openapi/swag/mangling v0.24.0 // indirect github.com/go-openapi/swag/netutils v0.24.0 // indirect - github.com/go-openapi/swag/stringutils v0.24.0 // indirect + github.com/go-openapi/swag/stringutils v0.24.0 github.com/go-openapi/swag/typeutils v0.24.0 // indirect github.com/go-openapi/swag/yamlutils v0.24.0 // indirect github.com/google/uuid v1.6.0 // indirect diff --git a/middleware/parameter.go b/middleware/parameter.go index 7da9b17..fb1b14b 100644 --- a/middleware/parameter.go +++ b/middleware/parameter.go @@ -24,12 +24,12 @@ import ( "strconv" "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" + "github.com/go-openapi/swag/stringutils" "github.com/go-openapi/validate" - - "github.com/go-openapi/runtime" ) const defaultMaxMemory = 32 << 20 @@ -331,7 +331,7 @@ func (p *untypedParamBinder) setFieldValue(target reflect.Value, defaultValue in } return nil } - b, err := swag.ConvertBool(data) + b, err := conv.ConvertBool(data) if err != nil { return err } @@ -455,7 +455,7 @@ func (p *untypedParamBinder) readFormattedSliceFieldValue(data string, target re return nil, true, nil } - return swag.SplitByFormat(data, p.parameter.CollectionFormat), false, nil + return stringutils.SplitByFormat(data, p.parameter.CollectionFormat), false, nil } func (p *untypedParamBinder) setSliceFieldValue(target reflect.Value, defaultValue interface{}, data []string, hasKey bool) error { diff --git a/middleware/router.go b/middleware/router.go index 96b748e..0f93179 100644 --- a/middleware/router.go +++ b/middleware/router.go @@ -31,7 +31,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/stringutils" ) // RouteParam is a object to capture route params in a framework agnostic way. @@ -460,11 +460,11 @@ func (d *defaultRouteBuilder) AddRoute(method, path string, operation *spec.Oper parameters := d.analyzer.ParamsFor(method, strings.TrimPrefix(path, bp)) // add API defaults if not part of the spec - if defConsumes := d.api.DefaultConsumes(); defConsumes != "" && !swag.ContainsStringsCI(consumes, defConsumes) { + if defConsumes := d.api.DefaultConsumes(); defConsumes != "" && !stringutils.ContainsStringsCI(consumes, defConsumes) { consumes = append(consumes, defConsumes) } - if defProduces := d.api.DefaultProduces(); defProduces != "" && !swag.ContainsStringsCI(produces, defProduces) { + if defProduces := d.api.DefaultProduces(); defProduces != "" && !stringutils.ContainsStringsCI(produces, defProduces) { produces = append(produces, defProduces) } diff --git a/middleware/string_conversion_test.go b/middleware/string_conversion_test.go index 2265b51..93bcae2 100644 --- a/middleware/string_conversion_test.go +++ b/middleware/string_conversion_test.go @@ -23,7 +23,7 @@ import ( "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/stringutils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -279,8 +279,8 @@ func TestSliceConversion(t *testing.T) { assert.Empty(t, tags) } - assert.Nil(t, swag.SplitByFormat("yada", "multi")) - assert.Nil(t, swag.SplitByFormat("", "")) + assert.Nil(t, stringutils.SplitByFormat("yada", "multi")) + assert.Nil(t, stringutils.SplitByFormat("", "")) categoriesField := val.FieldByName("Categories") binder := &untypedParamBinder{ diff --git a/middleware/validation.go b/middleware/validation.go index e581cd7..3879d75 100644 --- a/middleware/validation.go +++ b/middleware/validation.go @@ -20,9 +20,8 @@ import ( "strings" "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/runtime" + "github.com/go-openapi/swag/stringutils" ) type validation struct { @@ -30,7 +29,7 @@ type validation struct { result []error request *http.Request route *MatchedRoute - bound map[string]interface{} + bound map[string]any } // ContentType validates the content type of a request @@ -42,14 +41,14 @@ func validateContentType(allowed []string, actual string) error { if err != nil { return errors.InvalidContentType(actual, allowed) } - if swag.ContainsStringsCI(allowed, mt) { + if stringutils.ContainsStringsCI(allowed, mt) { return nil } - if swag.ContainsStringsCI(allowed, "*/*") { + if stringutils.ContainsStringsCI(allowed, "*/*") { return nil } parts := strings.Split(actual, "/") - if len(parts) == 2 && swag.ContainsStringsCI(allowed, parts[0]+"/*") { + if len(parts) == 2 && stringutils.ContainsStringsCI(allowed, parts[0]+"/*") { return nil } return errors.InvalidContentType(actual, allowed) @@ -60,7 +59,7 @@ func validateRequest(ctx *Context, request *http.Request, route *MatchedRoute) * context: ctx, request: request, route: route, - bound: make(map[string]interface{}), + bound: make(map[string]any), } validate.debugLogf("validating request %s %s", request.Method, request.URL.EscapedPath()) @@ -83,7 +82,7 @@ func (v *validation) parameters() { v.debugLogf("validating request parameters for %s %s", v.request.Method, v.request.URL.EscapedPath()) if result := v.route.Binder.Bind(v.request, v.route.Params, v.route.Consumer, v.bound); result != nil { if result.Error() == "validation failure list" { - for _, e := range result.(*errors.Validation).Value.([]interface{}) { + for _, e := range result.(*errors.Validation).Value.([]any) { v.result = append(v.result, e.(error)) } return diff --git a/request.go b/request.go index 3235201..203dab2 100644 --- a/request.go +++ b/request.go @@ -22,7 +22,7 @@ import ( "net/http" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/stringutils" ) // CanHaveBody returns true if this method can have a body @@ -145,5 +145,5 @@ func ReadSingleValue(values Gettable, name string) string { // ReadCollectionValue reads a collection value from a string data source func ReadCollectionValue(values Gettable, name, collectionFormat string) []string { v := ReadSingleValue(values, name) - return swag.SplitByFormat(v, collectionFormat) + return stringutils.SplitByFormat(v, collectionFormat) } diff --git a/text.go b/text.go index f33320b..d8dee94 100644 --- a/text.go +++ b/text.go @@ -22,7 +22,7 @@ import ( "io" "reflect" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // TextConsumer creates a new text consumer @@ -99,7 +99,7 @@ func TextProducer() Producer { v := reflect.Indirect(reflect.ValueOf(data)) if t := v.Type(); t.Kind() == reflect.Struct || t.Kind() == reflect.Slice { - b, err := swag.WriteJSON(data) + b, err := jsonutils.WriteJSON(data) if err != nil { return err }