Skip to content

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

Open
DurgaPrasad-54 wants to merge 5 commits intoPSMRI:mainfrom
DurgaPrasad-54:main
Open

chore(swagger): automate swagger sync to amrit-docs#63
DurgaPrasad-54 wants to merge 5 commits intoPSMRI:mainfrom
DurgaPrasad-54:main

Conversation

@DurgaPrasad-54
Copy link
Contributor

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

Summary by CodeRabbit

  • New Features

    • Added automated workflow to synchronize Swagger API documentation to the documentation repository
    • Introduced Swagger profile for API documentation generation and testing
  • Documentation

    • Added DeepWiki project badge to README

@coderabbitai
Copy link

coderabbitai bot commented Feb 6, 2026

Warning

Rate limit exceeded

@DurgaPrasad-54 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 59 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

This pull request introduces automated Swagger documentation synchronization for the scheduler API. A new GitHub Actions workflow generates Swagger JSON during API builds and creates pull requests to sync the documentation to the AMRIT-Docs repository. Supporting changes include adding H2 database runtime dependency, a Swagger profile configuration file, and a documentation badge.

Changes

Cohort / File(s) Summary
Swagger Documentation Automation
.github/workflows/swagger-json.yml
New GitHub Actions workflow that builds the API in swagger profile, starts it on port 9090, polls and validates the Swagger JSON endpoint, and creates an automated PR to sync scheduler-api.json to the AMRIT-Docs repository.
Application Configuration
src/main/resources/application-swagger.properties
New configuration file for swagger profile containing H2 in-memory database setup, Redis defaults, CORS origins, JWT secret, and public API endpoints for beneficiary and user search.
Build Dependencies
pom.xml
Added runtime dependency for H2 database (com.h2database:h2) to support in-memory database initialization in the swagger profile.
Documentation
README.md
Added DeepWiki documentation badge for reference and visibility.

Sequence Diagram

sequenceDiagram
    participant GitHub as GitHub<br/>(Trigger)
    participant Actions as GitHub Actions<br/>(Runner)
    participant Maven as Maven
    participant API as API Server
    participant Swagger as Swagger<br/>Endpoint
    participant Validation as Validation<br/>(jq)
    participant Docs as AMRIT-Docs<br/>Repo
    participant PullRequest as GitHub API<br/>(PR Creation)

    GitHub->>Actions: Push to main / Manual dispatch
    Actions->>Maven: Build API (package, skip tests)
    Maven-->>Actions: Build artifacts
    Actions->>API: Start API (swagger profile, port 9090)
    API-->>Actions: Started
    
    loop Poll until valid
        Actions->>Swagger: GET /swagger-json
        Swagger-->>Actions: JSON response
        Actions->>Validation: Validate JSON paths
        Validation-->>Actions: Validation result
    end
    
    Actions->>API: Stop API process
    API-->>Actions: Stopped
    
    Actions->>Docs: Checkout AMRIT-Docs repo
    Docs-->>Actions: Repository cloned
    Actions->>Actions: Copy scheduler-api.json
    Actions->>Docs: Update docs/swagger/scheduler-api.json
    Actions->>PullRequest: Create PR with auto-generated commit
    PullRequest-->>GitHub: PR created
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'chore(swagger): automate swagger sync to amrit-docs' accurately summarizes the main change: introducing GitHub Actions workflow automation to sync Swagger documentation to the AMRIT-Docs repository.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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

@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: 3

🤖 Fix all issues with AI agents
In @.github/workflows/swagger-json.yml:
- Around line 89-100: Update the Create Pull Request step: change the action
reference from "peter-evans/create-pull-request@v6" to the latest v8 (e.g.,
"@v8") and add the input "delete-branch: true" to the step inputs so branches
are removed when there is no remaining diff; locate the step using the "Create
Pull Request" name and the "peter-evans/create-pull-request" usage in the
workflow and add the new input alongside existing keys like token, path, branch,
base, commit-message, title and body.

In `@src/main/resources/application-swagger.properties`:
- Around line 15-16: Fix the typo and remove the weak hardcoded fallback for the
JWT secret: correct `defualt-key` to `default-key` if you must keep a documented
placeholder, but preferably remove the static fallback from the `jwt.secret`
property so the app/profile fails when `JWT_SECRET_KEY` is unset (change to use
no default or throw on missing env), or replace it with a long
cryptographically-random value if you absolutely need a reproducible default for
CI; also add a short comment that any static default is only for doc/CI
generation and not for production. Ensure you update the `jwt.secret` property
reference and the `JWT_SECRET_KEY` handling consistently so the value cannot
silently fall back to a guessable string.
- Around line 6-8: Update the swagger profile properties to use the Spring Boot
3.2 Redis property namespace and explicitly disable the session store: replace
occurrences of spring.redis.host and spring.redis.port with
spring.data.redis.host and spring.data.redis.port, and add
spring.session.store-type=none so the swagger profile does not inherit a Redis
session store; adjust any references in the file that mention spring.redis.* to
spring.data.redis.* and ensure spring.session.store-type is set to "none" for
the swagger profile.
🧹 Nitpick comments (5)
pom.xml (1)

254-258: Consider scoping H2 to a Maven profile to avoid shipping it in the production WAR.

With <scope>runtime</scope>, H2 will be bundled into the final WAR deployed to production. Since it's only needed for the CI swagger-generation step, you could wrap it in a Maven <profile> (e.g., swagger) and activate it only during the workflow build. This avoids enlarging the production artifact with an unused in-memory database driver.

♻️ Example: isolate H2 in a Maven profile
-		<dependency>
-			<groupId>com.h2database</groupId>
-			<artifactId>h2</artifactId>
-			<scope>runtime</scope>
-		</dependency>

Add a Maven profile at the bottom of pom.xml:

<profiles>
  <profile>
    <id>swagger</id>
    <dependencies>
      <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
      </dependency>
    </dependencies>
  </profile>
</profiles>

Then in the workflow, build and run with -Pswagger:

- name: Build API (skip tests)
  run: mvn -B clean package -DskipTests -Pswagger

- name: Run API in swagger profile
  run: |
    nohup mvn spring-boot:run \
      -Pswagger \
      -Dspring-boot.run.profiles=swagger \
      ...
.github/workflows/swagger-json.yml (4)

3-6: Consider adding a path filter to avoid unnecessary runs.

Every push to main triggers this workflow, including documentation-only or CI config changes. Adding a path filter prevents wasted CI minutes when no API code has changed.

♻️ Suggested path filter
 on:
   push:
     branches: [ main ]
+    paths:
+      - 'src/**'
+      - 'pom.xml'
   workflow_dispatch:

26-38: Double build: mvn package then mvn spring-boot:run recompiles the project.

spring-boot:run forks a new build lifecycle, so the project is effectively built twice. Consider running the already-built WAR directly:

♻️ Run the built artifact instead
       - name: Build API (skip tests)
-        run: mvn -B clean package -DskipTests
+        run: mvn -B clean package -DskipTests -Dspring-boot.run.skip=true

       - name: Run API in swagger profile
         run: |
-          nohup mvn spring-boot:run \
-            -Dspring-boot.run.profiles=swagger \
-            -Dspring-boot.run.arguments=--server.port=9090 \
-            > app.log 2>&1 &
+          WAR_FILE=$(find target -name '*.war' -type f | head -1)
+          nohup java -jar "$WAR_FILE" \
+            --spring.profiles.active=swagger \
+            --server.port=9090 \
+            > app.log 2>&1 &
           echo $! > api_pid.txt

This also improves PID tracking — $! will capture the actual Java process PID rather than a nohup mvn shell wrapper, making the kill in the cleanup step more reliable.


14-17: fetch-depth: 0 is unnecessary for this use case.

Full git history isn't needed to build the project. The default shallow clone (fetch-depth: 1) would speed up checkout.

       - name: Checkout API repo (full history)
         uses: actions/checkout@v4
-        with:
-          fetch-depth: 0

29-30: jq is pre-installed on GitHub-hosted ubuntu-latest runners.

Remove this step to save CI time.

Remove unnecessary step
-      - name: Install jq
-        run: sudo apt-get update && sudo apt-get install -y jq

Comment on lines +89 to +100
- 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 }}-${{ github.run_attempt }}
base: main
commit-message: "chore(docs): auto-update Scheduler-API swagger"
title: "chore(docs): auto-update Scheduler-API swagger"
body: |
This PR automatically updates Scheduler-API Swagger JSON
from the latest main branch build.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

peter-evans create-pull-request latest version 2026

💡 Result:

Latest peter-evans/create-pull-request version (as of Feb 6, 2026) is v8.1.0 (released Jan 21, 2026). [1]

Recommended usage (major pin):

- uses: peter-evans/create-pull-request@v8

[2]

Exact pin:

- uses: peter-evans/create-pull-request@v8.1.0

[1]

Sources: [1] [2]


🌐 Web query:

peter-evans create-pull-request delete-branch option

💡 Result:

In peter-evans/create-pull-request, the delete-branch input controls whether the action will delete the PR branch when it determines the branch is no longer needed.

  • Set it like this:
- uses: peter-evans/create-pull-request@v8
  with:
    branch: my-auto-branch
    delete-branch: true
  • What it does:
    1. If a PR becomes unnecessary (no diff remains), the action will close the PR and delete the branch.
    2. If a PR was merged but the branch wasn’t deleted, then the next time the action runs, it will delete the branch if there’s still no diff.
  • What it does not do: it doesn’t delete the branch immediately on merge (that would require the merge event to trigger the action). If you want immediate deletion on merge, use GitHub’s repo setting “Automatically delete head branches”. [1]

🌐 Web query:

peter-evans create-pull-request@v6 2025 2026 current version

💡 Result:

As of February 6, 2026, the current major version of peter-evans/create-pull-request is v8, with the latest release shown as v8.0.0 (Dec 9, 2025). [1]

So peter-evans/create-pull-request@v6 is not current; update to:

  • uses: peter-evans/create-pull-request@v8 (recommended major pin), or
  • uses: peter-evans/create-pull-request@v8.0.0 (exact pin)

The GitHub Marketplace usage example also reflects @v8. [2]

Sources: [1] [2]


Upgrade to peter-evans/create-pull-request@v8 and add delete-branch: true with additional configuration.

peter-evans/create-pull-request@v6 is outdated (latest is v8.1.0 as of Jan 2026). The delete-branch: true option should be added, but note it only deletes branches when the action detects no remaining diff—it does not immediately clean up merged branches. To fully prevent stale branch accumulation, also enable GitHub's repository setting "Automatically delete head branches" so merged branches are deleted immediately.

♻️ Update action version and add delete-branch option
       - name: Create Pull Request
-        uses: peter-evans/create-pull-request@v6
+        uses: peter-evans/create-pull-request@v8
         with:
           token: ${{ secrets.DOCS_REPO_TOKEN }}
           path: amrit-docs
           branch: auto/swagger-update-${{ github.run_id }}-${{ github.run_attempt }}
           base: main
           commit-message: "chore(docs): auto-update Scheduler-API swagger"
           title: "chore(docs): auto-update Scheduler-API swagger"
+          delete-branch: true
           body: |
             This PR automatically updates Scheduler-API Swagger JSON
             from the latest main branch build.
🤖 Prompt for AI Agents
In @.github/workflows/swagger-json.yml around lines 89 - 100, Update the Create
Pull Request step: change the action reference from
"peter-evans/create-pull-request@v6" to the latest v8 (e.g., "@v8") and add the
input "delete-branch: true" to the step inputs so branches are removed when
there is no remaining diff; locate the step using the "Create Pull Request" name
and the "peter-evans/create-pull-request" usage in the workflow and add the new
input alongside existing keys like token, path, branch, base, commit-message,
title and body.

Comment on lines 6 to 8
# Disable Redis if not needed for docs (optional)
spring.redis.host=${REDIS_HOST:localhost}
spring.redis.port=${REDIS_PORT:6379}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Find build configuration files to determine Spring Boot version
find . -maxdepth 2 -type f \( -name "pom.xml" -o -name "build.gradle" -o -name "build.gradle.kts" \) | head -5

Repository: PSMRI/Scheduler-API

Length of output: 72


🏁 Script executed:

# Check application properties files to understand configuration patterns
fd "application.*\.properties$" | head -20

Repository: PSMRI/Scheduler-API

Length of output: 154


🏁 Script executed:

# Look for Redis or session configuration in the codebase
rg "spring\.redis|spring\.data\.redis|redis.*host|redis.*port" -t properties --max-count 20

Repository: PSMRI/Scheduler-API

Length of output: 97


🏁 Script executed:

# Read pom.xml to determine Spring Boot version
head -100 pom.xml | grep -i "spring.boot\|spring-boot"

Repository: PSMRI/Scheduler-API

Length of output: 431


🏁 Script executed:

# Read the swagger properties file
cat -n src/main/resources/application-swagger.properties

Repository: PSMRI/Scheduler-API

Length of output: 887


🏁 Script executed:

# Read the main properties file
cat -n src/main/resources/application.properties

Repository: PSMRI/Scheduler-API

Length of output: 1504


🏁 Script executed:

# Search for Redis configuration patterns in properties files
rg "spring\.(redis|data\.redis|session|autoconfigure)" src/main/resources/

Repository: PSMRI/Scheduler-API

Length of output: 445


🏁 Script executed:

# Get the Spring Boot version from pom.xml
rg "spring-boot-starter-parent" -A 2 pom.xml | head -10

Repository: PSMRI/Scheduler-API

Length of output: 201


🏁 Script executed:

# Search for version info in pom.xml
grep -i "version" pom.xml | head -10

Repository: PSMRI/Scheduler-API

Length of output: 448


🌐 Web query:

Spring Boot 3.x spring.redis vs spring.data.redis property names RedisAutoConfiguration

💡 Result:

In Spring Boot 3.x, the Redis properties used by RedisAutoConfiguration moved from the spring.redis.* prefix to spring.data.redis.* because Redis auto-configuration is now aligned with (and requires) Spring Data Redis on the classpath. This follows the prefix on RedisProperties, which is what RedisAutoConfiguration binds to. (docs.spring.io)

What changed

  • Spring Boot 2.x: RedisProperties is bound with @ConfigurationProperties(prefix="spring.redis") (docs.enterprise.spring.io)
  • Spring Boot 3.x: RedisProperties is bound with @ConfigurationProperties(prefix="spring.data.redis") (docs.enterprise.spring.io)

So, for Boot 3.x, you should use:

spring.data.redis.host=localhost
spring.data.redis.port=6379
spring.data.redis.password=...
spring.data.redis.database=0
spring.data.redis.timeout=60s

Example confirmation (Boot 3.x uses spring.data.redis.*): (baeldung.com)

Migration rule of thumb

Replace:

This applies to the whole Redis property set (including things like url, ssl, client-type, lettuce.*, jedis.*, cluster/sentinel, etc.), since they’re all under RedisProperties which RedisAutoConfiguration enables. (docs.spring.io)

Citations:


🏁 Script executed:

# Verify which properties are actually recognized in Spring Boot 3.2.2 by checking if spring.redis.* properties are deprecated
rg "RedisProperties" pom.xml

Repository: PSMRI/Scheduler-API

Length of output: 45


🏁 Script executed:

# Check if there are any other configuration files or test configs that show proper usage
fd "application.*\.properties$|application.*\.yml$" src/test/ 2>/dev/null | head -10

Repository: PSMRI/Scheduler-API

Length of output: 45


🌐 Web query:

Spring Boot 3.2 spring.redis properties deprecated or removed compatibility

💡 Result:

In Spring Boot 3.2, the spring.redis.* property namespace is no longer used for Redis auto-configuration. Redis configuration properties are now bound under spring.data.redis.* (this change happened in Spring Boot 3.0+, so it applies to 3.2 as well). In the Spring Boot 3.2 API, RedisProperties is explicitly annotated with @ConfigurationProperties(prefix="spring.data.redis"). [1] (In older Spring Boot versions, it used spring.redis.) [2]

What to do (migration / compatibility)

  • Rename your properties from spring.redis.*spring.data.redis.* (same property names after the prefix in most cases). This is the recommended migration step noted in Boot 3.0 migration guidance/notes. [3]
    • Example:
      • spring.redis.hostspring.data.redis.host
      • spring.redis.portspring.data.redis.port
      • spring.redis.passwordspring.data.redis.password
      • spring.redis.sslspring.data.redis.ssl.enabled (see current docs for SSL structure) [4]

Related (often confused) namespace

  • Redis cache settings are separate and use spring.cache.redis.* (e.g., TTL), not spring.data.redis.*. [5]

Sources:
[1] Spring Boot 3.2 RedisProperties API (prefix = spring.data.redis) (docs.enterprise.spring.io)
[2] Spring Boot 2.x RedisProperties API (prefix = spring.redis) (docs.spring.io)
[3] Boot migrator / release-note excerpt describing spring.redisspring.data.redis move (lightrun.com)
[4] Spring Boot 3.2 reference docs showing spring.data.redis.* usage (docs.enterprise.spring.io)
[5] Spring Boot 3.2 reference docs showing spring.cache.redis.* properties (docs.spring.io)

Citations:


Update property prefix from spring.redis.* to spring.data.redis.* and explicitly disable Redis session store for the swagger profile.

The current configuration has two issues:

  1. Wrong property prefix for Spring Boot 3.2: The code uses spring.redis.*, but Spring Boot 3.2 requires spring.data.redis.*. The spring.redis.* namespace is no longer recognized by RedisAutoConfiguration in Boot 3.x.

  2. Redis session store is not disabled: The swagger profile doesn't override spring.session.store-type, so it inherits the production setting (spring.session.store-type=redis from application.properties). This means the app will fail to start in CI if no Redis instance is available.

Fix:

Suggested changes
 # Disable Redis if not needed for docs (optional)
-spring.redis.host=${REDIS_HOST:localhost}
-spring.redis.port=${REDIS_PORT:6379}
+spring.data.redis.host=${REDIS_HOST:localhost}
+spring.data.redis.port=${REDIS_PORT:6379}
+spring.session.store-type=none
+spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration,org.springframework.boot.autoconfigure.session.SessionAutoConfiguration
🤖 Prompt for AI Agents
In `@src/main/resources/application-swagger.properties` around lines 6 - 8, Update
the swagger profile properties to use the Spring Boot 3.2 Redis property
namespace and explicitly disable the session store: replace occurrences of
spring.redis.host and spring.redis.port with spring.data.redis.host and
spring.data.redis.port, and add spring.session.store-type=none so the swagger
profile does not inherit a Redis session store; adjust any references in the
file that mention spring.redis.* to spring.data.redis.* and ensure
spring.session.store-type is set to "none" for the swagger profile.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 6, 2026

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.

1 participant