Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions sync.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

defaultBaseUrl="https://fingerprintjs.github.io/fingerprint-pro-server-api-openapi"
# Resolve paths relative to the repository root, so the script can be run from
# any working directory.
cd "$(dirname "${BASH_SOURCE[0]}")"

defaultBaseUrl="https://fingerprintjs.github.io/openapi"
schemaUrl="${1:-$defaultBaseUrl/schemas/fingerprint-server-api-v4.yaml}"
examplesBaseUrl="${2:-$defaultBaseUrl/examples}"

mkdir -p ./res
CURL_OPTS=(-fSL --retry 3 --proto-redir '=https' --connect-timeout 10 --max-time 300)
if [[ "${TRACE:-}" != "true" && "${ACTIONS_STEP_DEBUG:-}" != "true" ]]; then
CURL_OPTS+=(-s)
Comment thread
erayaydin marked this conversation as resolved.
fi

schemaDestination="./res/fingerprint-server-api.yaml"
exampleBaseDestination="./src/Fingerprint.ServerSdk.Test/mocks"

mkdir -p "$(dirname "$schemaDestination")"

curl -fSL -o ./res/fingerprint-server-api.yaml "$schemaUrl"
echo "Downloading $schemaUrl to $schemaDestination"
curl "${CURL_OPTS[@]}" -o "$schemaDestination" "$schemaUrl"

examplesList=(
examples=(
'errors/400_ip_address_invalid.json'
'errors/400_request_body_invalid.json'
'errors/403_feature_not_enabled.json'
Expand All @@ -22,16 +35,13 @@ examplesList=(
'webhook/webhook_event.json'
)

baseDestination="./src/Fingerprint.ServerSdk.Test/mocks"

for example in "${examplesList[@]}"; do
destinationPath="$baseDestination/$example"
destinationDir="$(dirname "$destinationPath")"

mkdir -p "$destinationDir"
for example in "${examples[@]}"; do
destinationPath="$exampleBaseDestination/$example"
mkdir -p "$(dirname "$destinationPath")"

echo "Downloading $example to $destinationPath"
curl -fSL -o "$destinationPath" "$examplesBaseUrl/$example"
exampleUrl="$examplesBaseUrl/$example"
echo "Downloading $exampleUrl to $destinationPath"
curl "${CURL_OPTS[@]}" -o "$destinationPath" "$exampleUrl"
done

echo "All OpenAPI documentation downloads complete."
echo "All OpenAPI schema downloads complete."
Loading