-
Notifications
You must be signed in to change notification settings - Fork 49
Swagger Json Automation #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,83 @@ | ||||||||||||||||
| name: Sync Swagger to AMRIT-Docs | ||||||||||||||||
|
|
||||||||||||||||
| on: | ||||||||||||||||
| push: | ||||||||||||||||
| branches: [ main ] | ||||||||||||||||
| workflow_dispatch: | ||||||||||||||||
|
|
||||||||||||||||
| jobs: | ||||||||||||||||
| swagger-sync: | ||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||
|
|
||||||||||||||||
| steps: | ||||||||||||||||
| - name: Checkout API repo | ||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||
|
|
||||||||||||||||
| - name: Set up Java 17 | ||||||||||||||||
| uses: actions/setup-java@v4 | ||||||||||||||||
| with: | ||||||||||||||||
| distribution: temurin | ||||||||||||||||
| java-version: 17 | ||||||||||||||||
| cache: maven | ||||||||||||||||
|
|
||||||||||||||||
| - name: Build API (skip tests) | ||||||||||||||||
| run: mvn clean package -DskipTests | ||||||||||||||||
|
|
||||||||||||||||
| - name: Install jq | ||||||||||||||||
| run: sudo apt-get update && sudo apt-get install -y jq | ||||||||||||||||
|
|
||||||||||||||||
| - name: Run API in swagger profile | ||||||||||||||||
| run: | | ||||||||||||||||
| mvn spring-boot:run \ | ||||||||||||||||
| -Dspring-boot.run.profiles=swagger \ | ||||||||||||||||
| -Dspring-boot.run.arguments=--server.port=9090 \ | ||||||||||||||||
| > app.log 2>&1 & | ||||||||||||||||
| echo $! > api_pid.txt | ||||||||||||||||
|
|
||||||||||||||||
| - name: Wait for API & fetch Swagger | ||||||||||||||||
| run: | | ||||||||||||||||
| for i in {1..30}; do | ||||||||||||||||
| CODE=$(curl -s -o swagger_raw.json -w "%{http_code}" http://localhost:9090/v3/api-docs || true) | ||||||||||||||||
| if [ "$CODE" = "200" ]; then | ||||||||||||||||
| jq . swagger_raw.json > common-api.json | ||||||||||||||||
| echo "Swagger generated successfully" | ||||||||||||||||
| exit 0 | ||||||||||||||||
| fi | ||||||||||||||||
| echo "Waiting for API... ($i)" | ||||||||||||||||
| sleep 5 | ||||||||||||||||
| done | ||||||||||||||||
|
|
||||||||||||||||
| echo "Swagger not generated" | ||||||||||||||||
| cat app.log || true | ||||||||||||||||
| exit 1 | ||||||||||||||||
|
|
||||||||||||||||
| - name: Stop API | ||||||||||||||||
| if: always() | ||||||||||||||||
| run: | | ||||||||||||||||
| if [ -f api_pid.txt ]; then | ||||||||||||||||
| kill $(cat api_pid.txt) || true | ||||||||||||||||
| fi | ||||||||||||||||
|
|
||||||||||||||||
| - name: Checkout AMRIT-Docs | ||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||
| with: | ||||||||||||||||
| repository: DurgaPrasad-54/AMRIT-Docs | ||||||||||||||||
| token: ${{ secrets.DOCS_REPO_TOKEN }} | ||||||||||||||||
| path: amrit-docs | ||||||||||||||||
|
Comment on lines
+61
to
+66
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Workflow targets a personal fork instead of the organization repository. The checkout targets 🔧 Suggested fix - name: Checkout AMRIT-Docs
uses: actions/checkout@v4
with:
- repository: DurgaPrasad-54/AMRIT-Docs
+ repository: PSMRI/AMRIT-Docs
token: ${{ secrets.DOCS_REPO_TOKEN }}
path: amrit-docs🤖 Prompt for AI Agents |
||||||||||||||||
|
|
||||||||||||||||
| - name: Copy Swagger JSON | ||||||||||||||||
| run: | | ||||||||||||||||
| cp common-api.json amrit-docs/docs/swagger/common-api.json | ||||||||||||||||
|
Comment on lines
+68
to
+70
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure target directory exists before copy. The copy will fail if 🔧 Proposed fix - name: Copy Swagger JSON
run: |
+ mkdir -p amrit-docs/docs/swagger
cp common-api.json amrit-docs/docs/swagger/common-api.json📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
|
|
||||||||||||||||
| - name: Create Pull Request | ||||||||||||||||
| uses: peter-evans/create-pull-request@v6 | ||||||||||||||||
| with: | ||||||||||||||||
| token: ${{ secrets.DOCS_REPO_TOKEN }} | ||||||||||||||||
| path: amrit-docs | ||||||||||||||||
| branch: auto/swagger-update | ||||||||||||||||
| base: main | ||||||||||||||||
| commit-message: Auto-update Common-API swagger | ||||||||||||||||
| title: Auto-update Common-API swagger | ||||||||||||||||
| body: | | ||||||||||||||||
| This PR automatically updates the Common-API Swagger JSON | ||||||||||||||||
| from the latest main branch build. | ||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| cors.allowed-origins=* | ||
| # ---- Embedded DB for Swagger documentation generation | ||
| spring.datasource.url=jdbc:h2:mem:swaggerdb | ||
| spring.datasource.driver-class-name=org.h2.Driver | ||
| spring.datasource.username=sa | ||
| spring.datasource.password= | ||
|
|
||
| spring.jpa.database-platform=org.hibernate.dialect.H2Dialect | ||
| spring.jpa.hibernate.ddl-auto=none | ||
| spring.jpa.show-sql=false | ||
|
|
||
| spring.sql.init.mode=never | ||
|
|
||
| # Use placeholders for sensitive values | ||
| jwt.secret=<Enter_Your_Secret_Key> | ||
| jwt.expiration=3600000 | ||
| sms-password=<Enter_SMS_Password> | ||
| sms-username=<Enter_SMS_Username> | ||
| start-grievancedatasync-scheduler=false | ||
| sms-consent-source-address=<Enter_Source_Address> | ||
| send-message-url=http://localhost:8080/sms/sendMessage | ||
| secondary.datasource.username=<Enter_Username> | ||
| secondary.datasource.password=<Enter_Password> | ||
| secondary.datasource.url=jdbc:h2:mem:reportingdb | ||
| secondary.datasource.driver-class-name=org.h2.Driver | ||
|
|
||
| springdoc.api-docs.enabled=true | ||
| springdoc.swagger-ui.enabled=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
cat -n .github/workflows/swagger-json.yml | head -80Repository: PSMRI/Common-API
Length of output: 2770
🌐 Web query:
actions/checkout v4 latest release commit SHA github💡 Result:
Latest actions/checkout v4 release tag is v4.3.1, which points to commit SHA
34e114876b0b11c390a56381ad16ebd13914f8d5. [1][2]Major tag
v4currently also points to the same commit. [1]Sources:
[1] https://github.com/actions/checkout/tags
[2] actions/checkout@34e1148
🌐 Web query:
actions/setup-java v4 latest release commit SHA github💡 Result:
Latest actions/setup-java v4 release is v4.8.0, which points to commit c1e323688fd81a25caa38c78aa6df2d33d3e20d9. [1] [2]
🌐 Web query:
peter-evans/create-pull-request v6 latest release commit SHA github💡 Result:
Latest v6 release for
peter-evans/create-pull-requestis v6.1.0 (tagv6.1.0/ major tagv6), pointing to commit:Pin GitHub Actions to full commit SHAs.
Unpinned actions are a supply-chain risk. Pin
actions/checkout,actions/setup-java, andpeter-evans/create-pull-requestto their release commit SHAs:Example pinning
Also applies to: 57-62, 68-73
🤖 Prompt for AI Agents