Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix x-kubernetes-int-or-string precedence
Give x-kubernetes-int-or-string precedence over anyOf, allOf and oneOf
  • Loading branch information
madsbacha authored Nov 17, 2021
commit 999f27d8e93e0c708700282967263f377153534a
10 changes: 5 additions & 5 deletions gen/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down