@@ -17,32 +17,30 @@ set -o nounset
1717# # OpenAPI file (latest)
1818OPENAPI_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
2421OPENAPI_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
3026versions_file=" versions.json"
3127
3228pushd " ${OPENAPI_FOLDER} "
29+ versions_url=" ${API_BASE_URL} /${versions_file} "
3330echo " Fetching versions from $versions_url "
3431
3532curl --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
4745echo " Fetching api from $openapi_url to $OPENAPI_FILE_NAME "
4846
0 commit comments