mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 01:40:07 +00:00
stricter swagger validation
This commit is contained in:
parent
d63e35247f
commit
8cdd403d9d
@ -114,7 +114,7 @@ func (s *SwaggerSchema) ValidateObject(obj interface{}, apiVersion, fieldName, t
|
|||||||
if len(fieldName) > 0 {
|
if len(fieldName) > 0 {
|
||||||
fieldName = fieldName + "."
|
fieldName = fieldName + "."
|
||||||
}
|
}
|
||||||
//handle required fields
|
// handle required fields
|
||||||
for _, requiredKey := range model.Required {
|
for _, requiredKey := range model.Required {
|
||||||
if _, ok := fields[requiredKey]; !ok {
|
if _, ok := fields[requiredKey]; !ok {
|
||||||
allErrs = append(allErrs, fmt.Errorf("field %s: is required", requiredKey))
|
allErrs = append(allErrs, fmt.Errorf("field %s: is required", requiredKey))
|
||||||
@ -123,10 +123,7 @@ func (s *SwaggerSchema) ValidateObject(obj interface{}, apiVersion, fieldName, t
|
|||||||
for key, value := range fields {
|
for key, value := range fields {
|
||||||
details, ok := properties.At(key)
|
details, ok := properties.At(key)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Infof("unknown field: %s", key)
|
allErrs = append(allErrs, fmt.Errorf("found invalid field %s for %s", key, typeName))
|
||||||
// Some properties can be missing because of
|
|
||||||
// https://github.com/GoogleCloudPlatform/kubernetes/issues/6842.
|
|
||||||
glog.Info("this may be a false alarm, see https://github.com/GoogleCloudPlatform/kubernetes/issues/6842")
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if details.Type == nil && details.Ref == nil {
|
if details.Type == nil && details.Ref == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user