fix kubectl swagger cache bug

This commit is contained in:
AdoHe
2016-03-04 18:59:40 -05:00
parent a9594b4470
commit 893e36c61d
3 changed files with 105 additions and 12 deletions

View File

@@ -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 {