Skip to content

Commit bfa86f9

Browse files
authored
Merge pull request #234 from fingerprintjs/chore/openapi-repo-rename-inter-2472
INTER-2472: Update schema URL and harden sync script
2 parents 0c1bd62 + 4cacae7 commit bfa86f9

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

‎sync.sh‎

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
defaultBaseUrl="https://fingerprintjs.github.io/fingerprint-pro-server-api-openapi"
4+
# Resolve paths relative to the repository root, so the script can be run from
5+
# any working directory.
6+
cd "$(dirname "${BASH_SOURCE[0]}")"
7+
8+
defaultBaseUrl="https://fingerprintjs.github.io/openapi"
59
schemaUrl="${1:-$defaultBaseUrl/schemas/fingerprint-server-api-v4.yaml}"
610
examplesBaseUrl="${2:-$defaultBaseUrl/examples}"
711

8-
mkdir -p ./res
12+
CURL_OPTS=(-fSL --retry 3 --proto-redir '=https' --connect-timeout 10 --max-time 300)
13+
if [[ "${TRACE:-}" != "true" && "${ACTIONS_STEP_DEBUG:-}" != "true" ]]; then
14+
CURL_OPTS+=(-s)
15+
fi
16+
17+
schemaDestination="./res/fingerprint-server-api.yaml"
18+
exampleBaseDestination="./test/mocks"
19+
20+
mkdir -p "$(dirname "$schemaDestination")"
921

10-
curl -fSL --retry 3 -o ./res/fingerprint-server-api.yaml "$schemaUrl"
22+
echo "Downloading $schemaUrl to $schemaDestination"
23+
curl "${CURL_OPTS[@]}" -o "$schemaDestination" "$schemaUrl"
1124

1225
examples=(
1326
'events/search/get_event_search_200.json'
@@ -27,17 +40,15 @@ examples=(
2740
'errors/429_too_many_requests.json'
2841
)
2942

30-
baseDestination="./test/mocks"
31-
mkdir -p "$baseDestination"
32-
3343
for example in "${examples[@]}"; do
34-
destinationPath="$baseDestination/$example"
35-
destinationDir="$(dirname "$destinationPath")"
36-
mkdir -p "$destinationDir"
44+
destinationPath="$exampleBaseDestination/$example"
45+
mkdir -p "$(dirname "$destinationPath")"
3746

3847
exampleUrl="$examplesBaseUrl/$example"
3948
echo "Downloading $exampleUrl to $destinationPath"
40-
curl -fSL --retry 3 -o "$destinationPath" "$exampleUrl"
49+
curl "${CURL_OPTS[@]}" -o "$destinationPath" "$exampleUrl"
4150
done
4251

52+
echo "All OpenAPI schema downloads complete."
53+
4354
./generate.sh

0 commit comments

Comments
 (0)