Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #31 from flanksource/fix-int-or-string
Browse files Browse the repository at this point in the history
fix: use anyOf if types/format is empty (for int-or-string type)
  • Loading branch information
moshloop authored Mar 7, 2021
2 parents a6ca19d + b87b9b9 commit f3c7e1a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions k8s/schema_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,20 @@ func (m *SchemaManager) FindTypeForKeyFromSchema(schema *spec.Schema, key string
return nil, errors.Wrapf(err, "failed to find type for key %s", key)
}

if len(fieldSchema.Type) == 0 && fieldSchema.Format == "" {
types := []string{}
format := ""
for _, sc := range fieldSchema.AnyOf {
if len(sc.Type) > 0 {
types = append(types, sc.Type...)
}
if sc.Format != "" && format == "" {
format = sc.Format
}
}
return &TypedField{Types: types, Format: format}, nil
}

typedField := &TypedField{Types: fieldSchema.Type, Format: fieldSchema.Format}
return typedField, nil
}
Expand Down

0 comments on commit f3c7e1a

Please sign in to comment.