fix kubectl swagger cache bug
This commit is contained in:
@@ -44,6 +44,14 @@ func NewInvalidTypeError(expected reflect.Kind, observed reflect.Kind, fieldName
|
||||
return &InvalidTypeError{expected, observed, fieldName}
|
||||
}
|
||||
|
||||
// TypeNotFoundError is returned when specified type
|
||||
// can not found in schema
|
||||
type TypeNotFoundError string
|
||||
|
||||
func (tnfe TypeNotFoundError) Error() string {
|
||||
return fmt.Sprintf("couldn't find type: %s", string(tnfe))
|
||||
}
|
||||
|
||||
// Schema is an interface that knows how to validate an API object serialized to a byte array.
|
||||
type Schema interface {
|
||||
ValidateBytes(data []byte) error
|
||||
@@ -164,7 +172,7 @@ func (s *SwaggerSchema) ValidateObject(obj interface{}, fieldName, typeName stri
|
||||
models := s.api.Models
|
||||
model, ok := models.At(typeName)
|
||||
if !ok {
|
||||
return append(allErrs, fmt.Errorf("couldn't find type: %s", typeName))
|
||||
return append(allErrs, TypeNotFoundError(typeName))
|
||||
}
|
||||
properties := model.Properties
|
||||
if len(properties.List) == 0 {
|
||||
|
Reference in New Issue
Block a user