New Upstream Release - golang-github-go-openapi-spec
Ready changes
Summary
Merged new upstream version: 0.20.8 (was: 0.20.7).
Resulting package
Built on 2023-03-27T13:46 (took 7m49s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-releases golang-github-go-openapi-spec-dev
Lintian Result
Diff
diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml
new file mode 100644
index 0000000..79a485c
--- /dev/null
+++ b/.github/workflows/go-test.yml
@@ -0,0 +1,23 @@
+name: Go Test
+
+on: [push, pull_request]
+
+jobs:
+
+ test:
+
+ name: Test
+ runs-on: ${{ matrix.os }}
+
+ strategy:
+ matrix:
+ os: [ ubuntu-latest, macos-latest, windows-latest ]
+ steps:
+
+ - uses: actions/setup-go@v2
+ with:
+ go-version: 1.x
+
+ - uses: actions/checkout@v2
+
+ - run: go test
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 2281a07..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-after_success:
-- bash <(curl -s https://codecov.io/bash)
-go:
-- 1.16.x
-- 1.x
-arch:
- - amd64
-jobs:
- include:
- # only run fast tests on ppc64le
- - go: 1.x
- arch: ppc64le
- script:
- - gotestsum -f short-verbose -- ./...
-
- # include linting job, but only for latest go version and amd64 arch
- - go: 1.x
- arch: amd64
- install:
- go get github.com/golangci/golangci-lint/cmd/golangci-lint
- script:
- - golangci-lint run --new-from-rev master
-
-install:
-- GO111MODULE=off go get -u gotest.tools/gotestsum
-language: go
-notifications:
- slack:
- secure: QUWvCkBBK09GF7YtEvHHVt70JOkdlNBG0nIKu/5qc4/nW5HP8I2w0SEf/XR2je0eED1Qe3L/AfMCWwrEj+IUZc3l4v+ju8X8R3Lomhme0Eb0jd1MTMCuPcBT47YCj0M7RON7vXtbFfm1hFJ/jLe5+9FXz0hpXsR24PJc5ZIi/ogNwkaPqG4BmndzecpSh0vc2FJPZUD9LT0I09REY/vXR0oQAalLkW0asGD5taHZTUZq/kBpsNxaAFrLM23i4mUcf33M5fjLpvx5LRICrX/57XpBrDh2TooBU6Qj3CgoY0uPRYUmSNxbVx1czNzl2JtEpb5yjoxfVPQeg0BvQM00G8LJINISR+ohrjhkZmAqchDupAX+yFrxTtORa78CtnIL6z/aTNlgwwVD8kvL/1pFA/JWYmKDmz93mV/+6wubGzNSQCstzjkFA4/iZEKewKUoRIAi/fxyscP6L/rCpmY/4llZZvrnyTqVbt6URWpopUpH4rwYqreXAtJxJsfBJIeSmUIiDIOMGkCTvyTEW3fWGmGoqWtSHLoaWDyAIGb7azb+KvfpWtEcoPFWfSWU+LGee0A/YsUhBl7ADB9A0CJEuR8q4BPpKpfLwPKSiKSAXL7zDkyjExyhtgqbSl2jS+rKIHOZNL8JkCcTP2MKMVd563C5rC5FMKqu3S9m2b6380E=
-script:
-- gotestsum -f short-verbose -- -race -coverprofile=coverage.txt -covermode=atomic ./...
diff --git a/debian/changelog b/debian/changelog
index a1476cc..62d9e02 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+golang-github-go-openapi-spec (1:0.20.8-1) UNRELEASED; urgency=low
+
+ * New upstream release.
+ * Drop patch 0001-preserve-url.Parse-behaviour-before-go1.19.patch, present
+ upstream.
+ * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk> Mon, 27 Mar 2023 13:39:02 -0000
+
golang-github-go-openapi-spec (1:0.20.4-2) unstable; urgency=medium
* Team upload
diff --git a/debian/patches/0001-preserve-url.Parse-behaviour-before-go1.19.patch b/debian/patches/0001-preserve-url.Parse-behaviour-before-go1.19.patch
deleted file mode 100644
index b8867d0..0000000
--- a/debian/patches/0001-preserve-url.Parse-behaviour-before-go1.19.patch
+++ /dev/null
@@ -1,166 +0,0 @@
-From: Shengjing Zhu <zhsj@debian.org>
-Date: Fri, 12 Aug 2022 20:18:32 +0800
-Subject: preserve url.Parse behaviour before go1.19
-
-Forwarded: https://github.com/go-openapi/spec/pull/158
----
- normalizer.go | 11 +++++------
- normalizer_nonwindows.go | 3 ++-
- normalizer_windows.go | 4 ++--
- schema.go | 3 +--
- url_go18.go | 8 ++++++++
- url_go19.go | 14 ++++++++++++++
- 6 files changed, 32 insertions(+), 11 deletions(-)
- create mode 100644 url_go18.go
- create mode 100644 url_go19.go
-
-diff --git a/normalizer.go b/normalizer.go
-index d6c4839..e8b6009 100644
---- a/normalizer.go
-+++ b/normalizer.go
-@@ -40,7 +40,7 @@ const fileScheme = "file"
- //
- // The base path argument is assumed to be canonicalized (e.g. using normalizeBase()).
- func normalizeURI(refPath, base string) string {
-- refURL, err := url.Parse(refPath)
-+ refURL, err := parseURL(refPath)
- if err != nil {
- specLogger.Printf("warning: invalid URI in $ref %q: %v", refPath, err)
- refURL, refPath = repairURI(refPath)
-@@ -58,7 +58,7 @@ func normalizeURI(refPath, base string) string {
- return refURL.String()
- }
-
-- baseURL, _ := url.Parse(base)
-+ baseURL, _ := parseURL(base)
- if path.IsAbs(refURL.Path) {
- baseURL.Path = refURL.Path
- } else if refURL.Path != "" {
-@@ -84,7 +84,6 @@ func normalizeURI(refPath, base string) string {
- // There is a special case for schemas that are anchored with an "id":
- // in that case, the rebasing is performed // against the id only if this is an anchor for the initial root document.
- // All other intermediate "id"'s found along the way are ignored for the purpose of rebasing.
--//
- func denormalizeRef(ref *Ref, originalRelativeBase, id string) Ref {
- debugLog("denormalizeRef called:\n$ref: %q\noriginal: %s\nroot ID:%s", ref.String(), originalRelativeBase, id)
-
-@@ -94,7 +93,7 @@ func denormalizeRef(ref *Ref, originalRelativeBase, id string) Ref {
- }
-
- if id != "" {
-- idBaseURL, err := url.Parse(id)
-+ idBaseURL, err := parseURL(id)
- if err == nil { // if the schema id is not usable as a URI, ignore it
- if ref, ok := rebase(ref, idBaseURL, true); ok { // rebase, but keep references to root unchaged (do not want $ref: "")
- // $ref relative to the ID of the schema in the root document
-@@ -103,7 +102,7 @@ func denormalizeRef(ref *Ref, originalRelativeBase, id string) Ref {
- }
- }
-
-- originalRelativeBaseURL, _ := url.Parse(originalRelativeBase)
-+ originalRelativeBaseURL, _ := parseURL(originalRelativeBase)
-
- r, _ := rebase(ref, originalRelativeBaseURL, false)
-
-@@ -168,7 +167,7 @@ func normalizeRef(ref *Ref, relativeBase string) *Ref {
- //
- // See also: https://en.wikipedia.org/wiki/File_URI_scheme
- func normalizeBase(in string) string {
-- u, err := url.Parse(in)
-+ u, err := parseURL(in)
- if err != nil {
- specLogger.Printf("warning: invalid URI in RelativeBase %q: %v", in, err)
- u, in = repairURI(in)
-diff --git a/normalizer_nonwindows.go b/normalizer_nonwindows.go
-index c8a0645..2df0723 100644
---- a/normalizer_nonwindows.go
-+++ b/normalizer_nonwindows.go
-@@ -1,3 +1,4 @@
-+//go:build !windows
- // +build !windows
-
- // Copyright 2015 go-swagger maintainers
-@@ -34,7 +35,7 @@ func absPath(in string) string {
- }
-
- func repairURI(in string) (*url.URL, string) {
-- u, _ := url.Parse("")
-+ u, _ := parseURL("")
- debugLog("repaired URI: original: %q, repaired: %q", in, "")
- return u, ""
- }
-diff --git a/normalizer_windows.go b/normalizer_windows.go
-index fe2d1ec..a66c532 100644
---- a/normalizer_windows.go
-+++ b/normalizer_windows.go
-@@ -60,13 +60,13 @@ func repairURI(in string) (*url.URL, string) {
- const prefix = fileScheme + "://"
- if !strings.HasPrefix(in, prefix) {
- // giving up: resolve to empty path
-- u, _ := url.Parse("")
-+ u, _ := parseURL("")
-
- return u, ""
- }
-
- // attempt the repair, stripping the scheme should be sufficient
-- u, _ := url.Parse(strings.TrimPrefix(in, prefix))
-+ u, _ := parseURL(strings.TrimPrefix(in, prefix))
- debugLog("repaired URI: original: %q, repaired: %q", in, u.String())
-
- return u, u.String()
-diff --git a/schema.go b/schema.go
-index a8d0f73..4e9be85 100644
---- a/schema.go
-+++ b/schema.go
-@@ -17,7 +17,6 @@ package spec
- import (
- "encoding/json"
- "fmt"
-- "net/url"
- "strings"
-
- "github.com/go-openapi/jsonpointer"
-@@ -145,7 +144,7 @@ func (r *SchemaURL) fromMap(v map[string]interface{}) error {
- }
- if vv, ok := v["$schema"]; ok {
- if str, ok := vv.(string); ok {
-- u, err := url.Parse(str)
-+ u, err := parseURL(str)
- if err != nil {
- return err
- }
-diff --git a/url_go18.go b/url_go18.go
-new file mode 100644
-index 0000000..60b7851
---- /dev/null
-+++ b/url_go18.go
-@@ -0,0 +1,8 @@
-+//go:build !go1.19
-+// +build !go1.19
-+
-+package spec
-+
-+import "net/url"
-+
-+var parseURL = url.Parse
-diff --git a/url_go19.go b/url_go19.go
-new file mode 100644
-index 0000000..392e3e6
---- /dev/null
-+++ b/url_go19.go
-@@ -0,0 +1,14 @@
-+//go:build go1.19
-+// +build go1.19
-+
-+package spec
-+
-+import "net/url"
-+
-+func parseURL(s string) (*url.URL, error) {
-+ u, err := url.Parse(s)
-+ if err == nil {
-+ u.OmitHost = false
-+ }
-+ return u, err
-+}
diff --git a/debian/patches/series b/debian/patches/series
index cf8d328..e69de29 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +0,0 @@
-0001-preserve-url.Parse-behaviour-before-go1.19.patch
diff --git a/go.mod b/go.mod
index 39aab5f..9e3e36f 100644
--- a/go.mod
+++ b/go.mod
@@ -2,10 +2,9 @@ module github.com/go-openapi/spec
require (
github.com/go-openapi/jsonpointer v0.19.5
- github.com/go-openapi/jsonreference v0.19.6
+ github.com/go-openapi/jsonreference v0.20.0
github.com/go-openapi/swag v0.19.15
github.com/stretchr/testify v1.6.1
- golang.org/x/text v0.3.7 // indirect
gopkg.in/yaml.v2 v2.4.0
)
diff --git a/go.sum b/go.sum
index 3a2f522..7427dbd 100644
--- a/go.sum
+++ b/go.sum
@@ -1,17 +1,12 @@
-github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
-github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
-github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
-github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w=
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY=
github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
-github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs=
-github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns=
+github.com/go-openapi/jsonreference v0.20.0 h1:MYlu0sBgChmCfJxxUKZ8g1cPWFOB37YSZqewK7OKeyA=
+github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo=
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM=
github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
@@ -19,12 +14,10 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
-github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
-github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq0y3QnmWAArdw9PqbmotexnWx/FU8=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA=
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
@@ -33,19 +26,9 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-golang.org/x/net v0.0.0-20210421230115-4e50805a0758 h1:aEpZnXcAmXkd6AvLb2OPt+EN1Zu/8Ne3pCqPjja5PXY=
-golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
-golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
-golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
-golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
@@ -53,7 +36,6 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/normalizer.go b/normalizer.go
index d6c4839..e8b6009 100644
--- a/normalizer.go
+++ b/normalizer.go
@@ -40,7 +40,7 @@ const fileScheme = "file"
//
// The base path argument is assumed to be canonicalized (e.g. using normalizeBase()).
func normalizeURI(refPath, base string) string {
- refURL, err := url.Parse(refPath)
+ refURL, err := parseURL(refPath)
if err != nil {
specLogger.Printf("warning: invalid URI in $ref %q: %v", refPath, err)
refURL, refPath = repairURI(refPath)
@@ -58,7 +58,7 @@ func normalizeURI(refPath, base string) string {
return refURL.String()
}
- baseURL, _ := url.Parse(base)
+ baseURL, _ := parseURL(base)
if path.IsAbs(refURL.Path) {
baseURL.Path = refURL.Path
} else if refURL.Path != "" {
@@ -84,7 +84,6 @@ func normalizeURI(refPath, base string) string {
// There is a special case for schemas that are anchored with an "id":
// in that case, the rebasing is performed // against the id only if this is an anchor for the initial root document.
// All other intermediate "id"'s found along the way are ignored for the purpose of rebasing.
-//
func denormalizeRef(ref *Ref, originalRelativeBase, id string) Ref {
debugLog("denormalizeRef called:\n$ref: %q\noriginal: %s\nroot ID:%s", ref.String(), originalRelativeBase, id)
@@ -94,7 +93,7 @@ func denormalizeRef(ref *Ref, originalRelativeBase, id string) Ref {
}
if id != "" {
- idBaseURL, err := url.Parse(id)
+ idBaseURL, err := parseURL(id)
if err == nil { // if the schema id is not usable as a URI, ignore it
if ref, ok := rebase(ref, idBaseURL, true); ok { // rebase, but keep references to root unchaged (do not want $ref: "")
// $ref relative to the ID of the schema in the root document
@@ -103,7 +102,7 @@ func denormalizeRef(ref *Ref, originalRelativeBase, id string) Ref {
}
}
- originalRelativeBaseURL, _ := url.Parse(originalRelativeBase)
+ originalRelativeBaseURL, _ := parseURL(originalRelativeBase)
r, _ := rebase(ref, originalRelativeBaseURL, false)
@@ -168,7 +167,7 @@ func normalizeRef(ref *Ref, relativeBase string) *Ref {
//
// See also: https://en.wikipedia.org/wiki/File_URI_scheme
func normalizeBase(in string) string {
- u, err := url.Parse(in)
+ u, err := parseURL(in)
if err != nil {
specLogger.Printf("warning: invalid URI in RelativeBase %q: %v", in, err)
u, in = repairURI(in)
diff --git a/normalizer_nonwindows.go b/normalizer_nonwindows.go
index c8a0645..2df0723 100644
--- a/normalizer_nonwindows.go
+++ b/normalizer_nonwindows.go
@@ -1,3 +1,4 @@
+//go:build !windows
// +build !windows
// Copyright 2015 go-swagger maintainers
@@ -34,7 +35,7 @@ func absPath(in string) string {
}
func repairURI(in string) (*url.URL, string) {
- u, _ := url.Parse("")
+ u, _ := parseURL("")
debugLog("repaired URI: original: %q, repaired: %q", in, "")
return u, ""
}
diff --git a/normalizer_test.go b/normalizer_test.go
index 9eace0b..b152297 100644
--- a/normalizer_test.go
+++ b/normalizer_test.go
@@ -14,6 +14,24 @@ import (
const windowsOS = "windows"
+// only used for windows
+var currentDriveLetter = getCurrentDrive()
+
+// get the current drive letter in lowercase on windows that the test is running
+func getCurrentDrive() string {
+ if runtime.GOOS != windowsOS {
+ return ""
+ }
+ p, err := filepath.Abs("/")
+ if err != nil {
+ panic(err)
+ }
+ if len(p) == 0 {
+ panic("current windows drive letter is empty")
+ }
+ return strings.ToLower(string(p[0]))
+}
+
func TestNormalizer_NormalizeURI(t *testing.T) {
type testNormalizePathsTestCases []struct {
refPath string
@@ -299,7 +317,7 @@ func TestNormalizer_NormalizeBase(t *testing.T) {
{
// path clean
Base: "///folder//subfolder///file.json/",
- Expected: "file:///c:/folder/subfolder/file.json",
+ Expected: "file:///" + currentDriveLetter + ":/folder/subfolder/file.json",
Windows: true,
},
{
@@ -326,7 +344,7 @@ func TestNormalizer_NormalizeBase(t *testing.T) {
{
// handling dots (3/6): valid, cleaned to /c:/ on windows
Base: "/..",
- Expected: "file:///c:",
+ Expected: "file:///" + currentDriveLetter + ":",
Windows: true,
},
{
@@ -359,7 +377,7 @@ func TestNormalizer_NormalizeBase(t *testing.T) {
// windows-only cases
{
Base: "/base/sub/file.json",
- Expected: "file:///c:/base/sub/file.json", // on windows, filepath.Abs("/a/b") prepends the "c:" drive
+ Expected: "file:///" + currentDriveLetter + ":/base/sub/file.json", // on windows, filepath.Abs("/a/b") prepends the "c:" drive
Windows: true,
},
{
diff --git a/normalizer_windows.go b/normalizer_windows.go
index fe2d1ec..a66c532 100644
--- a/normalizer_windows.go
+++ b/normalizer_windows.go
@@ -60,13 +60,13 @@ func repairURI(in string) (*url.URL, string) {
const prefix = fileScheme + "://"
if !strings.HasPrefix(in, prefix) {
// giving up: resolve to empty path
- u, _ := url.Parse("")
+ u, _ := parseURL("")
return u, ""
}
// attempt the repair, stripping the scheme should be sufficient
- u, _ := url.Parse(strings.TrimPrefix(in, prefix))
+ u, _ := parseURL(strings.TrimPrefix(in, prefix))
debugLog("repaired URI: original: %q, repaired: %q", in, u.String())
return u, u.String()
diff --git a/schema.go b/schema.go
index a8d0f73..4e9be85 100644
--- a/schema.go
+++ b/schema.go
@@ -17,7 +17,6 @@ package spec
import (
"encoding/json"
"fmt"
- "net/url"
"strings"
"github.com/go-openapi/jsonpointer"
@@ -145,7 +144,7 @@ func (r *SchemaURL) fromMap(v map[string]interface{}) error {
}
if vv, ok := v["$schema"]; ok {
if str, ok := vv.(string); ok {
- u, err := url.Parse(str)
+ u, err := parseURL(str)
if err != nil {
return err
}
diff --git a/url_go18.go b/url_go18.go
new file mode 100644
index 0000000..60b7851
--- /dev/null
+++ b/url_go18.go
@@ -0,0 +1,8 @@
+//go:build !go1.19
+// +build !go1.19
+
+package spec
+
+import "net/url"
+
+var parseURL = url.Parse
diff --git a/url_go19.go b/url_go19.go
new file mode 100644
index 0000000..392e3e6
--- /dev/null
+++ b/url_go19.go
@@ -0,0 +1,14 @@
+//go:build go1.19
+// +build go1.19
+
+package spec
+
+import "net/url"
+
+func parseURL(s string) (*url.URL, error) {
+ u, err := url.Parse(s)
+ if err == nil {
+ u.OmitHost = false
+ }
+ return u, err
+}
Debdiff
File lists identical (after any substitutions)
No differences were encountered in the control files