From 999f27d8e93e0c708700282967263f377153534a Mon Sep 17 00:00:00 2001 From: Mads Date: Wed, 17 Nov 2021 16:48:06 +0100 Subject: [PATCH] Fix x-kubernetes-int-or-string precedence Give x-kubernetes-int-or-string precedence over anyOf, allOf and oneOf --- gen/schema.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gen/schema.go b/gen/schema.go index 911d2b4..f71741f 100644 --- a/gen/schema.go +++ b/gen/schema.go @@ -194,6 +194,11 @@ func GetTypeSpec(schema map[string]interface{}, name string, types map[string]ps return anyTypeSpec } + intOrString, foundIntOrString, _ := unstruct.NestedBool(schema, "x-kubernetes-int-or-string") + if foundIntOrString && intOrString { + return intOrStringTypeSpec + } + // If the schema is of the `oneOf` type: return a TypeSpec with the `OneOf` // field filled with the TypeSpec of all sub-schemas. oneOf, foundOneOf, _ := NestedMapSlice(schema, "oneOf") @@ -229,11 +234,6 @@ func GetTypeSpec(schema map[string]interface{}, name string, types map[string]ps return GetTypeSpec(combinedSchema, name, types) } - intOrString, foundIntOrString, _ := unstruct.NestedBool(schema, "x-kubernetes-int-or-string") - if foundIntOrString && intOrString { - return intOrStringTypeSpec - } - preserveUnknownFields, foundPreserveUnknownFields, _ := unstruct.NestedBool(schema, "x-kubernetes-preserve-unknown-fields") if foundPreserveUnknownFields && preserveUnknownFields { return arbitraryJSONTypeSpec