@@ -6,7 +6,7 @@ ROOT_DIR=$(git rev-parse --show-toplevel)
66OAS_REPO_NAME=$1
77OAS_REPO=$2
88ALLOW_ALPHA=$3
9- OAS_API_VERSION =$4
9+ OAS_API_VERSIONS =$4
1010
1111if [[ -z ${OAS_REPO_NAME} ]]; then
1212 echo " Repo name is empty, default public OAS repo name will be used."
@@ -18,9 +18,9 @@ if [[ ! ${OAS_REPO} || -d ${OAS_REPO} ]]; then
1818 OAS_REPO=" https://github.com/stackitcloud/${OAS_REPO_NAME} .git"
1919fi
2020
21- if [[ -z ${OAS_API_VERSION } ]]; then
22- echo " No API version passed, main branch will be used "
23- OAS_API_VERSION= " main "
21+ if [[ -z ${OAS_API_VERSIONS } ]]; then
22+ echo " No API version passed, using ${ROOTDIR} /api-versions.json "
23+ OAS_API_VERSIONS= " ${ROOTDIR} /api-versions.json "
2424fi
2525
2626# Create temp directory to clone OAS repo
@@ -41,16 +41,23 @@ mkdir ${ROOT_DIR}/oas
4141cd ${work_dir}
4242git clone ${OAS_REPO} --quiet
4343
44- echo " Using api version ${OAS_API_VERSION} "
45- cd ${OAS_REPO_NAME}
46- git checkout --quiet ${OAS_API_VERSION}
47- cd -
48-
4944for service_dir in ${work_dir} /${OAS_REPO_NAME} /services/* ; do
45+
5046 max_version_dir=" "
5147 max_version=-1
5248 service=$( basename " $service_dir " )
5349
50+ apiVersion=$( jq -r -f <( cat << EOF
51+ if has("${service} ") then ."${service} " else "main" end
52+ EOF
53+ ) ${OAS_API_VERSIONS} )
54+ if [ " ${apiVersion} " != " main" ]; then
55+ echo " Using ${apiVersion} for ${service} "
56+ fi
57+ cd ${work_dir} /${OAS_REPO_NAME} > /dev/null
58+ git checkout -q $apiVersion
59+ cd - > /dev/null
60+
5461 # Prioritize GA over Beta over Alpha versions
5562 # GA priority = 3, Beta priority = 2, Alpha priority = 1
5663 max_version_priority=1
0 commit comments