Updating pkg/api/validation/ to consider swagger.items as object and not array

This commit is contained in:
nikhiljindal
2015-03-12 16:04:11 -07:00
parent e11f62cfcf
commit b2276b5d4b
2 changed files with 17 additions and 49 deletions

View File

@@ -126,7 +126,7 @@ func (s *SwaggerSchema) validateField(value interface{}, apiVersion, fieldName,
if !ok { if !ok {
return NewInvalidTypeError(reflect.Array, reflect.TypeOf(value).Kind(), fieldName) return NewInvalidTypeError(reflect.Array, reflect.TypeOf(value).Kind(), fieldName)
} }
arrType := *fieldDetails.Items[0].Ref arrType := *fieldDetails.Items.Ref
for ix := range arr { for ix := range arr {
err := s.validateField(arr[ix], apiVersion, fmt.Sprintf("%s[%d]", fieldName, ix), arrType, nil) err := s.validateField(arr[ix], apiVersion, fmt.Sprintf("%s[%d]", fieldName, ix), arrType, nil)
if err != nil { if err != nil {

View File

@@ -943,11 +943,9 @@
"properties": { "properties": {
"command": { "command": {
"type": "array", "type": "array",
"items": [ "items": {
{
"$ref": "string" "$ref": "string"
} }
]
}, },
"cpu": { "cpu": {
"type": "integer", "type": "integer",
@@ -955,11 +953,9 @@
}, },
"env": { "env": {
"type": "array", "type": "array",
"items": [ "items": {
{
"$ref": "v1beta1.EnvVar" "$ref": "v1beta1.EnvVar"
} }
]
}, },
"image": { "image": {
"type": "string" "type": "string"
@@ -982,11 +978,9 @@
}, },
"ports": { "ports": {
"type": "array", "type": "array",
"items": [ "items": {
{
"$ref": "v1beta1.Port" "$ref": "v1beta1.Port"
} }
]
}, },
"privileged": { "privileged": {
"type": "boolean" "type": "boolean"
@@ -996,11 +990,9 @@
}, },
"volumeMounts": { "volumeMounts": {
"type": "array", "type": "array",
"items": [ "items": {
{
"$ref": "v1beta1.VolumeMount" "$ref": "v1beta1.VolumeMount"
} }
]
}, },
"workingDir": { "workingDir": {
"type": "string" "type": "string"
@@ -1018,11 +1010,9 @@
"properties": { "properties": {
"containers": { "containers": {
"type": "array", "type": "array",
"items": [ "items": {
{
"$ref": "v1beta1.Container" "$ref": "v1beta1.Container"
} }
]
}, },
"id": { "id": {
"type": "string" "type": "string"
@@ -1038,11 +1028,9 @@
}, },
"volumes": { "volumes": {
"type": "array", "type": "array",
"items": [ "items": {
{
"$ref": "v1beta1.Volume" "$ref": "v1beta1.Volume"
} }
]
} }
} }
}, },
@@ -1075,11 +1063,9 @@
}, },
"endpoints": { "endpoints": {
"type": "array", "type": "array",
"items": [ "items": {
{
"$ref": "string" "$ref": "string"
} }
]
}, },
"id": { "id": {
"type": "string" "type": "string"
@@ -1130,11 +1116,9 @@
}, },
"items": { "items": {
"type": "array", "type": "array",
"items": [ "items": {
{
"$ref": "v1beta1.Endpoints" "$ref": "v1beta1.Endpoints"
} }
]
}, },
"kind": { "kind": {
"type": "string" "type": "string"
@@ -1260,11 +1244,9 @@
}, },
"items": { "items": {
"type": "array", "type": "array",
"items": [ "items": {
{
"$ref": "v1beta1.Event" "$ref": "v1beta1.Event"
} }
]
}, },
"kind": { "kind": {
"type": "string" "type": "string"
@@ -1288,11 +1270,9 @@
"properties": { "properties": {
"command": { "command": {
"type": "array", "type": "array",
"items": [ "items": {
{
"$ref": "string" "$ref": "string"
} }
]
} }
} }
}, },
@@ -1482,22 +1462,18 @@
}, },
"items": { "items": {
"type": "array", "type": "array",
"items": [ "items": {
{
"$ref": "v1beta1.Minion" "$ref": "v1beta1.Minion"
} }
]
}, },
"kind": { "kind": {
"type": "string" "type": "string"
}, },
"minions": { "minions": {
"type": "array", "type": "array",
"items": [ "items": {
{
"$ref": "v1beta1.Minion" "$ref": "v1beta1.Minion"
} }
]
}, },
"namespace": { "namespace": {
"type": "string" "type": "string"
@@ -1639,11 +1615,9 @@
}, },
"items": { "items": {
"type": "array", "type": "array",
"items": [ "items": {
{
"$ref": "v1beta1.Pod" "$ref": "v1beta1.Pod"
} }
]
}, },
"kind": { "kind": {
"type": "string" "type": "string"
@@ -1813,11 +1787,9 @@
}, },
"items": { "items": {
"type": "array", "type": "array",
"items": [ "items": {
{
"$ref": "v1beta1.ReplicationController" "$ref": "v1beta1.ReplicationController"
} }
]
}, },
"kind": { "kind": {
"type": "string" "type": "string"
@@ -1942,11 +1914,9 @@
}, },
"publicIPs": { "publicIPs": {
"type": "array", "type": "array",
"items": [ "items": {
{
"$ref": "string" "$ref": "string"
} }
]
}, },
"resourceVersion": { "resourceVersion": {
"type": "uint64" "type": "uint64"
@@ -1999,11 +1969,9 @@
}, },
"items": { "items": {
"type": "array", "type": "array",
"items": [ "items": {
{
"$ref": "v1beta1.Service" "$ref": "v1beta1.Service"
} }
]
}, },
"kind": { "kind": {
"type": "string" "type": "string"