Skip to content

Commit 2bb72c6

Browse files
authored
CLOUDP-261809: update sdk to use mongodb/openapi (#517)
1 parent e4b8378 commit 2bb72c6

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

.github/workflows/autoupdate-preview.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ jobs:
1818
working-directory: ./tools
1919
run: make fetch_openapi
2020
env:
21-
API_BASE_URL: ${{ secrets.MDB_CURRENT_API_PREVIEW_URL }}
22-
S3_BUCKET: ${{ secrets.MDB_CURRENT_API_PREVIEW_S3_BUCKET }}
21+
API_BASE_URL: https://raw.githubusercontent.com/mongodb/openapi/refs/heads/dev/openapi/v2
2322
- name: Verify Changed files
2423
uses: tj-actions/verify-changed-files@6b59fb7cbb8d9a6ecc10ee556496d0078a9ed957
2524
id: verify-changed-files

tools/releaser/scripts/extract-version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SDK_MINOR_VERSION=$(echo "$SDK_VERSION" | awk -F'.' '{print $2}')
1313
SDK_MAJOR_VERSION=$(echo "$SDK_VERSION" | awk -F'.' '{print $1}')
1414

1515
# Extract the last version from the versions.json file
16-
HYPEN_RESOURCE_VERSION=$(cat $versions_file_path | jq -r '.versions."2.0" | .[-1]')
16+
HYPEN_RESOURCE_VERSION=$(cat $versions_file_path | jq -r ' .[-1]')
1717
NEW_RESOURCE_VERSION=$(echo "$HYPEN_RESOURCE_VERSION" | tr -d '-')
1818

1919
echo "Extracted version from version.go file: '$SDK_VERSION'. Resource Version: '$SDK_RESOURCE_VERSION'"

tools/scripts/fetch.sh

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,30 @@ set -o nounset
1717
## OpenAPI file (latest)
1818
OPENAPI_FILE_NAME=${OPENAPI_FILE_NAME:-"atlas-api.yaml"}
1919

20-
## Base URL
21-
API_BASE_URL=${API_BASE_URL:-"https://cloud.mongodb.com"}
22-
2320
## Folder used for fetching files
2421
OPENAPI_FOLDER=${OPENAPI_FOLDER:-"../openapi"}
2522

26-
## S3 bucket where the spec is hosted
27-
S3_BUCKET=${S3_BUCKET:-"mongodb-mms-prod-build-server"}
2823

29-
versions_url="${API_BASE_URL}/api/openapi/versions"
24+
# Base URL for fetching the openapi file
25+
API_BASE_URL=${API_BASE_URL:-}https://raw.githubusercontent.com/mongodb/openapi/refs/heads/main/openapi/v2
3026
versions_file="versions.json"
3127

3228
pushd "${OPENAPI_FOLDER}"
29+
versions_url="${API_BASE_URL}/${versions_file}"
3330
echo "Fetching versions from $versions_url"
3431

3532
curl --show-error --fail --silent -o "${versions_file}" \
3633
-H "Accept: application/json" "${versions_url}"
3734

38-
## Dynamic Versioned API Version
39-
CURRENT_API_REVISION=$(jq -r '.versions."2.0" | .[-1]' < "./${versions_file}")
35+
# Remove "preview" from versions file if it exists and update the file
36+
jq 'map(select(. != "preview"))' < "./${versions_file}" > "./${versions_file}.tmp"
37+
mv "./${versions_file}.tmp" "./${versions_file}"
4038

41-
echo "Fetching OpenAPI release sha"
42-
sha=$(curl --show-error --fail --silent -H "Accept: text/plain" "${API_BASE_URL}/api/private/unauth/version")
39+
## Dynamic Versioned API Version
40+
CURRENT_API_REVISION=$(jq -r '.[-1]' < "./${versions_file}")
4341

44-
echo "Fetching OAS file for ${sha}"
45-
openapi_url="https://${S3_BUCKET}.s3.amazonaws.com/openapi/${sha}-v2-${CURRENT_API_REVISION}.yaml"
42+
echo "Fetching OAS file for version $CURRENT_API_REVISION"
43+
openapi_url=${API_BASE_URL}/openapi-${CURRENT_API_REVISION}.yaml
4644

4745
echo "Fetching api from $openapi_url to $OPENAPI_FILE_NAME"
4846

0 commit comments

Comments
 (0)