Skip to content

Commit 4014b17

Browse files
committed
fix(oas): respect STACKIT API versioning spec during OAS download
relates to STACKITSDK-136
1 parent 4b51c0a commit 4014b17

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

scripts/download-oas.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ EOF
5959
cd - > /dev/null
6060

6161
# Prioritize GA over Beta over Alpha versions
62-
# GA priority = 3, Beta priority = 2, Alpha priority = 1
62+
# GA priority = 999, Beta priority >= 2, Alpha priority = 1
6363
max_version_priority=1
6464

6565
for dir in ${service_dir}/*; do
6666
version=$(basename "$dir")
67-
current_version_priority=3
67+
current_version_priority=999
6868
# Check if directory name starts with 'v'
6969
if [[ ${version} == v* ]]; then
7070
# Remove the 'v' prefix
@@ -85,9 +85,16 @@ EOF
8585
fi
8686
# Check if version is beta
8787
if [[ ${version} == *beta* ]]; then
88-
# Remove 'beta' suffix
89-
version=${version%beta*}
9088
current_version_priority=2
89+
90+
# check if the version is e.g. "v2beta2"
91+
if [[ ${version} =~ beta([0-9]+)$ ]]; then
92+
betaVersion="${BASH_REMATCH[1]}"
93+
current_version_priority=$((betaVersion+current_version_priority))
94+
fi
95+
96+
# Remove 'beta' suffix
97+
version=${version%beta*}
9198
fi
9299
# Compare versions, prioritizing GA over Beta over Alpha versions
93100
if [[ $((version)) -gt ${max_version} || ($((version)) -eq ${max_version} && ${current_version_priority} -gt ${max_version_priority}) ]]; then

0 commit comments

Comments
 (0)