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 contact_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
12 changes: 9 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
24 changes: 18 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand Down
4 changes: 2 additions & 2 deletions header.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"strings"

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

const (
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
}
8 changes: 4 additions & 4 deletions helpers_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (
"strings"
"testing"

"github.com/go-openapi/swag"
"github.com/go-openapi/swag/loading"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

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
}
Expand Down
4 changes: 2 additions & 2 deletions info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions items.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"strings"

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

const (
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions items_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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,
},
},
Expand Down Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions license.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"sort"

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

func init() {
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions path_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down
7 changes: 4 additions & 3 deletions schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down
Loading
Loading