Strip defaults in new places

This commit is contained in:
Antoine Pelisse
2020-11-11 12:42:12 -08:00
parent 07a40273eb
commit de4abee3ef
6 changed files with 15 additions and 5 deletions

View File

@@ -42,5 +42,6 @@ go_test(
deps = [
"//staging/src/k8s.io/apimachinery/pkg/util/diff:go_default_library",
"//vendor/github.com/go-openapi/spec:go_default_library",
"//vendor/k8s.io/kube-openapi/pkg/handler:go_default_library",
],
)

View File

@@ -24,12 +24,15 @@ import (
"github.com/go-openapi/spec"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/kube-openapi/pkg/handler"
)
func TestOpenAPIRoundtrip(t *testing.T) {
dummyRef := func(name string) spec.Ref { return spec.MustCreateRef("#/definitions/dummy") }
for name, value := range GetOpenAPIDefinitions(dummyRef) {
t.Run(name, func(t *testing.T) {
// TODO(kubernetes/gengo#193): We currently round-trip ints to floats.
value.Schema = *handler.PruneDefaultsSchema(&value.Schema)
data, err := json.Marshal(value.Schema)
if err != nil {
t.Error(err)