@@ -98,8 +98,7 @@ func (p *goPostProcessor) PopulateServerHandlers(ctx *gencontext.GenContext, pat
9898 }
9999 pathsSet := map [string ]string {}
100100 for _ , path := range paths {
101- path = strings .ReplaceAll (path , "{" , "" )
102- path = strings .ReplaceAll (path , "}" , "" )
101+ ctx .Logger .Infof ("pre path: %s" , path )
103102 pathsSet [toAPIFilename (path )] = path
104103 }
105104 ctx .Logger .Infof ("paths: %v" , pathsSet )
@@ -218,22 +217,17 @@ func isReservedFilename(name string) bool {
218217}
219218
220219var (
221- capitalLetterPattern = regexp .MustCompile (`([A-Z]+)([A-Z][a-z][a-z]+)` )
222- lowercasePattern = regexp .MustCompile (`([a-z\d])([A-Z])` )
223220 pkgSeparatorPattern = regexp .MustCompile (`\.` )
224221 dollarPattern = regexp .MustCompile (`\$` )
225222)
226223
227224// taken from openapi-generator
228225func underscore (word string ) string {
229- replacementPattern := "$1_$2"
230226 // Replace package separator with slash.
231- result := pkgSeparatorPattern .ReplaceAllString (word , "/ " )
227+ result := pkgSeparatorPattern .ReplaceAllString (word , "_ " )
232228 // Replace $ with two underscores for inner classes.
233229 result = dollarPattern .ReplaceAllString (result , "__" )
234- // Replace capital letter with _ plus lowercase letter.
235- result = capitalLetterPattern .ReplaceAllString (result , replacementPattern )
236- result = lowercasePattern .ReplaceAllString (result , replacementPattern )
230+ result = endpoints .CamelCaseToSnakeCase (result )
237231 result = strings .ReplaceAll (result , "-" , "_" )
238232 // replace space with underscore
239233 result = strings .ReplaceAll (result , " " , "_" )
@@ -246,7 +240,9 @@ func toAPIFilename(name string) string {
246240 // NOTE: openapi-generator transforms tag to camelCase, we don't do that here
247241 // we just remove slashes from path and then use openapi-generator logic
248242 // to convert this path to filename.
249- api := strings .TrimPrefix (name , "/" )
243+ api := strings .ReplaceAll (name , "{" , "" )
244+ api = strings .ReplaceAll (api , "}" , "" )
245+ api = strings .TrimPrefix (api , "/" )
250246 api = strings .TrimSuffix (api , "/" )
251247 api = strings .ReplaceAll (api , "/" , "_" )
252248 // replace - with _ e.g. created-at => created_at
0 commit comments