From da758bdcc508b68a39ddec2c8e9e6f594754211b Mon Sep 17 00:00:00 2001 From: Praneet Loke <1466314+praneetloke@users.noreply.github.com> Date: Sun, 10 Mar 2024 10:14:36 -0700 Subject: [PATCH] Lower-case module names. Update test case. --- pkg/resource_naming.go | 6 +++--- pkg/testdata/simple_property_ref.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/resource_naming.go b/pkg/resource_naming.go index ddd0c6e..85e9aec 100644 --- a/pkg/resource_naming.go +++ b/pkg/resource_naming.go @@ -12,7 +12,7 @@ func getModuleFromPath(path string, useParentResourceAsModule bool) string { if useParentResourceAsModule { parentPath := getParentPath(path) parentParts := strings.Split(strings.TrimPrefix(parentPath, pathSeparator), pathSeparator) - return parentParts[len(parentParts)-1] + return strings.ToLower(parentParts[len(parentParts)-1]) } parts := strings.Split(strings.TrimPrefix(path, pathSeparator), pathSeparator) @@ -20,11 +20,11 @@ func getModuleFromPath(path string, useParentResourceAsModule bool) string { // If the first item in parts is not a version number prefix, then // return as-is. if !versionRegex.Match([]byte(parts[0])) { - return parts[0] + return strings.ToLower(parts[0]) } // Otherwise, we should use a versioned module. - return parts[1] + pathSeparator + parts[0] + return strings.ToLower(parts[1]) + pathSeparator + parts[0] } func getParentPath(path string) string { diff --git a/pkg/testdata/simple_property_ref.yml b/pkg/testdata/simple_property_ref.yml index 74fc242..1fcb97b 100644 --- a/pkg/testdata/simple_property_ref.yml +++ b/pkg/testdata/simple_property_ref.yml @@ -22,7 +22,7 @@ components: $ref: "#/components/schemas/a_string_prop" paths: - /v2/fakeresource: + /v2/fakeResource: post: operationId: create_fake_resource requestBody: