Skip to content

Commit

Permalink
regex check in concatenate tokens (#27)
Browse files Browse the repository at this point in the history
Remove unvalid characters from schema refs.
  • Loading branch information
gicont authored Mar 28, 2023
1 parent 7776596 commit 4ea4a46
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/spec/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package spec
import (
"encoding/json"
"fmt"
"regexp"
"sort"
"strings"

Expand Down Expand Up @@ -132,7 +133,8 @@ func generateDefNameFromPropNames(propNames []string) string {
// generate name based on properties names when 'defNameHint' is missing
// sort the slice to get more stable test results
sort.Strings(propNames)
return strings.Join(propNames, "_")
propString := strings.Join(propNames, "_")
return regexp.MustCompile(`[^a-zA-Z0-9._-]+`).ReplaceAllString(propString, "")
}

func getUniqueSchemeName(schemes spec.Schemas, name string) string {
Expand Down

0 comments on commit 4ea4a46

Please sign in to comment.