Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bytestream.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"io"
"reflect"

"github.com/go-openapi/swag"
"github.com/go-openapi/swag/jsonutils"
)

func defaultCloser() error { return nil }
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions middleware/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions middleware/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}

Expand Down
6 changes: 3 additions & 3 deletions middleware/string_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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{
Expand Down
15 changes: 7 additions & 8 deletions middleware/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ 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 {
context *Context
result []error
request *http.Request
route *MatchedRoute
bound map[string]interface{}
bound map[string]any
}

// ContentType validates the content type of a request
Expand All @@ -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)
Expand All @@ -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())

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions text.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"io"
"reflect"

"github.com/go-openapi/swag"
"github.com/go-openapi/swag/jsonutils"
)

// TextConsumer creates a new text consumer
Expand Down Expand Up @@ -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
}
Expand Down
Loading