forked from ifooth/grpc-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.go
36 lines (30 loc) · 763 Bytes
/
helpers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//go:build go1.12
// +build go1.12
package genopenapi
import (
"strings"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
func fieldName(k string) string {
return strings.ReplaceAll(cases.Title(language.AmericanEnglish).String(k), "-", "_")
}
// this method will filter the same fields and return the unique one
func getUniqueFields(schemaFieldsRequired []string, fieldsRequired []string) []string {
var unique []string
var index *int
for j, schemaFieldRequired := range schemaFieldsRequired {
index = nil
for i, fieldRequired := range fieldsRequired {
i := i
if schemaFieldRequired == fieldRequired {
index = &i
break
}
}
if index == nil {
unique = append(unique, schemaFieldsRequired[j])
}
}
return unique
}