diff --git a/store/proxy/proxy_store.go b/store/proxy/proxy_store.go index 4e5fd737..8e24c38f 100644 --- a/store/proxy/proxy_store.go +++ b/store/proxy/proxy_store.go @@ -383,7 +383,7 @@ func (s *Store) Create(apiContext *types.APIContext, schema *types.Schema, data if name == "" { generated, _ := values.GetValueN(data, "metadata", "generateName").(string) if generated == "" { - values.PutValue(data, types.GenerateName(schema.ID), "metadata", "name") + values.PutValue(data, types.GenerateTypePrefix(schema.ID), "metadata", "generateName") } } diff --git a/types/id.go b/types/id.go index 9c6618d1..514b9336 100644 --- a/types/id.go +++ b/types/id.go @@ -17,3 +17,8 @@ func GenerateName(typeName string) string { last := utilrand.String(5) return fmt.Sprintf("%s-%s", strings.ToLower(base), last) } + +func GenerateTypePrefix(typeName string) string { + base := typeName[0:1] + lowerChars.ReplaceAllString(typeName[1:], "") + return strings.ToLower(base) + "-" +}