Fix CRD validation error for 'items' field
Signed-off-by: He Xiaoxi <xxhe@alauda.io>
This commit is contained in:
31
vendor/github.com/go-openapi/loads/spec.go
generated
vendored
31
vendor/github.com/go-openapi/loads/spec.go
generated
vendored
@@ -16,6 +16,7 @@ package loads
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
@@ -50,6 +51,10 @@ func init() {
|
||||
loaders = defaultLoader
|
||||
spec.PathLoader = loaders.Fn
|
||||
AddLoader(swag.YAMLMatcher, swag.YAMLDoc)
|
||||
|
||||
gob.Register(map[string]interface{}{})
|
||||
gob.Register([]interface{}{})
|
||||
//gob.Register(spec.Refable{})
|
||||
}
|
||||
|
||||
// AddLoader for a document
|
||||
@@ -76,7 +81,7 @@ func JSONSpec(path string) (*Document, error) {
|
||||
return nil, err
|
||||
}
|
||||
// convert to json
|
||||
return Analyzed(json.RawMessage(data), "")
|
||||
return Analyzed(data, "")
|
||||
}
|
||||
|
||||
// Document represents a swagger spec document
|
||||
@@ -120,9 +125,9 @@ func Spec(path string) (*Document, error) {
|
||||
lastErr = err2
|
||||
continue
|
||||
}
|
||||
doc, err := Analyzed(b, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
doc, err3 := Analyzed(b, "")
|
||||
if err3 != nil {
|
||||
return nil, err3
|
||||
}
|
||||
if doc != nil {
|
||||
doc.specFilePath = path
|
||||
@@ -176,8 +181,8 @@ func Analyzed(data json.RawMessage, version string) (*Document, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
origsqspec := new(spec.Swagger)
|
||||
if err := json.Unmarshal(raw, origsqspec); err != nil {
|
||||
origsqspec, err := cloneSpec(swspec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -252,6 +257,7 @@ func (d *Document) Raw() json.RawMessage {
|
||||
return d.raw
|
||||
}
|
||||
|
||||
// OrigSpec yields the original spec
|
||||
func (d *Document) OrigSpec() *spec.Swagger {
|
||||
return d.origSpec
|
||||
}
|
||||
@@ -277,3 +283,16 @@ func (d *Document) Pristine() *Document {
|
||||
func (d *Document) SpecFilePath() string {
|
||||
return d.specFilePath
|
||||
}
|
||||
|
||||
func cloneSpec(src *spec.Swagger) (*spec.Swagger, error) {
|
||||
var b bytes.Buffer
|
||||
if err := gob.NewEncoder(&b).Encode(src); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var dst spec.Swagger
|
||||
if err := gob.NewDecoder(&b).Decode(&dst); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &dst, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user