diff --git a/api.go b/api.go index ae64f1a..4a2978b 100644 --- a/api.go +++ b/api.go @@ -151,6 +151,8 @@ type API struct { // Apply customisation to a specific type by checking the t parameter. // Apply customisations to all types by ignoring the t parameter. ApplyCustomSchemaToType func(t reflect.Type, s *openapi3.Schema) + + ApplyPostNormalizeTransform func(normalized string) string } // Merge route data into the existing configuration. diff --git a/schema.go b/schema.go index 3850b27..3dca0e2 100644 --- a/schema.go +++ b/schema.go @@ -444,8 +444,18 @@ func (api *API) normalizeTypeName(pkgPath, name string) string { break } } + + var normalized string + if omitPackage || pkgPath == "" { - return normalizer.Replace(name) + normalized = normalizer.Replace(name) + } else { + normalized = normalizer.Replace(pkgPath + "/" + name) } - return normalizer.Replace(pkgPath + "/" + name) + + if api.ApplyPostNormalizeTransform != nil { + normalized = api.ApplyPostNormalizeTransform(normalized) + } + + return normalized }