Skip to content

added gitignore and api definition for testing #2

added gitignore and api definition for testing

added gitignore and api definition for testing #2

# Basic Tyk API + Policies validation triggered on any PR requests. The idea of this workflow is to validate specific field requirements
# or enforce governance to make sure specific custom plugins are used or formats
name: Tyk Schema Validation
# Perform the Tyk schema validation only on PR requests
on:
pull_request:
branches: [ main ]
jobs:
schema-validation:
runs-on: ubuntu-latest
steps:
# Check out the current repo and fetch only the current commits (JTBD)
- name: 'Checkout Repository'
uses: actions/checkout@v4
with:
fetch-depth: 1
# List the content that exists within the repo to validate the files
- name: 'List Repository Contents'
run: |
ls -la
pwd
# Install JQ library used to introspect the API and Policy definitions
- name: 'Install JQ Library'
uses: dcarbone/install-jq-action@v2
- name: 'Check JQ Library'
run: |
which jq
jq --version
# Governance to validate minimum required fields
- name: 'Validate min fields for APIs and Policies'
run: |
for file in $(find . -name "*.json"); do
echo "Validating $file"
# Check if target_url is valid and not empty
if jq -e '.proxy.target_url | length > 0' "$file" > /dev/null; then
echo "$file contains a valid proxy.target_url."
target_url=$(jq -r '.proxy.target_url' "$file")
echo "proxy.target_url: $target_url"
else
echo "$file does NOT contain a valid proxy.target_url."
exit 1
fi
# Check if either JWT auth or or StaticMTLS is enabled
if jq -e '.enable_jwt == true or .auth_configs.use_mutual_tls_auth == true' "$file" > /dev/null; then
echo "$file has either enable_jwt or auth_configs.use_mutual_tls_auth set to true."
else
echo "$file does NOT have either enable_jwt or auth_configs.use_mutual_tls_auth set to true."
exit 1
fi
done