hack/pin-dependency.sh github.com/go-openapi/validate v0.19.5
This commit is contained in:
5
vendor/github.com/go-openapi/analysis/.codecov.yml
generated
vendored
Normal file
5
vendor/github.com/go-openapi/analysis/.codecov.yml
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
coverage:
|
||||
status:
|
||||
patch:
|
||||
default:
|
||||
target: 80%
|
8
vendor/github.com/go-openapi/analysis/.golangci.yml
generated
vendored
8
vendor/github.com/go-openapi/analysis/.golangci.yml
generated
vendored
@@ -4,7 +4,7 @@ linters-settings:
|
||||
golint:
|
||||
min-confidence: 0
|
||||
gocyclo:
|
||||
min-complexity: 30
|
||||
min-complexity: 40
|
||||
maligned:
|
||||
suggest-new: true
|
||||
dupl:
|
||||
@@ -17,5 +17,11 @@ linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
- maligned
|
||||
- lll
|
||||
- gochecknoglobals
|
||||
- gochecknoinits
|
||||
# scopelint is useful, but also reports false positives
|
||||
# that unfortunately can't be disabled. So we disable the
|
||||
# linter rather than changing code that works.
|
||||
# see: https://github.com/kyoh86/scopelint/issues/4
|
||||
- scopelint
|
||||
|
4
vendor/github.com/go-openapi/analysis/README.md
generated
vendored
4
vendor/github.com/go-openapi/analysis/README.md
generated
vendored
@@ -1,5 +1,5 @@
|
||||
# OpenAPI initiative analysis [](https://travis-ci.org/go-openapi/analysis) [](https://codecov.io/gh/go-openapi/analysis) [](https://slackin.goswagger.io)
|
||||
|
||||
# OpenAPI initiative analysis [](https://travis-ci.org/go-openapi/analysis) [](https://ci.appveyor.com/project/casualjim/go-openapi/analysis/branch/master) [](https://codecov.io/gh/go-openapi/analysis)
|
||||
[](https://slackin.goswagger.io)
|
||||
[](https://raw.githubusercontent.com/go-openapi/analysis/master/LICENSE)
|
||||
[](http://godoc.org/github.com/go-openapi/analysis)
|
||||
[](https://golangci.com)
|
||||
|
36
vendor/github.com/go-openapi/analysis/analyzer.go
generated
vendored
36
vendor/github.com/go-openapi/analysis/analyzer.go
generated
vendored
@@ -142,38 +142,12 @@ func (p *enumAnalysis) addSchemaEnum(key string, enum []interface{}) {
|
||||
// or validation etc.
|
||||
func New(doc *spec.Swagger) *Spec {
|
||||
a := &Spec{
|
||||
spec: doc,
|
||||
consumes: make(map[string]struct{}, 150),
|
||||
produces: make(map[string]struct{}, 150),
|
||||
authSchemes: make(map[string]struct{}, 150),
|
||||
operations: make(map[string]map[string]*spec.Operation, 150),
|
||||
allSchemas: make(map[string]SchemaRef, 150),
|
||||
allOfs: make(map[string]SchemaRef, 150),
|
||||
references: referenceAnalysis{
|
||||
schemas: make(map[string]spec.Ref, 150),
|
||||
pathItems: make(map[string]spec.Ref, 150),
|
||||
responses: make(map[string]spec.Ref, 150),
|
||||
parameters: make(map[string]spec.Ref, 150),
|
||||
items: make(map[string]spec.Ref, 150),
|
||||
headerItems: make(map[string]spec.Ref, 150),
|
||||
parameterItems: make(map[string]spec.Ref, 150),
|
||||
allRefs: make(map[string]spec.Ref, 150),
|
||||
},
|
||||
patterns: patternAnalysis{
|
||||
parameters: make(map[string]string, 150),
|
||||
headers: make(map[string]string, 150),
|
||||
items: make(map[string]string, 150),
|
||||
schemas: make(map[string]string, 150),
|
||||
allPatterns: make(map[string]string, 150),
|
||||
},
|
||||
enums: enumAnalysis{
|
||||
parameters: make(map[string][]interface{}, 150),
|
||||
headers: make(map[string][]interface{}, 150),
|
||||
items: make(map[string][]interface{}, 150),
|
||||
schemas: make(map[string][]interface{}, 150),
|
||||
allEnums: make(map[string][]interface{}, 150),
|
||||
},
|
||||
spec: doc,
|
||||
references: referenceAnalysis{},
|
||||
patterns: patternAnalysis{},
|
||||
enums: enumAnalysis{},
|
||||
}
|
||||
a.reset()
|
||||
a.initialize()
|
||||
return a
|
||||
}
|
||||
|
33
vendor/github.com/go-openapi/analysis/appveyor.yml
generated
vendored
Normal file
33
vendor/github.com/go-openapi/analysis/appveyor.yml
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
version: "0.1.{build}"
|
||||
|
||||
clone_folder: C:\go-openapi\analysis
|
||||
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.12
|
||||
|
||||
test_script:
|
||||
- go test -v -timeout 20m ./...
|
||||
#artifacts:
|
||||
# - path: '%GOPATH%\bin\*.exe'
|
||||
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
|
377
vendor/github.com/go-openapi/analysis/flatten.go
generated
vendored
377
vendor/github.com/go-openapi/analysis/flatten.go
generated
vendored
@@ -140,12 +140,14 @@ func Flatten(opts FlattenOpts) error {
|
||||
cwd, _ := os.Getwd()
|
||||
opts.BasePath = filepath.Join(cwd, opts.BasePath)
|
||||
}
|
||||
// make sure drive letter on windows is normalized to lower case
|
||||
u, _ := url.Parse(opts.BasePath)
|
||||
opts.BasePath = u.String()
|
||||
|
||||
opts.flattenContext = newContext()
|
||||
|
||||
// recursively expand responses, parameters, path items and items in simple schemas.
|
||||
// This simplifies the spec and leaves $ref only into schema objects.
|
||||
//
|
||||
if err := swspec.ExpandSpec(opts.Swagger(), opts.ExpandOpts(!opts.Expand)); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -165,8 +167,11 @@ func Flatten(opts FlattenOpts) error {
|
||||
|
||||
opts.Spec.reload() // re-analyze
|
||||
|
||||
// at this point there are no other references left but schemas
|
||||
// at this point there are no references left but in schemas
|
||||
|
||||
for imported := false; !imported; {
|
||||
// iteratively import remote references until none left.
|
||||
// This inlining deals with name conflicts by introducing auto-generated names ("OAIGen")
|
||||
var err error
|
||||
if imported, err = importExternalReferences(&opts); err != nil {
|
||||
return err
|
||||
@@ -182,8 +187,9 @@ func Flatten(opts FlattenOpts) error {
|
||||
|
||||
opts.Spec.reload() // re-analyze
|
||||
}
|
||||
|
||||
// rewrite JSON pointers other than $ref to named definitions
|
||||
// and attempts to resolve conflicting names
|
||||
// and attempt to resolve conflicting names whenever possible.
|
||||
if err := stripPointersAndOAIGen(&opts); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -195,9 +201,7 @@ func Flatten(opts FlattenOpts) error {
|
||||
expected[slashpath.Join(definitionsPath, jsonpointer.Escape(k))] = struct{}{}
|
||||
}
|
||||
for _, k := range opts.Spec.AllDefinitionReferences() {
|
||||
if _, ok := expected[k]; ok {
|
||||
delete(expected, k)
|
||||
}
|
||||
delete(expected, k)
|
||||
}
|
||||
for k := range expected {
|
||||
debugLog("removing unused definition %s", slashpath.Base(k))
|
||||
@@ -362,6 +366,7 @@ func (isn *inlineSchemaNamer) Name(key string, schema *swspec.Schema, aschema *A
|
||||
|
||||
// rewrite any dependent $ref pointing to this place,
|
||||
// when not already pointing to a top-level definition.
|
||||
//
|
||||
// NOTE: this is important if such referers use arbitrary JSON pointers.
|
||||
an := New(isn.Spec)
|
||||
for k, v := range an.references.allRefs {
|
||||
@@ -373,6 +378,7 @@ func (isn *inlineSchemaNamer) Name(key string, schema *swspec.Schema, aschema *A
|
||||
r.String() == slashpath.Join(definitionsPath, newName) &&
|
||||
slashpath.Dir(v.String()) != definitionsPath {
|
||||
debugLog("found a $ref to a rewritten schema: %s points to %s", k, v.String())
|
||||
|
||||
// rewrite $ref to the new target
|
||||
if err := updateRef(isn.Spec, k,
|
||||
swspec.MustCreateRef(slashpath.Join(definitionsPath, newName))); err != nil {
|
||||
@@ -383,6 +389,7 @@ func (isn *inlineSchemaNamer) Name(key string, schema *swspec.Schema, aschema *A
|
||||
|
||||
// NOTE: this extension is currently not used by go-swagger (provided for information only)
|
||||
sch.AddExtension("x-go-gen-location", genLocation(parts))
|
||||
|
||||
// save cloned schema to definitions
|
||||
saveSchema(isn.Spec, newName, sch)
|
||||
|
||||
@@ -408,6 +415,7 @@ func (isn *inlineSchemaNamer) Name(key string, schema *swspec.Schema, aschema *A
|
||||
}
|
||||
|
||||
// genLocation indicates from which section of the specification (models or operations) a definition has been created.
|
||||
//
|
||||
// This is reflected in the output spec with a "x-go-gen-location" extension. At the moment, this is is provided
|
||||
// for information only.
|
||||
func genLocation(parts splitKey) string {
|
||||
@@ -420,6 +428,7 @@ func genLocation(parts splitKey) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// uniqifyName yields a unique name for a definition
|
||||
func uniqifyName(definitions swspec.Definitions, name string) (string, bool) {
|
||||
isOAIGen := false
|
||||
if name == "" {
|
||||
@@ -432,7 +441,7 @@ func uniqifyName(definitions swspec.Definitions, name string) (string, bool) {
|
||||
|
||||
unq := true
|
||||
for k := range definitions {
|
||||
if strings.ToLower(k) == strings.ToLower(name) {
|
||||
if strings.EqualFold(k, name) {
|
||||
unq = false
|
||||
break
|
||||
}
|
||||
@@ -781,7 +790,14 @@ func cloneSchema(schema *swspec.Schema) (*swspec.Schema, error) {
|
||||
return &sch, nil
|
||||
}
|
||||
|
||||
// importExternalReferences iteratively digs remote references and imports them into the main schema.
|
||||
//
|
||||
// At every iteration, new remotes may be found when digging deeper: they are rebased to the current schema before being imported.
|
||||
//
|
||||
// This returns true when no more remote references can be found.
|
||||
func importExternalReferences(opts *FlattenOpts) (bool, error) {
|
||||
debugLog("importExternalReferences")
|
||||
|
||||
groupedRefs := reverseIndexForSchemaRefs(opts)
|
||||
sortedRefStr := make([]string, 0, len(groupedRefs))
|
||||
if opts.flattenContext == nil {
|
||||
@@ -795,71 +811,110 @@ func importExternalReferences(opts *FlattenOpts) (bool, error) {
|
||||
sort.Strings(sortedRefStr)
|
||||
|
||||
complete := true
|
||||
|
||||
for _, refStr := range sortedRefStr {
|
||||
entry := groupedRefs[refStr]
|
||||
if !entry.Ref.HasFragmentOnly {
|
||||
complete = false
|
||||
var isOAIGen bool
|
||||
if entry.Ref.HasFragmentOnly {
|
||||
continue
|
||||
}
|
||||
complete = false
|
||||
var isOAIGen bool
|
||||
|
||||
newName := opts.flattenContext.resolved[refStr]
|
||||
if newName != "" {
|
||||
// rewrite ref with already resolved external ref (useful for cyclicali refs)
|
||||
debugLog("resolving known ref [%s] to %s", refStr, newName)
|
||||
// rewrite the external refs to local ones
|
||||
for _, key := range entry.Keys {
|
||||
if err := updateRef(opts.Swagger(), key,
|
||||
swspec.MustCreateRef(slashpath.Join(definitionsPath, newName))); err != nil {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
debugLog("importing external schema for [%s] from %s", strings.Join(entry.Keys, ", "), refStr)
|
||||
|
||||
// resolve to actual schema
|
||||
sch := new(swspec.Schema)
|
||||
sch.Ref = entry.Ref
|
||||
if err := swspec.ExpandSchemaWithBasePath(sch, nil, opts.ExpandOpts(false)); err != nil {
|
||||
newName := opts.flattenContext.resolved[refStr]
|
||||
if newName != "" {
|
||||
// rewrite ref with already resolved external ref (useful for cyclical refs):
|
||||
// rewrite external refs to local ones
|
||||
debugLog("resolving known ref [%s] to %s", refStr, newName)
|
||||
for _, key := range entry.Keys {
|
||||
if err := updateRef(opts.Swagger(), key,
|
||||
swspec.MustCreateRef(slashpath.Join(definitionsPath, newName))); err != nil {
|
||||
return false, err
|
||||
}
|
||||
if sch == nil {
|
||||
return false, fmt.Errorf("no schema found at %s for [%s]", refStr, strings.Join(entry.Keys, ", "))
|
||||
}
|
||||
debugLog("importing external schema for [%s] from %s", strings.Join(entry.Keys, ", "), refStr)
|
||||
|
||||
// generate a unique name - isOAIGen means that a naming conflict was resolved by changing the name
|
||||
newName, isOAIGen = uniqifyName(opts.Swagger().Definitions, nameFromRef(entry.Ref))
|
||||
debugLog("new name for [%s]: %s - with name conflict:%t",
|
||||
strings.Join(entry.Keys, ", "), newName, isOAIGen)
|
||||
|
||||
opts.flattenContext.resolved[refStr] = newName
|
||||
|
||||
// rewrite the external refs to local ones
|
||||
for _, key := range entry.Keys {
|
||||
if err := updateRef(opts.Swagger(), key,
|
||||
swspec.MustCreateRef(slashpath.Join(definitionsPath, newName))); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// keep track of created refs
|
||||
resolved := false
|
||||
if _, ok := opts.flattenContext.newRefs[key]; ok {
|
||||
resolved = opts.flattenContext.newRefs[key].resolved
|
||||
}
|
||||
opts.flattenContext.newRefs[key] = &newRef{
|
||||
key: key,
|
||||
newName: newName,
|
||||
path: slashpath.Join(definitionsPath, newName),
|
||||
isOAIGen: isOAIGen,
|
||||
resolved: resolved,
|
||||
schema: sch,
|
||||
}
|
||||
}
|
||||
|
||||
// add the resolved schema to the definitions
|
||||
saveSchema(opts.Swagger(), newName, sch)
|
||||
}
|
||||
} else {
|
||||
// resolve schemas
|
||||
debugLog("resolving schema from remote $ref [%s]", refStr)
|
||||
sch, err := swspec.ResolveRefWithBase(opts.Swagger(), &entry.Ref, opts.ExpandOpts(false))
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("could not resolve schema: %v", err)
|
||||
}
|
||||
|
||||
// at this stage only $ref analysis matters
|
||||
partialAnalyzer := &Spec{
|
||||
references: referenceAnalysis{},
|
||||
patterns: patternAnalysis{},
|
||||
enums: enumAnalysis{},
|
||||
}
|
||||
partialAnalyzer.reset()
|
||||
partialAnalyzer.analyzeSchema("", *sch, "/")
|
||||
|
||||
// now rewrite those refs with rebase
|
||||
for key, ref := range partialAnalyzer.references.allRefs {
|
||||
if err := updateRef(sch, key, swspec.MustCreateRef(rebaseRef(entry.Ref.String(), ref.String()))); err != nil {
|
||||
return false, fmt.Errorf("failed to rewrite ref for key %q at %s: %v", key, entry.Ref.String(), err)
|
||||
}
|
||||
}
|
||||
|
||||
// generate a unique name - isOAIGen means that a naming conflict was resolved by changing the name
|
||||
newName, isOAIGen = uniqifyName(opts.Swagger().Definitions, nameFromRef(entry.Ref))
|
||||
debugLog("new name for [%s]: %s - with name conflict:%t",
|
||||
strings.Join(entry.Keys, ", "), newName, isOAIGen)
|
||||
|
||||
opts.flattenContext.resolved[refStr] = newName
|
||||
|
||||
// rewrite the external refs to local ones
|
||||
for _, key := range entry.Keys {
|
||||
if err := updateRef(opts.Swagger(), key,
|
||||
swspec.MustCreateRef(slashpath.Join(definitionsPath, newName))); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// keep track of created refs
|
||||
resolved := false
|
||||
if _, ok := opts.flattenContext.newRefs[key]; ok {
|
||||
resolved = opts.flattenContext.newRefs[key].resolved
|
||||
}
|
||||
opts.flattenContext.newRefs[key] = &newRef{
|
||||
key: key,
|
||||
newName: newName,
|
||||
path: slashpath.Join(definitionsPath, newName),
|
||||
isOAIGen: isOAIGen,
|
||||
resolved: resolved,
|
||||
schema: sch,
|
||||
}
|
||||
}
|
||||
|
||||
// add the resolved schema to the definitions
|
||||
saveSchema(opts.Swagger(), newName, sch)
|
||||
}
|
||||
}
|
||||
// maintains ref index entries
|
||||
for k := range opts.flattenContext.newRefs {
|
||||
r := opts.flattenContext.newRefs[k]
|
||||
|
||||
// update tracking with resolved schemas
|
||||
if r.schema.Ref.String() != "" {
|
||||
ref := swspec.MustCreateRef(r.path)
|
||||
sch, err := swspec.ResolveRefWithBase(opts.Swagger(), &ref, opts.ExpandOpts(false))
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("could not resolve schema: %v", err)
|
||||
}
|
||||
r.schema = sch
|
||||
}
|
||||
// update tracking with renamed keys: got a cascade of refs
|
||||
if r.path != k {
|
||||
renamed := *r
|
||||
renamed.key = r.path
|
||||
opts.flattenContext.newRefs[renamed.path] = &renamed
|
||||
|
||||
// indirect ref
|
||||
r.newName = slashpath.Base(k)
|
||||
r.schema = swspec.RefSchema(r.path)
|
||||
r.path = k
|
||||
r.isOAIGen = strings.Contains(k, "OAIGen")
|
||||
}
|
||||
}
|
||||
|
||||
return complete, nil
|
||||
}
|
||||
|
||||
@@ -868,20 +923,77 @@ type refRevIdx struct {
|
||||
Keys []string
|
||||
}
|
||||
|
||||
// rebaseRef rebase a remote ref relative to a base ref.
|
||||
//
|
||||
// NOTE: does not support JSONschema ID for $ref (we assume we are working with swagger specs here).
|
||||
//
|
||||
// NOTE(windows):
|
||||
// * refs are assumed to have been normalized with drive letter lower cased (from go-openapi/spec)
|
||||
// * "/ in paths may appear as escape sequences
|
||||
func rebaseRef(baseRef string, ref string) string {
|
||||
debugLog("rebasing ref: %s onto %s", ref, baseRef)
|
||||
baseRef, _ = url.PathUnescape(baseRef)
|
||||
ref, _ = url.PathUnescape(ref)
|
||||
if baseRef == "" || baseRef == "." || strings.HasPrefix(baseRef, "#") {
|
||||
return ref
|
||||
}
|
||||
|
||||
parts := strings.Split(ref, "#")
|
||||
|
||||
baseParts := strings.Split(baseRef, "#")
|
||||
baseURL, _ := url.Parse(baseParts[0])
|
||||
if strings.HasPrefix(ref, "#") {
|
||||
if baseURL.Host == "" {
|
||||
return strings.Join([]string{baseParts[0], parts[1]}, "#")
|
||||
}
|
||||
return strings.Join([]string{baseParts[0], parts[1]}, "#")
|
||||
}
|
||||
|
||||
refURL, _ := url.Parse(parts[0])
|
||||
if refURL.Host != "" || filepath.IsAbs(parts[0]) {
|
||||
// not rebasing an absolute path
|
||||
return ref
|
||||
}
|
||||
|
||||
// there is a relative path
|
||||
var basePath string
|
||||
if baseURL.Host != "" {
|
||||
// when there is a host, standard URI rules apply (with "/")
|
||||
baseURL.Path = slashpath.Dir(baseURL.Path)
|
||||
baseURL.Path = slashpath.Join(baseURL.Path, "/"+parts[0])
|
||||
return baseURL.String()
|
||||
}
|
||||
|
||||
// this is a local relative path
|
||||
// basePart[0] and parts[0] are local filesystem directories/files
|
||||
basePath = filepath.Dir(baseParts[0])
|
||||
relPath := filepath.Join(basePath, string(filepath.Separator)+parts[0])
|
||||
if len(parts) > 1 {
|
||||
return strings.Join([]string{relPath, parts[1]}, "#")
|
||||
}
|
||||
return relPath
|
||||
}
|
||||
|
||||
// normalizePath renders absolute path on remote file refs
|
||||
//
|
||||
// NOTE(windows):
|
||||
// * refs are assumed to have been normalized with drive letter lower cased (from go-openapi/spec)
|
||||
// * "/ in paths may appear as escape sequences
|
||||
func normalizePath(ref swspec.Ref, opts *FlattenOpts) (normalizedPath string) {
|
||||
if ref.HasFragmentOnly || filepath.IsAbs(ref.String()) {
|
||||
normalizedPath = ref.String()
|
||||
uri, _ := url.PathUnescape(ref.String())
|
||||
if ref.HasFragmentOnly || filepath.IsAbs(uri) {
|
||||
normalizedPath = uri
|
||||
return
|
||||
}
|
||||
|
||||
refURL, _ := url.Parse(ref.String())
|
||||
refURL, _ := url.Parse(uri)
|
||||
if refURL.Host != "" {
|
||||
normalizedPath = ref.String()
|
||||
normalizedPath = uri
|
||||
return
|
||||
}
|
||||
|
||||
parts := strings.Split(ref.String(), "#")
|
||||
parts := strings.Split(uri, "#")
|
||||
// BasePath, parts[0] are local filesystem directories, guaranteed to be absolute at this stage
|
||||
parts[0] = filepath.Join(filepath.Dir(opts.BasePath), parts[0])
|
||||
normalizedPath = strings.Join(parts, "#")
|
||||
return
|
||||
@@ -935,7 +1047,16 @@ func saveSchema(spec *swspec.Swagger, name string, schema *swspec.Schema) {
|
||||
}
|
||||
|
||||
// getPointerFromKey retrieves the content of the JSON pointer "key"
|
||||
func getPointerFromKey(spec *swspec.Swagger, key string) (string, interface{}, error) {
|
||||
func getPointerFromKey(spec interface{}, key string) (string, interface{}, error) {
|
||||
switch spec.(type) {
|
||||
case *swspec.Schema:
|
||||
case *swspec.Swagger:
|
||||
default:
|
||||
panic("unexpected type used in getPointerFromKey")
|
||||
}
|
||||
if key == "#/" {
|
||||
return "", spec, nil
|
||||
}
|
||||
// unescape chars in key, e.g. "{}" from path params
|
||||
pth, _ := internal.PathUnescape(key[1:])
|
||||
ptr, err := jsonpointer.New(pth)
|
||||
@@ -952,7 +1073,13 @@ func getPointerFromKey(spec *swspec.Swagger, key string) (string, interface{}, e
|
||||
}
|
||||
|
||||
// getParentFromKey retrieves the container of the JSON pointer "key"
|
||||
func getParentFromKey(spec *swspec.Swagger, key string) (string, string, interface{}, error) {
|
||||
func getParentFromKey(spec interface{}, key string) (string, string, interface{}, error) {
|
||||
switch spec.(type) {
|
||||
case *swspec.Schema:
|
||||
case *swspec.Swagger:
|
||||
default:
|
||||
panic("unexpected type used in getPointerFromKey")
|
||||
}
|
||||
// unescape chars in key, e.g. "{}" from path params
|
||||
pth, _ := internal.PathUnescape(key[1:])
|
||||
|
||||
@@ -971,7 +1098,13 @@ func getParentFromKey(spec *swspec.Swagger, key string) (string, string, interfa
|
||||
}
|
||||
|
||||
// updateRef replaces a ref by another one
|
||||
func updateRef(spec *swspec.Swagger, key string, ref swspec.Ref) error {
|
||||
func updateRef(spec interface{}, key string, ref swspec.Ref) error {
|
||||
switch spec.(type) {
|
||||
case *swspec.Schema:
|
||||
case *swspec.Swagger:
|
||||
default:
|
||||
panic("unexpected type used in getPointerFromKey")
|
||||
}
|
||||
debugLog("updating ref for %s with %s", key, ref.String())
|
||||
pth, value, err := getPointerFromKey(spec, key)
|
||||
if err != nil {
|
||||
@@ -1165,6 +1298,7 @@ func stripPointersAndOAIGen(opts *FlattenOpts) error {
|
||||
// iterate as pointer or OAIGen resolution may introduce inline schemas or pointers
|
||||
for hasIntroducedPointerOrInline {
|
||||
if !opts.Minimal {
|
||||
opts.Spec.reload() // re-analyze
|
||||
if err := nameInlinedSchemas(opts); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1178,60 +1312,123 @@ func stripPointersAndOAIGen(opts *FlattenOpts) error {
|
||||
if hasIntroducedPointerOrInline, ers = stripOAIGen(opts); ers != nil {
|
||||
return ers
|
||||
}
|
||||
|
||||
opts.Spec.reload() // re-analyze
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// stripOAIGen strips the spec from unnecessary OAIGen constructs, initially created to dedupe flattened definitions.
|
||||
//
|
||||
// A dedupe is deemed unnecessary whenever:
|
||||
// - the only conflict is with its (single) parent: OAIGen is merged into its parent
|
||||
// - the only conflict is with its (single) parent: OAIGen is merged into its parent (reinlining)
|
||||
// - there is a conflict with multiple parents: merge OAIGen in first parent, the rewrite other parents to point to
|
||||
// the first parent.
|
||||
//
|
||||
// This function returns a true bool whenever it re-inlined a complex schema, so the caller may chose to iterate
|
||||
// flattening again.
|
||||
//
|
||||
// NOTE: the OAIGen definition cannot be itself a $ref.
|
||||
// pointer and name resolution again.
|
||||
func stripOAIGen(opts *FlattenOpts) (bool, error) {
|
||||
debugLog("stripOAIGen")
|
||||
replacedWithComplex := false
|
||||
for k, v := range opts.Spec.references.allRefs {
|
||||
// figure out referers of OAIGen definitions
|
||||
for _, r := range opts.flattenContext.newRefs {
|
||||
if r.isOAIGen && !r.resolved && r.path == v.String() { // bail on already resolved entries (avoid looping)
|
||||
|
||||
// figure out referers of OAIGen definitions
|
||||
for _, r := range opts.flattenContext.newRefs {
|
||||
if !r.isOAIGen || r.resolved { // bail on already resolved entries (avoid looping)
|
||||
continue
|
||||
}
|
||||
for k, v := range opts.Spec.references.allRefs {
|
||||
if r.path != v.String() {
|
||||
continue
|
||||
}
|
||||
found := false
|
||||
for _, p := range r.parents {
|
||||
if p == k {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
r.parents = append(r.parents, k)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, r := range opts.flattenContext.newRefs {
|
||||
if r.isOAIGen && len(r.parents) >= 1 && r.schema.Ref.String() == "" {
|
||||
for k := range opts.flattenContext.newRefs {
|
||||
r := opts.flattenContext.newRefs[k]
|
||||
//debugLog("newRefs[%s]: isOAIGen: %t, resolved: %t, name: %s, path:%s, #parents: %d, parents: %v, ref: %s",
|
||||
// k, r.isOAIGen, r.resolved, r.newName, r.path, len(r.parents), r.parents, r.schema.Ref.String())
|
||||
if r.isOAIGen && len(r.parents) >= 1 {
|
||||
pr := r.parents
|
||||
sort.Strings(pr)
|
||||
|
||||
// rewrite first parent schema in lexicographical order
|
||||
debugLog("rewrite first parent %s with schema", pr[0])
|
||||
debugLog("rewrite first parent in lex order %s with schema", pr[0])
|
||||
if err := updateRefWithSchema(opts.Swagger(), pr[0], r.schema); err != nil {
|
||||
return false, err
|
||||
}
|
||||
if pa, ok := opts.flattenContext.newRefs[pr[0]]; ok && pa.isOAIGen {
|
||||
// update parent in ref index entry
|
||||
debugLog("update parent entry: %s", pr[0])
|
||||
pa.schema = r.schema
|
||||
pa.resolved = false
|
||||
replacedWithComplex = true
|
||||
}
|
||||
|
||||
// rewrite other parents to point to first parent
|
||||
if len(pr) > 1 {
|
||||
for _, p := range pr[1:] {
|
||||
replacingRef := swspec.MustCreateRef(pr[0])
|
||||
// Set complex when replacing ref is an anonymous jsonpointer: further processing may be required
|
||||
|
||||
// set complex when replacing ref is an anonymous jsonpointer: further processing may be required
|
||||
replacedWithComplex = replacedWithComplex ||
|
||||
slashpath.Dir(replacingRef.String()) != definitionsPath
|
||||
debugLog("rewrite parent with ref: %s", replacingRef.String())
|
||||
|
||||
// NOTE: it is possible at this stage to introduce json pointers (to non-definitions places).
|
||||
// Those are stripped later on.
|
||||
if err := updateRef(opts.Swagger(), p, replacingRef); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if pa, ok := opts.flattenContext.newRefs[p]; ok && pa.isOAIGen {
|
||||
// update parent in ref index
|
||||
debugLog("update parent entry: %s", p)
|
||||
pa.schema = r.schema
|
||||
pa.resolved = false
|
||||
replacedWithComplex = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// remove OAIGen definition
|
||||
debugLog("removing definition %s", slashpath.Base(r.path))
|
||||
delete(opts.Swagger().Definitions, slashpath.Base(r.path))
|
||||
|
||||
// propagate changes in ref index for keys which have this one as a parent
|
||||
for kk, value := range opts.flattenContext.newRefs {
|
||||
if kk == k || !value.isOAIGen || value.resolved {
|
||||
continue
|
||||
}
|
||||
found := false
|
||||
newParents := make([]string, 0, len(value.parents))
|
||||
for _, parent := range value.parents {
|
||||
switch {
|
||||
case parent == r.path:
|
||||
found = true
|
||||
parent = pr[0]
|
||||
case strings.HasPrefix(parent, r.path+"/"):
|
||||
found = true
|
||||
parent = slashpath.Join(pr[0], strings.TrimPrefix(parent, r.path))
|
||||
}
|
||||
newParents = append(newParents, parent)
|
||||
}
|
||||
if found {
|
||||
value.parents = newParents
|
||||
}
|
||||
}
|
||||
|
||||
// mark naming conflict as resolved
|
||||
debugLog("marking naming conflict resolved for key: %s", r.key)
|
||||
opts.flattenContext.newRefs[r.key].isOAIGen = false
|
||||
opts.flattenContext.newRefs[r.key].resolved = true
|
||||
|
||||
@@ -1241,12 +1438,14 @@ func stripOAIGen(opts *FlattenOpts) (bool, error) {
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
debugLog("re-inline schema: parent: %s, %t", pr[0], isAnalyzedAsComplex(asch))
|
||||
debugLog("re-inlined schema: parent: %s, %t", pr[0], isAnalyzedAsComplex(asch))
|
||||
replacedWithComplex = replacedWithComplex ||
|
||||
!(slashpath.Dir(pr[0]) == definitionsPath) && isAnalyzedAsComplex(asch)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
debugLog("replacedWithComplex: %t", replacedWithComplex)
|
||||
opts.Spec.reload() // re-analyze
|
||||
return replacedWithComplex, nil
|
||||
}
|
||||
@@ -1338,6 +1537,14 @@ func namePointers(opts *FlattenOpts) error {
|
||||
debugLog("namePointers at %s for %s", key, v.Ref.String())
|
||||
|
||||
// qualify the expanded schema
|
||||
/*
|
||||
if key == "#/paths/~1some~1where~1{id}/get/parameters/1/items" {
|
||||
// DEBUG
|
||||
//func getPointerFromKey(spec interface{}, key string) (string, interface{}, error) {
|
||||
k, res, err := getPointerFromKey(namer.Spec, key)
|
||||
debugLog("k = %s, res=%#v, err=%v", k, res, err)
|
||||
}
|
||||
*/
|
||||
asch, ers := Schema(SchemaOpts{Schema: v.Schema, Root: opts.Swagger(), BasePath: opts.BasePath})
|
||||
if ers != nil {
|
||||
return fmt.Errorf("schema analysis [%s]: %v", key, ers)
|
||||
|
14
vendor/github.com/go-openapi/analysis/go.mod
generated
vendored
14
vendor/github.com/go-openapi/analysis/go.mod
generated
vendored
@@ -1,13 +1,13 @@
|
||||
module github.com/go-openapi/analysis
|
||||
|
||||
require (
|
||||
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
|
||||
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 // indirect
|
||||
github.com/go-openapi/errors v0.19.2 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.2
|
||||
github.com/go-openapi/jsonpointer v0.19.3
|
||||
github.com/go-openapi/loads v0.19.0
|
||||
github.com/go-openapi/spec v0.19.2
|
||||
github.com/go-openapi/strfmt v0.19.0
|
||||
github.com/go-openapi/swag v0.19.2
|
||||
github.com/go-openapi/spec v0.19.3
|
||||
github.com/go-openapi/strfmt v0.19.3
|
||||
github.com/go-openapi/swag v0.19.5
|
||||
github.com/stretchr/testify v1.3.0
|
||||
go.mongodb.org/mongo-driver v1.1.1 // indirect
|
||||
)
|
||||
|
||||
go 1.13
|
||||
|
30
vendor/github.com/go-openapi/analysis/go.sum
generated
vendored
30
vendor/github.com/go-openapi/analysis/go.sum
generated
vendored
@@ -10,8 +10,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
||||
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/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
|
||||
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is=
|
||||
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
|
||||
github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI=
|
||||
github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0=
|
||||
github.com/go-openapi/errors v0.19.2 h1:a2kIyV3w+OS3S97zxUndRVD46+FhGOUBDFY7nmu4CsY=
|
||||
@@ -19,20 +17,30 @@ github.com/go-openapi/errors v0.19.2/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA
|
||||
github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M=
|
||||
github.com/go-openapi/jsonpointer v0.19.2 h1:A9+F4Dc/MCNB5jibxf6rRvOvR/iFgQdyNx9eIhnGqq0=
|
||||
github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg=
|
||||
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/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I=
|
||||
github.com/go-openapi/jsonreference v0.19.2 h1:o20suLFB4Ri0tuzpWtyHlh7E7HnkqTNLq6aR6WVNS1w=
|
||||
github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc=
|
||||
github.com/go-openapi/loads v0.19.0 h1:wCOBNscACI8L93tt5tvB2zOMkJ098XCw3fP0BY2ybDA=
|
||||
github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU=
|
||||
github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
|
||||
github.com/go-openapi/spec v0.19.2 h1:SStNd1jRcYtfKCN7R0laGNs80WYYvn5CbBjM2sOmCrE=
|
||||
github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY=
|
||||
github.com/go-openapi/spec v0.19.3 h1:0XRyw8kguri6Yw4SxhsQA/atC88yqrk0+G4YhI2wabc=
|
||||
github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo=
|
||||
github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU=
|
||||
github.com/go-openapi/strfmt v0.19.0 h1:0Dn9qy1G9+UJfRU7TR8bmdGxb4uifB7HNrJjOnV0yPk=
|
||||
github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY=
|
||||
github.com/go-openapi/strfmt v0.19.2 h1:clPGfBnJohokno0e+d7hs6Yocrzjlgz6EsQSDncCRnE=
|
||||
github.com/go-openapi/strfmt v0.19.2/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU=
|
||||
github.com/go-openapi/strfmt v0.19.3 h1:eRfyY5SkaNJCAwmmMcADjY31ow9+N7MCLW7oRkbsINA=
|
||||
github.com/go-openapi/strfmt v0.19.3/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU=
|
||||
github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg=
|
||||
github.com/go-openapi/swag v0.19.2 h1:jvO6bCMBEilGwMfHhrd61zIID4oIFdwb76V17SM88dE=
|
||||
github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY=
|
||||
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
@@ -45,6 +53,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63 h1:nTT4s92Dgz2HlrB2NaMgvlfqHH39OgMhA7z3PK7PGD4=
|
||||
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/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
|
||||
@@ -55,6 +65,12 @@ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoH
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
go.mongodb.org/mongo-driver v1.0.3 h1:GKoji1ld3tw2aC+GX1wbr/J2fX13yNacEYoJ8Nhr0yU=
|
||||
go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
|
||||
go.mongodb.org/mongo-driver v1.1.1 h1:Sq1fR+0c58RME5EoqKdjkiQAmPjmfHlZOoRI6fTUOcs=
|
||||
go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -62,6 +78,8 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980 h1:dfGZHvZk057jK2MCeWus/TowKpJ8y4AmooUzdBSR9GU=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM=
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
105
vendor/github.com/go-openapi/analysis/mixin.go
generated
vendored
105
vendor/github.com/go-openapi/analysis/mixin.go
generated
vendored
@@ -27,7 +27,7 @@ import (
|
||||
// collisions are avoided by appending "Mixin<N>" but only if
|
||||
// needed.
|
||||
//
|
||||
// The following parts of primary are never modified by merging:
|
||||
// The following parts of primary are subject to merge, filling empty details
|
||||
// - Info
|
||||
// - BasePath
|
||||
// - Host
|
||||
@@ -57,6 +57,8 @@ func Mixin(primary *spec.Swagger, mixins ...*spec.Swagger) []string {
|
||||
initPrimary(primary)
|
||||
|
||||
for i, m := range mixins {
|
||||
skipped = append(skipped, mergeSwaggerProps(primary, m)...)
|
||||
|
||||
skipped = append(skipped, mergeConsumes(primary, m)...)
|
||||
|
||||
skipped = append(skipped, mergeProduces(primary, m)...)
|
||||
@@ -220,10 +222,10 @@ func mergeResponses(primary *spec.Swagger, m *spec.Swagger) (skipped []string) {
|
||||
}
|
||||
primary.Responses[k] = v
|
||||
}
|
||||
return
|
||||
return skipped
|
||||
}
|
||||
|
||||
func mergeConsumes(primary *spec.Swagger, m *spec.Swagger) (skipped []string) {
|
||||
func mergeConsumes(primary *spec.Swagger, m *spec.Swagger) []string {
|
||||
for _, v := range m.Consumes {
|
||||
found := false
|
||||
for _, vv := range primary.Consumes {
|
||||
@@ -238,10 +240,10 @@ func mergeConsumes(primary *spec.Swagger, m *spec.Swagger) (skipped []string) {
|
||||
}
|
||||
primary.Consumes = append(primary.Consumes, v)
|
||||
}
|
||||
return
|
||||
return []string{}
|
||||
}
|
||||
|
||||
func mergeProduces(primary *spec.Swagger, m *spec.Swagger) (skipped []string) {
|
||||
func mergeProduces(primary *spec.Swagger, m *spec.Swagger) []string {
|
||||
for _, v := range m.Produces {
|
||||
found := false
|
||||
for _, vv := range primary.Produces {
|
||||
@@ -256,7 +258,7 @@ func mergeProduces(primary *spec.Swagger, m *spec.Swagger) (skipped []string) {
|
||||
}
|
||||
primary.Produces = append(primary.Produces, v)
|
||||
}
|
||||
return
|
||||
return []string{}
|
||||
}
|
||||
|
||||
func mergeTags(primary *spec.Swagger, m *spec.Swagger) (skipped []string) {
|
||||
@@ -279,7 +281,7 @@ func mergeTags(primary *spec.Swagger, m *spec.Swagger) (skipped []string) {
|
||||
return
|
||||
}
|
||||
|
||||
func mergeSchemes(primary *spec.Swagger, m *spec.Swagger) (skipped []string) {
|
||||
func mergeSchemes(primary *spec.Swagger, m *spec.Swagger) []string {
|
||||
for _, v := range m.Schemes {
|
||||
found := false
|
||||
for _, vv := range primary.Schemes {
|
||||
@@ -294,6 +296,95 @@ func mergeSchemes(primary *spec.Swagger, m *spec.Swagger) (skipped []string) {
|
||||
}
|
||||
primary.Schemes = append(primary.Schemes, v)
|
||||
}
|
||||
return []string{}
|
||||
}
|
||||
|
||||
func mergeSwaggerProps(primary *spec.Swagger, m *spec.Swagger) []string {
|
||||
var skipped []string
|
||||
primary.Extensions, skipped = mergeExtensions(primary.Extensions, m.Extensions)
|
||||
|
||||
// merging details in swagger top properties
|
||||
if primary.Host == "" {
|
||||
primary.Host = m.Host
|
||||
}
|
||||
if primary.BasePath == "" {
|
||||
primary.BasePath = m.BasePath
|
||||
}
|
||||
if primary.Info == nil {
|
||||
primary.Info = m.Info
|
||||
} else if m.Info != nil {
|
||||
var sk []string
|
||||
primary.Info.Extensions, sk = mergeExtensions(primary.Info.Extensions, m.Info.Extensions)
|
||||
skipped = append(skipped, sk...)
|
||||
if primary.Info.Description == "" {
|
||||
primary.Info.Description = m.Info.Description
|
||||
}
|
||||
if primary.Info.Title == "" {
|
||||
primary.Info.Description = m.Info.Description
|
||||
}
|
||||
if primary.Info.TermsOfService == "" {
|
||||
primary.Info.TermsOfService = m.Info.TermsOfService
|
||||
}
|
||||
if primary.Info.Version == "" {
|
||||
primary.Info.Version = m.Info.Version
|
||||
}
|
||||
|
||||
if primary.Info.Contact == nil {
|
||||
primary.Info.Contact = m.Info.Contact
|
||||
} else if m.Info.Contact != nil {
|
||||
if primary.Info.Contact.Name == "" {
|
||||
primary.Info.Contact.Name = m.Info.Contact.Name
|
||||
}
|
||||
if primary.Info.Contact.URL == "" {
|
||||
primary.Info.Contact.URL = m.Info.Contact.URL
|
||||
}
|
||||
if primary.Info.Contact.Email == "" {
|
||||
primary.Info.Contact.Email = m.Info.Contact.Email
|
||||
}
|
||||
}
|
||||
|
||||
if primary.Info.License == nil {
|
||||
primary.Info.License = m.Info.License
|
||||
} else if m.Info.License != nil {
|
||||
if primary.Info.License.Name == "" {
|
||||
primary.Info.License.Name = m.Info.License.Name
|
||||
}
|
||||
if primary.Info.License.URL == "" {
|
||||
primary.Info.License.URL = m.Info.License.URL
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if primary.ExternalDocs == nil {
|
||||
primary.ExternalDocs = m.ExternalDocs
|
||||
} else if m.ExternalDocs != nil {
|
||||
if primary.ExternalDocs.Description == "" {
|
||||
primary.ExternalDocs.Description = m.ExternalDocs.Description
|
||||
}
|
||||
if primary.ExternalDocs.URL == "" {
|
||||
primary.ExternalDocs.URL = m.ExternalDocs.URL
|
||||
}
|
||||
}
|
||||
return skipped
|
||||
}
|
||||
|
||||
func mergeExtensions(primary spec.Extensions, m spec.Extensions) (result spec.Extensions, skipped []string) {
|
||||
if primary == nil {
|
||||
result = m
|
||||
return
|
||||
}
|
||||
if m == nil {
|
||||
result = primary
|
||||
return
|
||||
}
|
||||
result = primary
|
||||
for k, v := range m {
|
||||
if _, found := primary[k]; found {
|
||||
skipped = append(skipped, k)
|
||||
continue
|
||||
}
|
||||
primary[k] = v
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
28
vendor/github.com/go-openapi/analysis/schema.go
generated
vendored
28
vendor/github.com/go-openapi/analysis/schema.go
generated
vendored
@@ -40,10 +40,7 @@ func Schema(opts SchemaOpts) (*AnalyzedSchema, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := a.inferTuple(); err != nil {
|
||||
// NOTE(fredbi): currently, inferTuple() never returns an error
|
||||
return nil, err
|
||||
}
|
||||
a.inferTuple()
|
||||
|
||||
if err := a.inferFromRef(); err != nil {
|
||||
return nil, err
|
||||
@@ -112,21 +109,19 @@ func (a *AnalyzedSchema) inferFromRef() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if sch != nil {
|
||||
// NOTE(fredbi): currently the only cause for errors in
|
||||
rsch, err := Schema(SchemaOpts{
|
||||
Schema: sch,
|
||||
Root: a.root,
|
||||
BasePath: a.basePath,
|
||||
})
|
||||
if err != nil {
|
||||
// NOTE(fredbi): currently the only cause for errors is
|
||||
// unresolved ref. Since spec.ExpandSchema() expands the
|
||||
// schema recursively, there is no chance to get there,
|
||||
// until we add more causes for error in this schema analysis.
|
||||
rsch, err := Schema(SchemaOpts{
|
||||
Schema: sch,
|
||||
Root: a.root,
|
||||
BasePath: a.basePath,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.inherits(rsch)
|
||||
return err
|
||||
}
|
||||
a.inherits(rsch)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -198,11 +193,10 @@ func (a *AnalyzedSchema) inferArray() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *AnalyzedSchema) inferTuple() error {
|
||||
func (a *AnalyzedSchema) inferTuple() {
|
||||
tuple := a.hasItems && a.schema.Items.Schemas != nil
|
||||
a.IsTuple = tuple && !a.hasAdditionalItems
|
||||
a.IsTupleWithExtra = tuple && a.hasAdditionalItems
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *AnalyzedSchema) inferBaseType() {
|
||||
|
Reference in New Issue
Block a user