feat: Swagger and merchant policy reports #662
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Validate modified OpenAPI YAML/TPL files | |
| on: | |
| pull_request: | |
| paths: | |
| - 'src/idpay/apim/api/**' | |
| permissions: | |
| contents: read | |
| jobs: | |
| validate-openapi: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | |
| with: | |
| node-version: '20' | |
| - name: Install Spectral CLI and rulesets | |
| run: | | |
| npm install -g @stoplight/spectral-cli | |
| npm install @stoplight/spectral-owasp-ruleset | |
| - name: Get list of modified OpenAPI files | |
| id: get_modified_files | |
| run: | | |
| echo "π Fetching modified OpenAPI files in this PR..." | |
| curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| "${{ github.api_url }}/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" \ | |
| | jq -r '.[].filename' \ | |
| | grep -E '^src/idpay/apim/api/.*openapi.*\.(yml|yaml|yml.tpl|yaml.tpl)$' || true | |
| - name: Validate OpenAPI files with Spectral | |
| run: | | |
| files=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| "${{ github.api_url }}/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" \ | |
| | jq -r '.[].filename' \ | |
| | grep -E '^src/idpay/apim/api/.*openapi.*\.(yml|yaml|yml.tpl|yaml.tpl)$' || true) | |
| if [ -z "$files" ]; then | |
| echo "β No OpenAPI files were modified in this PR." | |
| exit 0 | |
| fi | |
| echo "π OpenAPI files to validate:" | |
| echo "$files" | |
| failed=0 | |
| for file in $files; do | |
| echo "" | |
| echo "βββββββββββββββββββββββββββββββββββββββ" | |
| echo "π Validating $file" | |
| echo "βββββββββββββββββββββββββββββββββββββββ" | |
| spectral lint -r .spectral.yaml --verbose "$file" || { | |
| echo "β Spectral validation failed for $file" | |
| failed=1 | |
| } | |
| done | |
| if [ $failed -eq 1 ]; then | |
| echo "" | |
| echo "β Validation failed for one or more OpenAPI files." | |
| exit 1 | |
| else | |
| echo "" | |
| echo "β All modified OpenAPI files passed validation." | |
| fi |