talk2map-test / .github /scripts /validate-postman.sh
Noel-Teens's picture
testing new workflow
bfa95ad
Raw History Blame Contribute Delete
2.71 kB
#!/bin/bash
# Postman Collection Validator
# This script validates the Talk2Map Postman collection before running tests
echo "πŸ” Validating Postman collection..."
# Check if collection file exists
if [ ! -f "Talk2Map.postman_collection.json" ]; then
echo "❌ Postman collection file not found!"
exit 1
fi
# Check if collection is valid JSON
if ! jq empty Talk2Map.postman_collection.json 2>/dev/null; then
echo "❌ Invalid JSON in Postman collection!"
exit 1
fi
# Extract collection info
collection_name=$(jq -r '.info.name' Talk2Map.postman_collection.json)
echo "βœ… Collection: $collection_name"
# Count requests
request_count=$(jq '[.item[].request] | length' Talk2Map.postman_collection.json)
echo "βœ… Total requests: $request_count"
# List all request names
echo "πŸ“‹ Available endpoints:"
jq -r '.item[].name' Talk2Map.postman_collection.json | sed 's/^/ - /'
# Check for required variables
if jq -e '.variable[] | select(.key=="baseUrl")' Talk2Map.postman_collection.json > /dev/null; then
default_url=$(jq -r '.variable[] | select(.key=="baseUrl") | .value' Talk2Map.postman_collection.json)
echo "βœ… Base URL variable found (default: $default_url)"
else
echo "⚠️ No baseUrl variable found in collection"
fi
# Validate bounding_box requirements for Talk2Map API
echo "πŸ” Checking bounding_box requirements..."
missing_bbox_count=0
# Check each request for bounding_box field (excluding health check)
for i in $(jq '.item | to_entries[] | select(.value.name != "Health") | .key' Talk2Map.postman_collection.json); do
request_name=$(jq -r ".item[$i].name" Talk2Map.postman_collection.json)
# Only check the main request body (not originalRequest in responses)
if jq -e ".item[$i].request.body.raw" Talk2Map.postman_collection.json > /dev/null; then
raw_body=$(jq -r ".item[$i].request.body.raw" Talk2Map.postman_collection.json)
# Parse the raw JSON body and check for bounding_box
if echo "$raw_body" | jq -e '.bounding_box' > /dev/null 2>&1; then
echo "βœ… Has bounding_box: $request_name"
else
echo "❌ Missing bounding_box in: $request_name"
echo " Raw body preview: $(echo "$raw_body" | head -c 100)..."
((missing_bbox_count++))
fi
else
echo "⚠️ No request body found for: $request_name"
fi
done
if [ $missing_bbox_count -gt 0 ]; then
echo "❌ $missing_bbox_count requests missing required bounding_box field!"
echo "Talk2Map API requires bounding_box for all /chat endpoints."
exit 1
fi
echo "βœ… All requests have required bounding_box field!"
echo "βœ… Postman collection validation complete!"