add swagger json automate - #344
Conversation
📝 WalkthroughWalkthroughAdds a GitHub Actions workflow that builds the Common-API WAR, runs it with a Changes
Sequence Diagram(s)sequenceDiagram
participant GH as GitHub Actions
participant Runner as CI Runner
participant App as Common-API (localhost:8083)
participant GitRemote as AMRIT-Docs
GH->>Runner: trigger workflow (push to main)
Runner->>Runner: checkout\nsetup Java 17 + Maven cache\nmvn package (skip tests)
Runner->>Runner: find WAR\nstart App with `swagger` profile (capture PID)
Runner->>App: poll GET /v3/api-docs
App-->>Runner: 200 + Swagger JSON
Runner->>Runner: save `common-api.json` (verify non-empty)
Runner->>GitRemote: clone AMRIT-Docs
Runner->>Runner: copy JSON -> amrit-docs/docs/swagger/common-api.json
Runner->>GitRemote: commit & push if changed ([skip ci])
Runner->>Runner: stop App (kill PID)
Runner-->>GH: workflow complete
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.github/workflows/swagger-export.yml:
- Around line 74-91: Update the "Commit and push" step to use a PAT with write
access to AMRIT-Docs (create a secret like AMRIT_DOCS_PAT and replace
secrets.GITHUB_TOKEN in the git push URL) and fix change detection for
docs/swagger/common-api.json so new/untracked files are detected: instead of
only running git diff --quiet docs/swagger/common-api.json, first test if the
file is tracked with git ls-files --error-unmatch docs/swagger/common-api.json
(handle its exit code), if tracked then use git diff --quiet to detect changes,
otherwise treat it as changed (or simply git add and then check git diff
--staged --quiet to see if there are staged changes) before committing; update
references in the step (Commit and push, docs/swagger/common-api.json,
secrets.GITHUB_TOKEN -> AMRIT_DOCS_PAT).
🧹 Nitpick comments (1)
.github/workflows/swagger-export.yml (1)
56-60: Add error handling for the curl request.If curl fails (e.g., network issue after endpoint was briefly available),
test -smight pass on a partial/error response. Consider checking curl's exit code explicitly.♻️ Suggested improvement
- name: Fetch Swagger JSON run: | - curl http://localhost:8083/v3/api-docs -o common-api.json + curl -f http://localhost:8083/v3/api-docs -o common-api.json test -s common-api.jsonThe
-fflag makes curl return a non-zero exit code on HTTP errors (4xx/5xx), causing the step to fail appropriately.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/main/resources/application-swagger.yml`:
- Line 12: Remove the redundant explicit Hibernate dialect setting by deleting
the database-platform property (database-platform:
org.hibernate.dialect.H2Dialect) from application-swagger.yml so Spring Boot /
Hibernate can auto-detect the H2 dialect from the JDBC URL
(jdbc:h2:mem:swaggerdb).
|
| git commit -m "chore: update Common-API Swagger [skip ci]" \ | ||
| -m "Source: ${{ github.repository }}@${{ github.sha }}" | ||
|
|
||
| git push https://x-access-token:${{ secrets.AMRIT_DOCS_PAT }}@github.com/PSMRI/AMRIT-Docs.git HEAD:main |
There was a problem hiding this comment.
How is this going to be generated? What does this variable mean?
There was a problem hiding this comment.
AMRIT_DOCS_PAT is a GitHub Personal Access Token created by a maintainer with write access to PSMRI/AMRIT-Docs and stored as a repository secret. It’s used only to authenticate the push from this workflow; for fork-based PRs the secret won’t be available, so the push step is expected to fail



Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.