github.com/grpc-ecosystem/grpc-gateway/v2@v2.19.1/protoc-gen-openapiv2/internal/genopenapi/helpers.go (about) 1 //go:build go1.12 2 // +build go1.12 3 4 package genopenapi 5 6 import ( 7 "strings" 8 9 "golang.org/x/text/cases" 10 "golang.org/x/text/language" 11 ) 12 13 func fieldName(k string) string { 14 return strings.ReplaceAll(cases.Title(language.AmericanEnglish).String(k), "-", "_") 15 } 16 17 // this method will filter the same fields and return the unique one 18 func getUniqueFields(schemaFieldsRequired []string, fieldsRequired []string) []string { 19 var unique []string 20 var index *int 21 22 for j, schemaFieldRequired := range schemaFieldsRequired { 23 index = nil 24 for i, fieldRequired := range fieldsRequired { 25 i := i 26 if schemaFieldRequired == fieldRequired { 27 index = &i 28 break 29 } 30 } 31 if index == nil { 32 unique = append(unique, schemaFieldsRequired[j]) 33 } 34 } 35 return unique 36 }