Skip to content

chore(swagger): automate swagger sync to amrit-docs#354

Merged
drtechie merged 3 commits intoPSMRI:mainfrom
DurgaPrasad-54:main
Feb 10, 2026
Merged

chore(swagger): automate swagger sync to amrit-docs#354
drtechie merged 3 commits intoPSMRI:mainfrom
DurgaPrasad-54:main

Conversation

@DurgaPrasad-54
Copy link
Copy Markdown
Contributor

@DurgaPrasad-54 DurgaPrasad-54 commented Feb 2, 2026

Summary by CodeRabbit

  • New Features

    • Added automated workflow to synchronize API documentation to the documentation repository on code changes.
  • Chores

    • Added database dependency for documentation and development environments.
    • Implemented profile-based isolation to separate documentation generation from production configurations.
    • Added configuration environment for API documentation generation with embedded database support.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 2, 2026

Warning

Rate limit exceeded

@DurgaPrasad-54 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 43 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📝 Walkthrough

Walkthrough

This 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 @Profile("!swagger") to exclude them from Swagger profile runs; and creation of an application-swagger.properties file with profile-specific settings including in-memory databases.

Changes

Cohort / File(s) Summary
CI/CD Automation
.github/workflows/swagger-json.yml
New GitHub Actions workflow that builds the API, extracts /v3/api-docs via polling, validates with jq, and creates a pull request to sync the Swagger JSON into the AMRIT-Docs repository.
Dependency Management
pom.xml
Added H2 database runtime dependency for in-memory database usage in Swagger profile.
Database Configuration
src/main/java/com/iemr/common/config/PrimaryDBConfig.java, src/main/java/com/iemr/common/config/SecondaryDBConfig.java
Applied @Profile("!swagger") to both classes; removed "com.iemr.common.repo" from PrimaryDBConfig basePackages list.
Swagger Profile Exclusions
src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java, src/main/java/com/iemr/common/controller/secondaryReport/CustomerRelationshipSecondaryReports.java, src/main/java/com/iemr/common/service/beneficiary/BenRelationshipTypeServiceImpl.java, src/main/java/com/iemr/common/service/beneficiary/BeneficiaryOccupationServiceImpl.java, src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java, src/main/java/com/iemr/common/service/beneficiary/SexualOrientationServiceImpl.java, src/main/java/com/iemr/common/service/reportSecondary/SecondaryReportServiceImpl.java, src/main/java/com/iemr/common/secondary/repository/callreport/CallReportSecondaryRepo.java, src/main/java/com/iemr/common/utils/FilterConfig.java, src/main/java/com/iemr/common/utils/JwtAuthenticationUtil.java, src/main/java/common/iemr/common/secondary/data/report/SecondaryCallReport.java
Applied @Profile("!swagger") annotations to exclude these beans from loading when the Swagger profile is active.
Scheduler Configuration
src/main/java/com/iemr/common/config/quartz/ScheduleJobForNHMDashboardData.java
Added Profile import; no annotation applied (import preparation).
Profile-Specific Configuration
src/main/resources/application-swagger.properties
New configuration file with CORS allowlist, embedded H2 datasources, JPA settings, JWT placeholders, scheduler toggle, messaging endpoint, and SpringDoc/Swagger UI enablement for Swagger profile.
Properties Cleanup
src/main/resources/application.properties
Removed duplicate blank lines for formatting consistency.
Report Service Interface
src/main/java/com/iemr/common/service/reportSecondary/SecondaryReportService.java
Minor formatting change (added blank line between license header and package declaration).

Sequence Diagram

sequenceDiagram
    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-*)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hops through the code with glee,
A Swagger profile sets beans free,
H2 in memory, docs auto-sync'd,
GitHub Actions and profiles linked,
The API's dressed in profiles neat!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: automating the synchronization of Swagger documentation to the AMRIT-Docs repository. It directly relates to the primary purpose of the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a 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 | 🟡 Minor

Unused import - @Profile annotation appears to be missing.

The Profile import 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 adding delete-branch: true to clean up after merge.

The create-pull-request action 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-minutes setting. 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: 15
src/main/resources/application-swagger.properties (1)

15-15: Use consistent placeholder format for jwt.secret.

The jwt.secret value JWT_SECRET appears 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 Profile and 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")

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Feb 4, 2026

@drtechie drtechie merged commit f60f36e into PSMRI:main Feb 10, 2026
4 checks passed
vanitha1822 added a commit that referenced this pull request Apr 20, 2026
* Update application.properties

* add column in create BeneficiaryModel

* Elasticsearch implementation for Beneficiary Search (#324)

* fix: implement functionality to search beneficiaries with Elasticsearch

* fix: remove unwanted import

* fix: update pom.xml

* fix: change the response code

* variable added

* update language

* update language

* Downgrade version from 3.6.1 to 3.6.0

* Elastic Search Implementation for Advanced Search (#327)

* fix: cherry-pick commits for advanced search

* fix: cherry-pick commit for token issue - mobile application

* fix: add the missing properties

* fix: add function to retrieve userid

* fix: move the fetch Userid to jwtUtil

* Remove empty line in application.properties

* fix:signature check for mmu

* Update application.properties

* Update application.properties

* fix: retrive any user without deleted

* implement state wise hide un hide form fields

* implement state wise hide un hide form fields

* implement state wise hide un hide form fields

* enhance welcome sms code

* fix hide unhide form issue

* docs: add DeepWiki badge and documentation link

* Add DeepWiki badge to README

Added DeepWiki badge to README for better visibility.

* fix hide unhide form issue

* fix hide unhide form issue

* fix hide unhide form issue

* fix hide unhide form issue

* fix hide unhide form issue

* fix hide unhide form issue

* fix hide unhide form issue

* fix hide unhide form issue

* fix hide unhide form issue

* fix hide unhide form issue

* fix hide unhide form issue

* fix hide unhide form issue

* fix hide unhide form issue

* fix hide unhide form issue

* fix hide unhide form issue

* fix hide unhide form issue

* chore(swagger): automate swagger sync to amrit-docs (#354)

* chore(swagger): automate swagger sync to amrit-docs

* chore(swagger): automate swagger sync to amrit-docs

* chore(swagger): automate swagger sync to amrit-docs

* Update the swagger json github workflow (#359)

* chore(swagger): automate swagger sync to amrit-docs

* chore(swagger): automate swagger sync to amrit-docs

* chore(swagger): automate swagger sync to amrit-docs

* fix(swagger): update the workflow and fix the running issue

* fix(swagger): fix the swagger json workflow

* chore(swagger): add fixed branch name in workflow

* chore(ci): prevent multiple swagger sync PRs by using fixed branch

* chore(swagger): add Dev/UAT/Demo servers to OpenAPI config

* chore(swagger): avoid default server URLs

* chore(swagger): remove field injection and inject URLs into OpenAPI bean

* Add /health endpoint and standardize /version response (#331)

* Add /health endpoint and standardize /version response

* Add license headers and Javadocs to health and version controllers

* Enhance /health endpoint to check Database and Redis connectivity

* Improve /health endpoint HTTP status handling and logging

* Enhance database health check with validation query

* Refactor health controller to constructor injection and constants

* Refactor: Extract business logic to HealthService to keep controller lean

* Refactor: Extract business logic to HealthService to keep controller lean

* Fix: Use ObjectProvider for optional health dependencies

* Add advance health check for database (#361)

* chore(swagger): automate swagger sync to amrit-docs

* chore(swagger): automate swagger sync to amrit-docs

* chore(swagger): automate swagger sync to amrit-docs

* fix(swagger): update the workflow and fix the running issue

* fix(swagger): fix the swagger json workflow

* chore(swagger): add fixed branch name in workflow

* chore(ci): prevent multiple swagger sync PRs by using fixed branch

* chore(swagger): add Dev/UAT/Demo servers to OpenAPI config

* chore(swagger): avoid default server URLs

* chore(swagger): remove field injection and inject URLs into OpenAPI bean

* feat(health,version): update version and health endpoints and add advance check for database

* fix(health): normalize severity and fix slow query false positives

* fix(health): avoid false CRITICAL on single long-running MySQL transaction

* fix(health): enforce 3s DB connection timeout via HikariCP

* Merge Release-3.8.0 (3.6.1) to Main (#379)

* Move code to 3.6.1 to 3.8.0 (#372)

* fix: cors spell fixes and import of packages updates

* fix: deployment issue fix

* feat: amm-1959 dhis token for cho report re-direction

* fix: beneficiary history on revisit (#320)

* fix: call type mapper (#322)

* Elasticsearch implementation for Beneficiary Search (#324)

* fix: implement functionality to search beneficiaries with Elasticsearch

* fix: remove unwanted import

* fix: update pom.xml

* fix: change the response code

* variable added

* Elastic Search Implementation for Advanced Search (#327)

* fix: cherry-pick commits for advanced search

* fix: cherry-pick commit for token issue - mobile application

* fix: add the missing properties

* fix: add function to retrieve userid

* fix: move the fetch Userid to jwtUtil

* fix:signature check for mmu

* fix: retrive any user without deleted

* fix: update KM filepath

* FLW-713 Remove All File Upload Options (#350)

* FLW-713 Remove All File Upload Options

* Fix UserServiceRoleRepo dependency issue and codeRabit comment

* fixed coderabit comment

* fix userMappingId issue

* Add SMS functionality in release-3.6.1 (#358)

* Enable SMS Functionality in MMU App to Send Prescriptions  (#325)

* fix: sms template save and map mmu (#306)

* Vb/sms (#307)

* fix: sms template save and map mmu

* fix: enable mms for mmu prescription

* Enable SMS Functionality in MMU App to Send Prescriptions  (#325)

* fix: sms template save and map mmu (#306)

* Vb/sms (#307)

* fix: sms template save and map mmu

* fix: enable mms for mmu prescription

---------

Co-authored-by: Vishwanath Balkur <118195001+vishwab1@users.noreply.github.com>

---------

Co-authored-by: 5Amogh <amoghavarsh@navadhiti.com>
Co-authored-by: Vanitha S <116701245+vanitha1822@users.noreply.github.com>
Co-authored-by: Sachin Kadam <152252767+sac2kadam@users.noreply.github.com>
Co-authored-by: vanitha1822 <vanitha@navadhiti.com>
Co-authored-by: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com>

* fix: add OTP rate limiting to prevent OTP flooding on sendConsent endpoint (#373)

- Add OtpRateLimiterService with Redis-backed per-mobile rate limits (3/min, 10/hr, 20/day)
- Add OtpRateLimitException for 429 responses
- Integrate rate limiter in BeneficiaryOTPHandlerImpl and BeneficiaryConsentController
- Add otp.ratelimit.* properties to common_ci and common_docker profiles
- Update common_example.properties with new OTP rate limit config

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

* Health api (#376)

* Cherry-pick health and version API enhancements to release-3.6.1 (#371)

* feat(health,version): update version and health endpoints and add advance check for database

* fix(health): normalize severity and fix slow query false positives

* fix(health): avoid false CRITICAL on single long-running MySQL transaction

* fix(health): enforce 3s DB connection timeout via HikariCP

* Release 3.6.1 (#374)

* feat(health,version): update version and health endpoints and add advance check for database

* fix(health): normalize severity and fix slow query false positives

* fix(health): avoid false CRITICAL on single long-running MySQL transaction

* fix(health): enforce 3s DB connection timeout via HikariCP

* feat(health): add healthcontroller and fix versioncontroller issues

* fix: build error (#375)

---------

Co-authored-by: KOPPIREDDY DURGA PRASAD <144464542+DurgaPrasad-54@users.noreply.github.com>
Co-authored-by: Vanitha S <116701245+vanitha1822@users.noreply.github.com>

---------

Co-authored-by: Vishwanath Balkur <118195001+vishwab1@users.noreply.github.com>
Co-authored-by: 5Amogh <amoghavarsh@navadhiti.com>
Co-authored-by: Sachin Kadam <152252767+sac2kadam@users.noreply.github.com>
Co-authored-by: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: KOPPIREDDY DURGA PRASAD <144464542+DurgaPrasad-54@users.noreply.github.com>

* fix: video consultation functionality

* fix: pom version update

* fix: add cti-server-ip

* fix: comment unwanted code

* fix: update videocall url property

* fix: update cti-server-ip

* docs: add CLAUDE.md for Claude Code guidance

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: KM issue

* fix: KM issue

* fix: remove unwanted imports

* fix: conflicts

* fix: update the temp path

* Fix the OpenKM Issue (#389)

* fix: remove km in application.properties

* fix: update all the properties to fetch from env

* fix: update path

* fix: KM issue

* fix: get file from km

* fix: build issue

* fix: build issue

* fix: remove unwanted imports

* fix: build issue

* fix: remove commented line

* Enable KM configuration in common_example.properties

Uncomment KM configuration properties for OpenKM.

* Fix ConfigProperties to resolve env variable placeholders via Spring Environment (#390)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: update sms issue

* fix: build issue

* fix: update condition

* fix: edit ben issue

* fix: phone number issue for sms

* fix: update the url with jwt token

* fix: jitsi authorization issue

* fix: skip auth

* fix: hash key updation

* fix: jwt type in header for authorization

* fix: update file path

* fix: vc recording path updation

* fix: update video call recording functionality

* fix: remove unwanted codes

* fix: coderabbit comments

---------

Co-authored-by: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com>
Co-authored-by: Saurav Mishra <saurav.mishra@bizbrolly.com>
Co-authored-by: Sachin Kadam <152252767+sac2kadam@users.noreply.github.com>
Co-authored-by: Mithun James <drtechie@users.noreply.github.com>
Co-authored-by: Amoghavarsh <93114621+5Amogh@users.noreply.github.com>
Co-authored-by: vishwab1 <vishwanath@navadhiti.com>
Co-authored-by: SnehaRH <77656297+snehar-nd@users.noreply.github.com>
Co-authored-by: DurgaPrasad-54 <prasad8790237@gmail.com>
Co-authored-by: KOPPIREDDY DURGA PRASAD <144464542+DurgaPrasad-54@users.noreply.github.com>
Co-authored-by: Vaishnav Bhosale <vaishnavbharatbhosale@gmail.com>
Co-authored-by: Vishwanath Balkur <118195001+vishwab1@users.noreply.github.com>
Co-authored-by: 5Amogh <amoghavarsh@navadhiti.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: SnehaRH <sneha@navadhiti.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants