-
Notifications
You must be signed in to change notification settings - Fork 49
chore(swagger): automate swagger sync to amrit-docs #354
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
base: main
Are you sure you want to change the base?
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughThis pull request introduces a Swagger profile-based configuration system for isolated API documentation builds. Changes include: a new GitHub Actions workflow that automates extracting Swagger JSON from the API and syncing it to the AMRIT-Docs repository; addition of H2 database dependency; annotation of multiple beans and configurations with Changes
Sequence DiagramsequenceDiagram
participant GitHub as GitHub<br/>Actions
participant API as API<br/>Server
participant jq as Validation<br/>(jq)
participant Docs as AMRIT-Docs<br/>Repository
GitHub->>GitHub: Checkout API repo & build
GitHub->>API: Start API (swagger profile on :9090)
GitHub->>GitHub: Poll /v3/api-docs (up to 30 attempts)
activate API
loop Polling
GitHub->>API: GET /v3/api-docs
API-->>GitHub: Return Swagger JSON
end
deactivate API
GitHub->>jq: Validate JSON structure
jq-->>GitHub: Valid ✓
GitHub->>GitHub: Write common-api.json
GitHub->>API: Kill API process
GitHub->>Docs: Checkout AMRIT-Docs (token auth)
GitHub->>Docs: Copy common-api.json to docs/swagger/
GitHub->>Docs: Create PR to main<br/>(branch: auto/swagger-update-*)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/java/com/iemr/common/config/quartz/ScheduleJobForNHMDashboardData.java (1)
34-38:⚠️ Potential issue | 🟡 MinorUnused import -
@Profileannotation appears to be missing.The
Profileimport was added but the@Profile("!swagger")annotation was not applied to the class. Based on the pattern in other files (e.g.,SecondaryReportServiceImpl,CallReportSecondaryRepo), this scheduled job should likely be excluded from the swagger profile to prevent it from running during Swagger documentation generation.🔧 Proposed fix
import org.springframework.context.annotation.Profile; `@Service` +@Profile("!swagger") `@Transactional` public class ScheduleJobForNHMDashboardData implements Job {
🧹 Nitpick comments (4)
.github/workflows/swagger-json.yml (2)
77-88: Consider addingdelete-branch: trueto clean up after merge.The
create-pull-requestaction will create new branches (auto/swagger-update-<run_id>) on each run. Without cleanup, these branches will accumulate in the AMRIT-Docs repository after PRs are merged.♻️ Proposed fix
- name: Create Pull Request uses: peter-evans/create-pull-request@v6 with: token: ${{ secrets.DOCS_REPO_TOKEN }} path: amrit-docs branch: auto/swagger-update-${{ github.run_id }} base: main commit-message: Auto-update Common-API swagger title: Auto-update Common-API swagger + delete-branch: true body: | This PR automatically updates the Common-API Swagger JSON from the latest main branch build.
8-11: Consider adding a job timeout.The workflow lacks a
timeout-minutessetting. If the API fails to start or hangs, the job could run for up to 6 hours (GitHub's default limit). Adding a timeout would fail fast and conserve CI resources.♻️ Proposed fix
jobs: swagger-sync: runs-on: ubuntu-latest + timeout-minutes: 15src/main/resources/application-swagger.properties (1)
15-15: Use consistent placeholder format forjwt.secret.The
jwt.secretvalueJWT_SECRETappears to be a literal string rather than following the placeholder pattern used elsewhere in this file (e.g.,<Enter_SMS_Password>,<Enter_Username>). For consistency and to clearly indicate this is a placeholder requiring replacement, consider using a similar format.Suggested change
-jwt.secret=JWT_SECRET +jwt.secret=<Enter_JWT_Secret>Based on learnings: "JWT secrets should be configured using placeholders (e.g.,
<Enter_Your_Secret_Key>) in properties files... to prevent accidental commit of actual secrets."src/main/java/com/iemr/common/config/PrimaryDBConfig.java (1)
51-51: Consider using import instead of fully qualified class name.Other files in this PR import
Profileand use@Profile("!swagger"). For consistency, consider adding the import and using the short form here as well.Suggested change
Add import at the top of the file:
import org.springframework.context.annotation.Profile;Then change:
-@org.springframework.context.annotation.Profile("!swagger") +@Profile("!swagger")
|



Summary by CodeRabbit
New Features
Chores