Skip to content

Commit 77eaa5b

Browse files
authored
Fix x-kubernetes-int-or-string precedence (#60)
Give x-kubernetes-int-or-string precedence over anyOf, allOf and oneOf
1 parent 671bb76 commit 77eaa5b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

gen/schema.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ func GetTypeSpec(schema map[string]interface{}, name string, types map[string]ps
205205
return anyTypeSpec
206206
}
207207

208+
intOrString, foundIntOrString, _ := unstruct.NestedBool(schema, "x-kubernetes-int-or-string")
209+
if foundIntOrString && intOrString {
210+
return intOrStringTypeSpec
211+
}
212+
208213
// If the schema is of the `oneOf` type: return a TypeSpec with the `OneOf`
209214
// field filled with the TypeSpec of all sub-schemas.
210215
oneOf, foundOneOf, _ := NestedMapSlice(schema, "oneOf")
@@ -240,11 +245,6 @@ func GetTypeSpec(schema map[string]interface{}, name string, types map[string]ps
240245
return GetTypeSpec(combinedSchema, name, types)
241246
}
242247

243-
intOrString, foundIntOrString, _ := unstruct.NestedBool(schema, "x-kubernetes-int-or-string")
244-
if foundIntOrString && intOrString {
245-
return intOrStringTypeSpec
246-
}
247-
248248
preserveUnknownFields, foundPreserveUnknownFields, _ := unstruct.NestedBool(schema, "x-kubernetes-preserve-unknown-fields")
249249
if foundPreserveUnknownFields && preserveUnknownFields {
250250
return arbitraryJSONTypeSpec

0 commit comments

Comments
 (0)