Skip to content

Commit 73720f1

Browse files
committed
WIP: using go-json
Signed-off-by: Frederic BIDON <[email protected]>
1 parent 096f80c commit 73720f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+70
-50
lines changed

cache.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ package spec
1616

1717
import (
1818
"sync"
19-
20-
jsoniter "github.com/json-iterator/go"
2119
)
2220

2321
// ResolutionCache a cache for resolving urls
@@ -73,19 +71,14 @@ var (
7371
resCache *simpleCache
7472
onceCache sync.Once
7573

76-
_ ResolutionCache = &simpleCache{}
77-
json jsoniter.API
74+
_ ResolutionCache = &simpleCache{}
7875
)
7976

8077
// initResolutionCache initializes the URI resolution cache. To be wrapped in a sync.Once.Do call.
8178
func initResolutionCache() {
8279
resCache = defaultResolutionCache()
8380
}
8481

85-
func init() {
86-
json = jsoniter.ConfigFastest
87-
}
88-
8982
func defaultResolutionCache() *simpleCache {
9083
return &simpleCache{store: map[string]interface{}{
9184
"http://swagger.io/v2/schema.json": MustLoadSwagger20Schema(),

circular_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"testing"
99
"time"
1010

11+
json "github.com/goccy/go-json"
1112
"github.com/stretchr/testify/assert"
1213
"github.com/stretchr/testify/require"
1314
)

contact_info.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package spec
1616

1717
import (
1818
"github.com/go-openapi/swag"
19+
json "github.com/goccy/go-json"
1920
)
2021

2122
// ContactInfo contact information for the exposed API.

contact_info_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package spec
1717
import (
1818
"testing"
1919

20+
json "github.com/goccy/go-json"
2021
"github.com/stretchr/testify/assert"
2122
"github.com/stretchr/testify/require"
2223
)

expander.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
package spec
1616

1717
import (
18-
stdjson "encoding/json"
1918
"fmt"
19+
20+
json "github.com/goccy/go-json"
2021
)
2122

2223
// ExpandOptions provides options for the spec expander.
@@ -28,11 +29,11 @@ import (
2829
//
2930
// PathLoader injects a document loading method. By default, this resolves to the function provided by the SpecLoader package variable.
3031
type ExpandOptions struct {
31-
RelativeBase string // the path to the root document to expand. This is a file, not a directory
32-
SkipSchemas bool // do not expand schemas, just paths, parameters and responses
33-
ContinueOnError bool // continue expanding even after and error is found
34-
PathLoader func(string) (stdjson.RawMessage, error) `json:"-"` // the document loading method that takes a path as input and yields a json document
35-
AbsoluteCircularRef bool // circular $ref remaining after expansion remain absolute URLs
32+
RelativeBase string // the path to the root document to expand. This is a file, not a directory
33+
SkipSchemas bool // do not expand schemas, just paths, parameters and responses
34+
ContinueOnError bool // continue expanding even after and error is found
35+
PathLoader func(string) (json.RawMessage, error) `json:"-"` // the document loading method that takes a path as input and yields a json document
36+
AbsoluteCircularRef bool // circular $ref remaining after expansion remain absolute URLs
3637
}
3738

3839
func optionsOrDefault(opts *ExpandOptions) *ExpandOptions {

expander_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package spec
1616

1717
import (
18-
stdjson "encoding/json"
1918
"io"
2019
"log"
2120
"net/http"
@@ -24,6 +23,7 @@ import (
2423
"path/filepath"
2524
"testing"
2625

26+
json "github.com/goccy/go-json"
2727
"github.com/stretchr/testify/assert"
2828
"github.com/stretchr/testify/require"
2929
)
@@ -38,7 +38,7 @@ const (
3838

3939
var (
4040
// PetStoreJSONMessage json raw message for Petstore20
41-
PetStoreJSONMessage = stdjson.RawMessage([]byte(PetStore20))
41+
PetStoreJSONMessage = json.RawMessage([]byte(PetStore20))
4242
specs = filepath.Join("fixtures", "specs")
4343
)
4444

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ require (
44
github.com/go-openapi/jsonpointer v0.20.2
55
github.com/go-openapi/jsonreference v0.20.4
66
github.com/go-openapi/swag v0.22.6
7-
github.com/json-iterator/go v1.1.12
7+
github.com/goccy/go-json v0.10.2
88
github.com/stretchr/testify v1.8.4
99
gopkg.in/yaml.v3 v3.0.1
1010
)
@@ -13,8 +13,6 @@ require (
1313
github.com/davecgh/go-spew v1.1.1 // indirect
1414
github.com/josharian/intern v1.0.0 // indirect
1515
github.com/mailru/easyjson v0.7.7 // indirect
16-
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
17-
github.com/modern-go/reflect2 v1.0.2 // indirect
1816
github.com/pmezard/go-difflib v1.0.0 // indirect
1917
)
2018

go.sum

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
21
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
32
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
43
github.com/go-openapi/jsonpointer v0.20.2 h1:mQc3nmndL8ZBzStEo3JYF8wzmeWffDH4VbXz58sAx6Q=
@@ -7,25 +6,17 @@ github.com/go-openapi/jsonreference v0.20.4 h1:bKlDxQxQJgwpUSgOENiMPzCTBVuc7vTdX
76
github.com/go-openapi/jsonreference v0.20.4/go.mod h1:5pZJyJP2MnYCpoeoMAql78cCHauHj0V9Lhc506VOpw4=
87
github.com/go-openapi/swag v0.22.6 h1:dnqg1XfHXL9aBxSbktBqFR5CxVyVI+7fYWhAf1JOeTw=
98
github.com/go-openapi/swag v0.22.6/go.mod h1:Gl91UqO+btAM0plGGxHqJcQZ1ZTy6jbmridBTsDy8A0=
10-
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
9+
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
10+
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
1111
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
1212
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
13-
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
14-
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
1513
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
1614
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
1715
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
1816
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
19-
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
20-
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
21-
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
22-
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
23-
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
2417
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2518
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2619
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
27-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
28-
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
2920
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
3021
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
3122
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

header.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919

2020
"github.com/go-openapi/jsonpointer"
2121
"github.com/go-openapi/swag"
22+
json "github.com/goccy/go-json"
2223
)
2324

2425
const (

header_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"testing"
1919

2020
"github.com/go-openapi/swag"
21+
json "github.com/goccy/go-json"
2122
"github.com/stretchr/testify/assert"
2223
"github.com/stretchr/testify/require"
2324
)

0 commit comments

Comments
 (0)