Skip to content

Commit f2e2f90

Browse files
committed
apiextensions: filter null types in ConvertJSONSchemaPropsToOpenAPIv2Schema
1 parent 23b7d8b commit f2e2f90

File tree

1 file changed

+10
-6
lines changed
  • staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi

1 file changed

+10
-6
lines changed

staging/src/k8s.io/apiextensions-apiserver/pkg/controller/openapi/conversion.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ func ConvertJSONSchemaPropsToOpenAPIv2Schema(in *apiextensions.JSONSchemaProps)
6262
}
6363
}
6464

65-
if len(p.Type) > 1 {
66-
// https://github.com/kubernetes/kube-openapi/pull/143/files#diff-62afddb578e9db18fb32ffb6b7802d92R272
67-
// We also set Properties to null to enforce parseArbitrary at https://github.com/kubernetes/kube-openapi/blob/814a8073653e40e0e324205d093770d4e7bb811f/pkg/util/proto/document.go#L247
65+
switch {
66+
case len(p.Type) == 2 && (p.Type[0] == "null" || p.Type[1] == "null"):
67+
// https://github.com/kubernetes/kube-openapi/pull/143/files#diff-ce77fea74b9dd098045004410023e0c3R219
6868
p.Type = nil
69-
p.Properties = nil
70-
} else if len(p.Type) == 1 {
69+
case len(p.Type) == 1:
7170
switch p.Type[0] {
7271
case "null":
7372
// https://github.com/kubernetes/kube-openapi/pull/143/files#diff-ce77fea74b9dd098045004410023e0c3R219
@@ -80,7 +79,12 @@ func ConvertJSONSchemaPropsToOpenAPIv2Schema(in *apiextensions.JSONSchemaProps)
8079
p.Items = nil
8180
}
8281
}
83-
} else {
82+
case len(p.Type) > 1:
83+
// https://github.com/kubernetes/kube-openapi/pull/143/files#diff-62afddb578e9db18fb32ffb6b7802d92R272
84+
// We also set Properties to null to enforce parseArbitrary at https://github.com/kubernetes/kube-openapi/blob/814a8073653e40e0e324205d093770d4e7bb811f/pkg/util/proto/document.go#L247
85+
p.Type = nil
86+
p.Properties = nil
87+
default:
8488
// https://github.com/kubernetes/kube-openapi/pull/143/files#diff-62afddb578e9db18fb32ffb6b7802d92R248
8589
p.Properties = nil
8690
}

0 commit comments

Comments
 (0)