diff --git a/scripts/generate-sdk/generate-sdk.sh b/scripts/generate-sdk/generate-sdk.sh index 10c8417..b0f7646 100755 --- a/scripts/generate-sdk/generate-sdk.sh +++ b/scripts/generate-sdk/generate-sdk.sh @@ -105,24 +105,22 @@ for service_json in ${ROOT_DIR}/oas/*.json; do service="${service%.json}" # Remove invalid characters to ensure a valid Go pkg name - service="${service//-/}" # remove dashes - service="${service// /}" # remove empty spaces - service="${service//_/}" # remove underscores - service="${service,,}" # convert upper case letters to lower case - service=$(echo "${service}" | tr -d -c '[:alnum:]') # remove non-alphanumeric characters + service="${service//-/}" # remove dashes + service="${service// /}" # remove empty spaces + service="${service//_/}" # remove underscores + service=$(echo "${service}" | tr '[:upper:]' '[:lower:]') # convert upper case letters to lower case + service=$(echo "${service}" | tr -d -c '[:alnum:]') # remove non-alphanumeric characters go_pkg_name_format="^[a-z0-9]+$" - if [[ ! ${service} =~ ${go_pkg_name_format} ]]; # check that it is a single lower case word - then + if [[ ! ${service} =~ ${go_pkg_name_format} ]]; then # check that it is a single lower case word echo "Service ${service} has an invalid Go package name even after removing invalid characters. The generate-sdk.sh script might need to be updated to catch corner case, contact the repo maintainers." - exit 1 + exit 1 fi contains_empty_space_pattern=" |'" - if [[ ${service_json} =~ ${contains_empty_space_pattern} ]]; - then + if [[ ${service_json} =~ ${contains_empty_space_pattern} ]]; then echo "OAS filename ${service_json} has empty spaces, the generation will fail. If the OAS was downloaded using the make download-oas command, it should be fixed in the api-specifications repo, please contact the repo maintainers at ${OAS_REPO}." - exit 1 + exit 1 fi echo "Generating ${service} service..."