Merged in feature/s3integration (pull request #47)
Set Up S3 integration * cfginterfaceandfirsts3funcs * addlocalstack * generallypassesfullsuite * addedmultipleattemptedpings * cleanup * stabiliseplusskip
This commit is contained in:
+35
-15
@@ -4,38 +4,58 @@ linters-settings:
|
||||
golint:
|
||||
min-confidence: 0
|
||||
gocyclo:
|
||||
min-complexity: 30
|
||||
min-complexity: 45
|
||||
maligned:
|
||||
suggest-new: true
|
||||
dupl:
|
||||
threshold: 100
|
||||
threshold: 200
|
||||
goconst:
|
||||
min-len: 2
|
||||
min-occurrences: 4
|
||||
min-occurrences: 3
|
||||
|
||||
linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
- maligned
|
||||
- unparam
|
||||
- lll
|
||||
- gochecknoinits
|
||||
- gochecknoglobals
|
||||
- funlen
|
||||
- godox
|
||||
- gocognit
|
||||
- whitespace
|
||||
- wsl
|
||||
- funlen
|
||||
- gochecknoglobals
|
||||
- gochecknoinits
|
||||
- scopelint
|
||||
- wrapcheck
|
||||
- exhaustivestruct
|
||||
- exhaustive
|
||||
- nlreturn
|
||||
- testpackage
|
||||
- gci
|
||||
- gofumpt
|
||||
- goerr113
|
||||
- nlreturn
|
||||
- gomnd
|
||||
- tparallel
|
||||
- exhaustivestruct
|
||||
- goerr113
|
||||
- errorlint
|
||||
- nestif
|
||||
- godot
|
||||
- errorlint
|
||||
- gofumpt
|
||||
- paralleltest
|
||||
- tparallel
|
||||
- thelper
|
||||
- ifshort
|
||||
- exhaustruct
|
||||
- varnamelen
|
||||
- gci
|
||||
- depguard
|
||||
- errchkjson
|
||||
- inamedparam
|
||||
- nonamedreturns
|
||||
- musttag
|
||||
- ireturn
|
||||
- forcetypeassert
|
||||
- cyclop
|
||||
# deprecated linters
|
||||
- deadcode
|
||||
- interfacer
|
||||
- scopelint
|
||||
- varcheck
|
||||
- structcheck
|
||||
- golint
|
||||
- nosnakecase
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
go:
|
||||
- 1.14.x
|
||||
- 1.x
|
||||
install:
|
||||
- go get gotest.tools/gotestsum
|
||||
jobs:
|
||||
include:
|
||||
# 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
|
||||
env:
|
||||
- GO111MODULE=on
|
||||
language: go
|
||||
notifications:
|
||||
slack:
|
||||
secure: OpQG/36F7DSF00HLm9WZMhyqFCYYyYTsVDObW226cWiR8PWYiNfLZiSEvIzT1Gx4dDjhigKTIqcLhG34CkL5iNXDjm9Yyo2RYhQPlK8NErNqUEXuBqn4RqYHW48VGhEhOyDd4Ei0E2FN5ZbgpvHgtpkdZ6XDi64r3Ac89isP9aPHXQTuv2Jog6b4/OKKiUTftLcTIst0p4Cp3gqOJWf1wnoj+IadWiECNVQT6zb47IYjtyw6+uV8iUjTzdKcRB6Zc6b4Dq7JAg1Zd7Jfxkql3hlKp4PNlRf9Cy7y5iA3G7MLyg3FcPX5z2kmcyPt2jOTRMBWUJ5zIQpOxizAcN8WsT3WWBL5KbuYK6k0PzujrIDLqdxGpNmjkkMfDBT9cKmZpm2FdW+oZgPFJP+oKmAo4u4KJz/vjiPTXgQlN5bmrLuRMCp+AwC5wkIohTqWZVPE2TK6ZSnMYcg/W39s+RP/9mJoyryAvPSpBOLTI+biCgaUCTOAZxNTWpMFc3tPYntc41WWkdKcooZ9JA5DwfcaVFyTGQ3YXz+HvX6G1z/gW0Q/A4dBi9mj2iE1xm7tRTT+4VQ2AXFvSEI1HJpfPgYnwAtwOD1v3Qm2EUHk9sCdtEDR4wVGEPIVn44GnwFMnGKx9JWppMPYwFu3SVDdHt+E+LOlhZUply11Aa+IVrT2KUQ=
|
||||
script:
|
||||
- gotestsum -f short-verbose -- -race -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
+9
-5
@@ -1,15 +1,19 @@
|
||||
# gojsonreference [](https://travis-ci.org/go-openapi/jsonreference) [](https://codecov.io/gh/go-openapi/jsonreference) [](https://slackin.goswagger.io)
|
||||
# gojsonreference [](https://github.com/go-openapi/jsonreference/actions?query=workflow%3A"go+test") [](https://codecov.io/gh/go-openapi/jsonreference)
|
||||
|
||||
[](https://slackin.goswagger.io)
|
||||
[](https://raw.githubusercontent.com/go-openapi/jsonreference/master/LICENSE)
|
||||
[](https://pkg.go.dev/github.com/go-openapi/jsonreference)
|
||||
[](https://goreportcard.com/report/github.com/go-openapi/jsonreference)
|
||||
|
||||
[](https://raw.githubusercontent.com/go-openapi/jsonreference/master/LICENSE) [](http://godoc.org/github.com/go-openapi/jsonreference)
|
||||
An implementation of JSON Reference - Go language
|
||||
|
||||
## Status
|
||||
Feature complete. Stable API
|
||||
|
||||
## Dependencies
|
||||
https://github.com/go-openapi/jsonpointer
|
||||
* https://github.com/go-openapi/jsonpointer
|
||||
|
||||
## References
|
||||
http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07
|
||||
|
||||
http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03
|
||||
* http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07
|
||||
* http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03
|
||||
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultHTTPPort = ":80"
|
||||
defaultHTTPSPort = ":443"
|
||||
)
|
||||
|
||||
// Regular expressions used by the normalizations
|
||||
var rxPort = regexp.MustCompile(`(:\d+)/?$`)
|
||||
var rxDupSlashes = regexp.MustCompile(`/{2,}`)
|
||||
|
||||
// NormalizeURL will normalize the specified URL
|
||||
// This was added to replace a previous call to the no longer maintained purell library:
|
||||
// The call that was used looked like the following:
|
||||
//
|
||||
// url.Parse(purell.NormalizeURL(parsed, purell.FlagsSafe|purell.FlagRemoveDuplicateSlashes))
|
||||
//
|
||||
// To explain all that was included in the call above, purell.FlagsSafe was really just the following:
|
||||
// - FlagLowercaseScheme
|
||||
// - FlagLowercaseHost
|
||||
// - FlagRemoveDefaultPort
|
||||
// - FlagRemoveDuplicateSlashes (and this was mixed in with the |)
|
||||
//
|
||||
// This also normalizes the URL into its urlencoded form by removing RawPath and RawFragment.
|
||||
func NormalizeURL(u *url.URL) {
|
||||
lowercaseScheme(u)
|
||||
lowercaseHost(u)
|
||||
removeDefaultPort(u)
|
||||
removeDuplicateSlashes(u)
|
||||
|
||||
u.RawPath = ""
|
||||
u.RawFragment = ""
|
||||
}
|
||||
|
||||
func lowercaseScheme(u *url.URL) {
|
||||
if len(u.Scheme) > 0 {
|
||||
u.Scheme = strings.ToLower(u.Scheme)
|
||||
}
|
||||
}
|
||||
|
||||
func lowercaseHost(u *url.URL) {
|
||||
if len(u.Host) > 0 {
|
||||
u.Host = strings.ToLower(u.Host)
|
||||
}
|
||||
}
|
||||
|
||||
func removeDefaultPort(u *url.URL) {
|
||||
if len(u.Host) > 0 {
|
||||
scheme := strings.ToLower(u.Scheme)
|
||||
u.Host = rxPort.ReplaceAllStringFunc(u.Host, func(val string) string {
|
||||
if (scheme == "http" && val == defaultHTTPPort) || (scheme == "https" && val == defaultHTTPSPort) {
|
||||
return ""
|
||||
}
|
||||
return val
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func removeDuplicateSlashes(u *url.URL) {
|
||||
if len(u.Path) > 0 {
|
||||
u.Path = rxDupSlashes.ReplaceAllString(u.Path, "/")
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -30,8 +30,8 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/PuerkitoBio/purell"
|
||||
"github.com/go-openapi/jsonpointer"
|
||||
"github.com/go-openapi/jsonreference/internal"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -114,7 +114,9 @@ func (r *Ref) parse(jsonReferenceString string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
r.referenceURL, _ = url.Parse(purell.NormalizeURL(parsed, purell.FlagsSafe|purell.FlagRemoveDuplicateSlashes))
|
||||
internal.NormalizeURL(parsed)
|
||||
|
||||
r.referenceURL = parsed
|
||||
refURL := r.referenceURL
|
||||
|
||||
if refURL.Scheme != "" && refURL.Host != "" {
|
||||
|
||||
+1
-2
@@ -1,2 +1 @@
|
||||
secrets.yml
|
||||
coverage.out
|
||||
*.out
|
||||
|
||||
+20
-1
@@ -11,7 +11,7 @@ linters-settings:
|
||||
threshold: 200
|
||||
goconst:
|
||||
min-len: 2
|
||||
min-occurrences: 2
|
||||
min-occurrences: 3
|
||||
|
||||
linters:
|
||||
enable-all: true
|
||||
@@ -40,3 +40,22 @@ linters:
|
||||
- tparallel
|
||||
- thelper
|
||||
- ifshort
|
||||
- exhaustruct
|
||||
- varnamelen
|
||||
- gci
|
||||
- depguard
|
||||
- errchkjson
|
||||
- inamedparam
|
||||
- nonamedreturns
|
||||
- musttag
|
||||
- ireturn
|
||||
- forcetypeassert
|
||||
- cyclop
|
||||
# deprecated linters
|
||||
- deadcode
|
||||
- interfacer
|
||||
- scopelint
|
||||
- varcheck
|
||||
- structcheck
|
||||
- golint
|
||||
- nosnakecase
|
||||
|
||||
-31
@@ -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 ./...
|
||||
+24
-4
@@ -1,8 +1,5 @@
|
||||
# OAI object model
|
||||
# OpenAPI v2 object model [](https://github.com/go-openapi/spec/actions?query=workflow%3A"go+test") [](https://codecov.io/gh/go-openapi/spec)
|
||||
|
||||
[](https://travis-ci.org/go-openapi/spec)
|
||||
<!-- [](https://ci.appveyor.com/project/casualjim/go-openapi/spec/branch/master) -->
|
||||
[](https://codecov.io/gh/go-openapi/spec)
|
||||
[](https://slackin.goswagger.io)
|
||||
[](https://raw.githubusercontent.com/go-openapi/spec/master/LICENSE)
|
||||
[](https://pkg.go.dev/github.com/go-openapi/spec)
|
||||
@@ -32,3 +29,26 @@ The object model for OpenAPI specification documents.
|
||||
> This [discussion thread](https://github.com/go-openapi/spec/issues/21) relates the full story.
|
||||
>
|
||||
> An early attempt to support Swagger 3 may be found at: https://github.com/go-openapi/spec3
|
||||
|
||||
* Does the unmarshaling support YAML?
|
||||
|
||||
> Not directly. The exposed types know only how to unmarshal from JSON.
|
||||
>
|
||||
> In order to load a YAML document as a Swagger spec, you need to use the loaders provided by
|
||||
> github.com/go-openapi/loads
|
||||
>
|
||||
> Take a look at the example there: https://pkg.go.dev/github.com/go-openapi/loads#example-Spec
|
||||
>
|
||||
> See also https://github.com/go-openapi/spec/issues/164
|
||||
|
||||
* How can I validate a spec?
|
||||
|
||||
> Validation is provided by [the validate package](http://github.com/go-openapi/validate)
|
||||
|
||||
* Why do we have an `ID` field for `Schema` which is not part of the swagger spec?
|
||||
|
||||
> We found jsonschema compatibility more important: since `id` in jsonschema influences
|
||||
> how `$ref` are resolved.
|
||||
> This `id` does not conflict with any property named `id`.
|
||||
>
|
||||
> See also https://github.com/go-openapi/spec/issues/23
|
||||
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
version: "0.1.{build}"
|
||||
|
||||
clone_folder: C:\go-openapi\spec
|
||||
shallow_clone: true # for startup speed
|
||||
pull_requests:
|
||||
do_not_increment_build_number: true
|
||||
|
||||
#skip_tags: true
|
||||
#skip_branch_with_pr: true
|
||||
|
||||
# appveyor.yml
|
||||
build: off
|
||||
|
||||
environment:
|
||||
GOPATH: c:\gopath
|
||||
|
||||
stack: go 1.15
|
||||
|
||||
test_script:
|
||||
- go test -v -timeout 20m ./...
|
||||
|
||||
deploy: off
|
||||
|
||||
notifications:
|
||||
- provider: Slack
|
||||
incoming_webhook: https://hooks.slack.com/services/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
|
||||
auth_token:
|
||||
secure: Sf7kZf7ZGbnwWUMpffHwMu5A0cHkLK2MYY32LNTPj4+/3qC3Ghl7+9v4TSLOqOlCwdRNjOGblAq7s+GDJed6/xgRQl1JtCi1klzZNrYX4q01pgTPvvGcwbBkIYgeMaPeIRcK9OZnud7sRXdttozgTOpytps2U6Js32ip7uj5mHSg2ub0FwoSJwlS6dbezZ8+eDhoha0F/guY99BEwx8Bd+zROrT2TFGsSGOFGN6wFc7moCqTHO/YkWib13a2QNXqOxCCVBy/lt76Wp+JkeFppjHlzs/2lP3EAk13RIUAaesdEUHvIHrzCyNJEd3/+KO2DzsWOYfpktd+KBCvgaYOsoo7ubdT3IROeAegZdCgo/6xgCEsmFc9ZcqCfN5yNx2A+BZ2Vwmpws+bQ1E1+B5HDzzaiLcYfG4X2O210QVGVDLWsv1jqD+uPYeHY2WRfh5ZsIUFvaqgUEnwHwrK44/8REAhQavt1QAj5uJpsRd7CkRVPWRNK+yIky+wgbVUFEchRNmS55E7QWf+W4+4QZkQi7vUTMc9nbTUu2Es9NfvfudOpM2wZbn98fjpb/qq/nRv6Bk+ca+7XD5/IgNLMbWp2ouDdzbiHLCOfDUiHiDJhLfFZx9Bwo7ZwfzeOlbrQX66bx7xRKYmOe4DLrXhNcpbsMa8qbfxlZRCmYbubB/Y8h4=
|
||||
channel: bots
|
||||
on_build_success: false
|
||||
on_build_failure: true
|
||||
on_build_status_changed: true
|
||||
-297
File diff suppressed because one or more lines are too long
+17
@@ -0,0 +1,17 @@
|
||||
package spec
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"path"
|
||||
)
|
||||
|
||||
//go:embed schemas/*.json schemas/*/*.json
|
||||
var assets embed.FS
|
||||
|
||||
func jsonschemaDraft04JSONBytes() ([]byte, error) {
|
||||
return assets.ReadFile(path.Join("schemas", "jsonschema-draft-04.json"))
|
||||
}
|
||||
|
||||
func v2SchemaJSONBytes() ([]byte, error) {
|
||||
return assets.ReadFile(path.Join("schemas", "v2", "schema.json"))
|
||||
}
|
||||
+45
-32
@@ -27,7 +27,6 @@ import (
|
||||
// all relative $ref's will be resolved from there.
|
||||
//
|
||||
// PathLoader injects a document loading method. By default, this resolves to the function provided by the SpecLoader package variable.
|
||||
//
|
||||
type ExpandOptions struct {
|
||||
RelativeBase string // the path to the root document to expand. This is a file, not a directory
|
||||
SkipSchemas bool // do not expand schemas, just paths, parameters and responses
|
||||
@@ -58,7 +57,7 @@ func ExpandSpec(spec *Swagger, options *ExpandOptions) error {
|
||||
if !options.SkipSchemas {
|
||||
for key, definition := range spec.Definitions {
|
||||
parentRefs := make([]string, 0, 10)
|
||||
parentRefs = append(parentRefs, fmt.Sprintf("#/definitions/%s", key))
|
||||
parentRefs = append(parentRefs, "#/definitions/"+key)
|
||||
|
||||
def, err := expandSchema(definition, parentRefs, resolver, specBasePath)
|
||||
if resolver.shouldStopOnError(err) {
|
||||
@@ -103,15 +102,21 @@ const rootBase = ".root"
|
||||
|
||||
// baseForRoot loads in the cache the root document and produces a fake ".root" base path entry
|
||||
// for further $ref resolution
|
||||
//
|
||||
// Setting the cache is optional and this parameter may safely be left to nil.
|
||||
func baseForRoot(root interface{}, cache ResolutionCache) string {
|
||||
if root == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
// cache the root document to resolve $ref's
|
||||
normalizedBase := normalizeBase(rootBase)
|
||||
|
||||
if root == nil {
|
||||
// ensure that we never leave a nil root: always cache the root base pseudo-document
|
||||
cachedRoot, found := cache.Get(normalizedBase)
|
||||
if found && cachedRoot != nil {
|
||||
// the cache is already preloaded with a root
|
||||
return normalizedBase
|
||||
}
|
||||
|
||||
root = map[string]interface{}{}
|
||||
}
|
||||
|
||||
cache.Set(normalizedBase, root)
|
||||
|
||||
return normalizedBase
|
||||
@@ -208,7 +213,19 @@ func expandSchema(target Schema, parentRefs []string, resolver *schemaLoader, ba
|
||||
}
|
||||
|
||||
if target.Ref.String() != "" {
|
||||
return expandSchemaRef(target, parentRefs, resolver, basePath)
|
||||
if !resolver.options.SkipSchemas {
|
||||
return expandSchemaRef(target, parentRefs, resolver, basePath)
|
||||
}
|
||||
|
||||
// when "expand" with SkipSchema, we just rebase the existing $ref without replacing
|
||||
// the full schema.
|
||||
rebasedRef, err := NewRef(normalizeURI(target.Ref.String(), basePath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
target.Ref = denormalizeRef(&rebasedRef, resolver.context.basePath, resolver.context.rootID)
|
||||
|
||||
return &target, nil
|
||||
}
|
||||
|
||||
for k := range target.Definitions {
|
||||
@@ -520,21 +537,25 @@ func getRefAndSchema(input interface{}) (*Ref, *Schema, error) {
|
||||
}
|
||||
|
||||
func expandParameterOrResponse(input interface{}, resolver *schemaLoader, basePath string) error {
|
||||
ref, _, err := getRefAndSchema(input)
|
||||
ref, sch, err := getRefAndSchema(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if ref == nil {
|
||||
if ref == nil && sch == nil { // nothing to do
|
||||
return nil
|
||||
}
|
||||
|
||||
parentRefs := make([]string, 0, 10)
|
||||
if err = resolver.deref(input, parentRefs, basePath); resolver.shouldStopOnError(err) {
|
||||
return err
|
||||
if ref != nil {
|
||||
// dereference this $ref
|
||||
if err = resolver.deref(input, parentRefs, basePath); resolver.shouldStopOnError(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
ref, sch, _ = getRefAndSchema(input)
|
||||
}
|
||||
|
||||
ref, sch, _ := getRefAndSchema(input)
|
||||
if ref.String() != "" {
|
||||
transitiveResolver := resolver.transitiveResolver(basePath, *ref)
|
||||
basePath = resolver.updateBasePath(transitiveResolver, basePath)
|
||||
@@ -546,6 +567,7 @@ func expandParameterOrResponse(input interface{}, resolver *schemaLoader, basePa
|
||||
if ref != nil {
|
||||
*ref = Ref{}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -555,38 +577,29 @@ func expandParameterOrResponse(input interface{}, resolver *schemaLoader, basePa
|
||||
return ern
|
||||
}
|
||||
|
||||
switch {
|
||||
case resolver.isCircular(&rebasedRef, basePath, parentRefs...):
|
||||
if resolver.isCircular(&rebasedRef, basePath, parentRefs...) {
|
||||
// this is a circular $ref: stop expansion
|
||||
if !resolver.options.AbsoluteCircularRef {
|
||||
sch.Ref = denormalizeRef(&rebasedRef, resolver.context.basePath, resolver.context.rootID)
|
||||
} else {
|
||||
sch.Ref = rebasedRef
|
||||
}
|
||||
case !resolver.options.SkipSchemas:
|
||||
// schema expanded to a $ref in another root
|
||||
sch.Ref = rebasedRef
|
||||
debugLog("rebased to: %s", sch.Ref.String())
|
||||
default:
|
||||
// skip schema expansion but rebase $ref to schema
|
||||
sch.Ref = denormalizeRef(&rebasedRef, resolver.context.basePath, resolver.context.rootID)
|
||||
}
|
||||
}
|
||||
|
||||
// $ref expansion or rebasing is performed by expandSchema below
|
||||
if ref != nil {
|
||||
*ref = Ref{}
|
||||
}
|
||||
|
||||
// expand schema
|
||||
if !resolver.options.SkipSchemas {
|
||||
s, err := expandSchema(*sch, parentRefs, resolver, basePath)
|
||||
if resolver.shouldStopOnError(err) {
|
||||
return err
|
||||
}
|
||||
if s == nil {
|
||||
// guard for when continuing on error
|
||||
return nil
|
||||
}
|
||||
// yes, we do it even if options.SkipSchema is true: we have to go down that rabbit hole and rebase nested $ref)
|
||||
s, err := expandSchema(*sch, parentRefs, resolver, basePath)
|
||||
if resolver.shouldStopOnError(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
if s != nil { // guard for when continuing on error
|
||||
*sch = *s
|
||||
}
|
||||
|
||||
|
||||
+19
@@ -16,6 +16,7 @@ package spec
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/go-openapi/jsonpointer"
|
||||
@@ -40,6 +41,24 @@ func (e Extensions) GetString(key string) (string, bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
// GetInt gets a int value from the extensions
|
||||
func (e Extensions) GetInt(key string) (int, bool) {
|
||||
realKey := strings.ToLower(key)
|
||||
|
||||
if v, ok := e.GetString(realKey); ok {
|
||||
if r, err := strconv.Atoi(v); err == nil {
|
||||
return r, true
|
||||
}
|
||||
}
|
||||
|
||||
if v, ok := e[realKey]; ok {
|
||||
if r, rOk := v.(float64); rOk {
|
||||
return int(r), true
|
||||
}
|
||||
}
|
||||
return -1, false
|
||||
}
|
||||
|
||||
// GetBool gets a string value from the extensions
|
||||
func (e Extensions) GetBool(key string) (bool, bool) {
|
||||
if v, ok := e[strings.ToLower(key)]; ok {
|
||||
|
||||
+5
-6
@@ -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)
|
||||
|
||||
+3
-2
@@ -1,3 +1,4 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
// Copyright 2015 go-swagger maintainers
|
||||
@@ -34,10 +35,10 @@ 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, ""
|
||||
}
|
||||
|
||||
func fixWindowsURI(u *url.URL, in string) {
|
||||
func fixWindowsURI(_ *url.URL, _ string) {
|
||||
}
|
||||
|
||||
+2
-2
@@ -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()
|
||||
|
||||
+4
-1
@@ -217,9 +217,12 @@ func (o *Operation) AddParam(param *Parameter) *Operation {
|
||||
|
||||
for i, p := range o.Parameters {
|
||||
if p.Name == param.Name && p.In == param.In {
|
||||
params := append(o.Parameters[:i], *param)
|
||||
params := make([]Parameter, 0, len(o.Parameters)+1)
|
||||
params = append(params, o.Parameters[:i]...)
|
||||
params = append(params, *param)
|
||||
params = append(params, o.Parameters[i+1:]...)
|
||||
o.Parameters = params
|
||||
|
||||
return o
|
||||
}
|
||||
}
|
||||
|
||||
+21
-21
@@ -84,27 +84,27 @@ type ParamProps struct {
|
||||
// Parameter a unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn).
|
||||
//
|
||||
// There are five possible parameter types.
|
||||
// * Path - Used together with [Path Templating](#pathTemplating), where the parameter value is actually part
|
||||
// of the operation's URL. This does not include the host or base path of the API. For example, in `/items/{itemId}`,
|
||||
// the path parameter is `itemId`.
|
||||
// * Query - Parameters that are appended to the URL. For example, in `/items?id=###`, the query parameter is `id`.
|
||||
// * Header - Custom headers that are expected as part of the request.
|
||||
// * Body - The payload that's appended to the HTTP request. Since there can only be one payload, there can only be
|
||||
// _one_ body parameter. The name of the body parameter has no effect on the parameter itself and is used for
|
||||
// documentation purposes only. Since Form parameters are also in the payload, body and form parameters cannot exist
|
||||
// together for the same operation.
|
||||
// * Form - Used to describe the payload of an HTTP request when either `application/x-www-form-urlencoded` or
|
||||
// `multipart/form-data` are used as the content type of the request (in Swagger's definition,
|
||||
// the [`consumes`](#operationConsumes) property of an operation). This is the only parameter type that can be used
|
||||
// to send files, thus supporting the `file` type. Since form parameters are sent in the payload, they cannot be
|
||||
// declared together with a body parameter for the same operation. Form parameters have a different format based on
|
||||
// the content-type used (for further details, consult http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4).
|
||||
// * `application/x-www-form-urlencoded` - Similar to the format of Query parameters but as a payload.
|
||||
// For example, `foo=1&bar=swagger` - both `foo` and `bar` are form parameters. This is normally used for simple
|
||||
// parameters that are being transferred.
|
||||
// * `multipart/form-data` - each parameter takes a section in the payload with an internal header.
|
||||
// For example, for the header `Content-Disposition: form-data; name="submit-name"` the name of the parameter is
|
||||
// `submit-name`. This type of form parameters is more commonly used for file transfers.
|
||||
// - Path - Used together with [Path Templating](#pathTemplating), where the parameter value is actually part
|
||||
// of the operation's URL. This does not include the host or base path of the API. For example, in `/items/{itemId}`,
|
||||
// the path parameter is `itemId`.
|
||||
// - Query - Parameters that are appended to the URL. For example, in `/items?id=###`, the query parameter is `id`.
|
||||
// - Header - Custom headers that are expected as part of the request.
|
||||
// - Body - The payload that's appended to the HTTP request. Since there can only be one payload, there can only be
|
||||
// _one_ body parameter. The name of the body parameter has no effect on the parameter itself and is used for
|
||||
// documentation purposes only. Since Form parameters are also in the payload, body and form parameters cannot exist
|
||||
// together for the same operation.
|
||||
// - Form - Used to describe the payload of an HTTP request when either `application/x-www-form-urlencoded` or
|
||||
// `multipart/form-data` are used as the content type of the request (in Swagger's definition,
|
||||
// the [`consumes`](#operationConsumes) property of an operation). This is the only parameter type that can be used
|
||||
// to send files, thus supporting the `file` type. Since form parameters are sent in the payload, they cannot be
|
||||
// declared together with a body parameter for the same operation. Form parameters have a different format based on
|
||||
// the content-type used (for further details, consult http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4).
|
||||
// - `application/x-www-form-urlencoded` - Similar to the format of Query parameters but as a payload.
|
||||
// For example, `foo=1&bar=swagger` - both `foo` and `bar` are form parameters. This is normally used for simple
|
||||
// parameters that are being transferred.
|
||||
// - `multipart/form-data` - each parameter takes a section in the payload with an internal header.
|
||||
// For example, for the header `Content-Disposition: form-data; name="submit-name"` the name of the parameter is
|
||||
// `submit-name`. This type of form parameters is more commonly used for file transfers.
|
||||
//
|
||||
// For more information: http://goo.gl/8us55a#parameterObject
|
||||
type Parameter struct {
|
||||
|
||||
+3
-3
@@ -42,8 +42,8 @@ func (items OrderSchemaItems) MarshalJSON() ([]byte, error) {
|
||||
func (items OrderSchemaItems) Len() int { return len(items) }
|
||||
func (items OrderSchemaItems) Swap(i, j int) { items[i], items[j] = items[j], items[i] }
|
||||
func (items OrderSchemaItems) Less(i, j int) (ret bool) {
|
||||
ii, oki := items[i].Extensions.GetString("x-order")
|
||||
ij, okj := items[j].Extensions.GetString("x-order")
|
||||
ii, oki := items[i].Extensions.GetInt("x-order")
|
||||
ij, okj := items[j].Extensions.GetInt("x-order")
|
||||
if oki {
|
||||
if okj {
|
||||
defer func() {
|
||||
@@ -56,7 +56,7 @@ func (items OrderSchemaItems) Less(i, j int) (ret bool) {
|
||||
ret = reflect.ValueOf(ii).String() < reflect.ValueOf(ij).String()
|
||||
}
|
||||
}()
|
||||
return reflect.ValueOf(ii).Int() < reflect.ValueOf(ij).Int()
|
||||
return ii < ij
|
||||
}
|
||||
return true
|
||||
} else if okj {
|
||||
|
||||
+20
-7
@@ -19,6 +19,7 @@ import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
@@ -62,6 +63,7 @@ func (r *Responses) UnmarshalJSON(data []byte) error {
|
||||
if err := json.Unmarshal(data, &r.ResponsesProps); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(data, &r.VendorExtensible); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -107,20 +109,31 @@ func (r ResponsesProps) MarshalJSON() ([]byte, error) {
|
||||
|
||||
// UnmarshalJSON unmarshals responses from JSON
|
||||
func (r *ResponsesProps) UnmarshalJSON(data []byte) error {
|
||||
var res map[string]Response
|
||||
var res map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &res); err != nil {
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
if v, ok := res["default"]; ok {
|
||||
r.Default = &v
|
||||
var defaultRes Response
|
||||
if err := json.Unmarshal(v, &defaultRes); err != nil {
|
||||
return err
|
||||
}
|
||||
r.Default = &defaultRes
|
||||
delete(res, "default")
|
||||
}
|
||||
for k, v := range res {
|
||||
if nk, err := strconv.Atoi(k); err == nil {
|
||||
if r.StatusCodeResponses == nil {
|
||||
r.StatusCodeResponses = map[int]Response{}
|
||||
if !strings.HasPrefix(k, "x-") {
|
||||
var statusCodeResp Response
|
||||
if err := json.Unmarshal(v, &statusCodeResp); err != nil {
|
||||
return err
|
||||
}
|
||||
if nk, err := strconv.Atoi(k); err == nil {
|
||||
if r.StatusCodeResponses == nil {
|
||||
r.StatusCodeResponses = map[int]Response{}
|
||||
}
|
||||
r.StatusCodeResponses[nk] = statusCodeResp
|
||||
}
|
||||
r.StatusCodeResponses[nk] = v
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
+1
-2
@@ -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
|
||||
}
|
||||
|
||||
+1
-8
@@ -168,14 +168,7 @@ func (r *schemaLoader) load(refURL *url.URL) (interface{}, url.URL, bool, error)
|
||||
normalized := normalizeBase(pth)
|
||||
debugLog("loading doc from: %s", normalized)
|
||||
|
||||
unescaped, err := url.PathUnescape(normalized)
|
||||
if err != nil {
|
||||
return nil, url.URL{}, false, err
|
||||
}
|
||||
|
||||
u := url.URL{Path: unescaped}
|
||||
|
||||
data, fromCache := r.cache.Get(u.RequestURI())
|
||||
data, fromCache := r.cache.Get(normalized)
|
||||
if fromCache {
|
||||
return data, toFetch, fromCache, nil
|
||||
}
|
||||
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
{
|
||||
"id": "http://json-schema.org/draft-04/schema#",
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "Core schema meta-schema",
|
||||
"definitions": {
|
||||
"schemaArray": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": { "$ref": "#" }
|
||||
},
|
||||
"positiveInteger": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"positiveIntegerDefault0": {
|
||||
"allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
|
||||
},
|
||||
"simpleTypes": {
|
||||
"enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
|
||||
},
|
||||
"stringArray": {
|
||||
"type": "array",
|
||||
"items": { "type": "string" },
|
||||
"minItems": 1,
|
||||
"uniqueItems": true
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"$schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": {},
|
||||
"multipleOf": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"exclusiveMinimum": true
|
||||
},
|
||||
"maximum": {
|
||||
"type": "number"
|
||||
},
|
||||
"exclusiveMaximum": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"minimum": {
|
||||
"type": "number"
|
||||
},
|
||||
"exclusiveMinimum": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"maxLength": { "$ref": "#/definitions/positiveInteger" },
|
||||
"minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
|
||||
"pattern": {
|
||||
"type": "string",
|
||||
"format": "regex"
|
||||
},
|
||||
"additionalItems": {
|
||||
"anyOf": [
|
||||
{ "type": "boolean" },
|
||||
{ "$ref": "#" }
|
||||
],
|
||||
"default": {}
|
||||
},
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{ "$ref": "#" },
|
||||
{ "$ref": "#/definitions/schemaArray" }
|
||||
],
|
||||
"default": {}
|
||||
},
|
||||
"maxItems": { "$ref": "#/definitions/positiveInteger" },
|
||||
"minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
|
||||
"uniqueItems": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"maxProperties": { "$ref": "#/definitions/positiveInteger" },
|
||||
"minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
|
||||
"required": { "$ref": "#/definitions/stringArray" },
|
||||
"additionalProperties": {
|
||||
"anyOf": [
|
||||
{ "type": "boolean" },
|
||||
{ "$ref": "#" }
|
||||
],
|
||||
"default": {}
|
||||
},
|
||||
"definitions": {
|
||||
"type": "object",
|
||||
"additionalProperties": { "$ref": "#" },
|
||||
"default": {}
|
||||
},
|
||||
"properties": {
|
||||
"type": "object",
|
||||
"additionalProperties": { "$ref": "#" },
|
||||
"default": {}
|
||||
},
|
||||
"patternProperties": {
|
||||
"type": "object",
|
||||
"additionalProperties": { "$ref": "#" },
|
||||
"default": {}
|
||||
},
|
||||
"dependencies": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"anyOf": [
|
||||
{ "$ref": "#" },
|
||||
{ "$ref": "#/definitions/stringArray" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"enum": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"uniqueItems": true
|
||||
},
|
||||
"type": {
|
||||
"anyOf": [
|
||||
{ "$ref": "#/definitions/simpleTypes" },
|
||||
{
|
||||
"type": "array",
|
||||
"items": { "$ref": "#/definitions/simpleTypes" },
|
||||
"minItems": 1,
|
||||
"uniqueItems": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"format": { "type": "string" },
|
||||
"allOf": { "$ref": "#/definitions/schemaArray" },
|
||||
"anyOf": { "$ref": "#/definitions/schemaArray" },
|
||||
"oneOf": { "$ref": "#/definitions/schemaArray" },
|
||||
"not": { "$ref": "#" }
|
||||
},
|
||||
"dependencies": {
|
||||
"exclusiveMaximum": [ "maximum" ],
|
||||
"exclusiveMinimum": [ "minimum" ]
|
||||
},
|
||||
"default": {}
|
||||
}
|
||||
+1607
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -26,7 +26,7 @@ import (
|
||||
const (
|
||||
// SwaggerSchemaURL the url for the swagger 2.0 schema to validate specs
|
||||
SwaggerSchemaURL = "http://swagger.io/v2/schema.json#"
|
||||
// JSONSchemaURL the url for the json schema schema
|
||||
// JSONSchemaURL the url for the json schema
|
||||
JSONSchemaURL = "http://json-schema.org/draft-04/schema#"
|
||||
)
|
||||
|
||||
@@ -41,7 +41,7 @@ func MustLoadJSONSchemaDraft04() *Schema {
|
||||
|
||||
// JSONSchemaDraft04 loads the json schema document for json shema draft04
|
||||
func JSONSchemaDraft04() (*Schema, error) {
|
||||
b, err := Asset("jsonschema-draft-04.json")
|
||||
b, err := jsonschemaDraft04JSONBytes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -65,7 +65,7 @@ func MustLoadSwagger20Schema() *Schema {
|
||||
// Swagger20Schema loads the swagger 2.0 schema from the embedded assets
|
||||
func Swagger20Schema() (*Schema, error) {
|
||||
|
||||
b, err := Asset("v2/schema.json")
|
||||
b, err := v2SchemaJSONBytes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
+2
-2
@@ -253,7 +253,7 @@ func (s SchemaOrBool) MarshalJSON() ([]byte, error) {
|
||||
// UnmarshalJSON converts this bool or schema object from a JSON structure
|
||||
func (s *SchemaOrBool) UnmarshalJSON(data []byte) error {
|
||||
var nw SchemaOrBool
|
||||
if len(data) >= 4 {
|
||||
if len(data) > 0 {
|
||||
if data[0] == '{' {
|
||||
var sch Schema
|
||||
if err := json.Unmarshal(data, &sch); err != nil {
|
||||
@@ -261,7 +261,7 @@ func (s *SchemaOrBool) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
nw.Schema = &sch
|
||||
}
|
||||
nw.Allows = !(data[0] == 'f' && data[1] == 'a' && data[2] == 'l' && data[3] == 's' && data[4] == 'e')
|
||||
nw.Allows = !bytes.Equal(data, []byte("false"))
|
||||
}
|
||||
*s = nw
|
||||
return nil
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user