Skip to content

Conversation

@DurgaPrasad-54
Copy link
Contributor

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

Summary by CodeRabbit

  • New Features

    • Automated workflow to generate, validate, and sync Swagger API documentation to the docs site, with push and manual triggers and automatic pull request creation
    • Workflow builds and runs the API, polls the docs endpoint for validation, and uploads validated Swagger JSON
  • Chores

    • Added a runtime database dependency to support local API docs generation
  • Configuration

    • Added app config for an in-memory DB, CORS, logging, JWT env sourcing, and public endpoints to support docs generation
  • Documentation

    • Added DeepWiki badge to the README

@coderabbitai
Copy link

coderabbitai bot commented Feb 6, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds a GitHub Actions workflow that builds the scheduler API using a swagger profile, extracts and validates Swagger JSON, and opens a PR to sync scheduler-api.json into AMRIT-Docs. Also adds H2 runtime dependency, swagger profile properties, and a README badge.

Changes

Cohort / File(s) Summary
Swagger Documentation Automation
.github/workflows/swagger-json.yml
New workflow "Sync Swagger to AMRIT-Docs": checks out the API, sets up Java 17, builds (skip tests), runs API with swagger profile on port 9090, polls and validates /v3/api-docs//swagger-json, stops the API, checks out AMRIT-Docs, copies scheduler-api.json into docs/swagger/, and creates an automated PR via peter-evans/create-pull-request.
Application Configuration
src/main/resources/application-swagger.properties
Adds swagger profile properties: in-memory H2 datasource and JPA create-drop, H2 dialect, CORS origins, root logging, JWT secret fallback, and allowed public API endpoints for Swagger.
Build Dependencies
pom.xml
Adds runtime dependency com.h2database:h2 to support the in-memory DB used by the swagger profile.
Documentation
README.md
Inserts a DeepWiki badge line adjacent to the license badge; documentation-only change.

Sequence Diagram

sequenceDiagram
    participant GH as GitHub (Trigger)
    participant Runner as Actions Runner
    participant Repo as API Repo
    participant Build as Maven/Java
    participant API as Scheduler API (swagger profile)
    participant Endpoint as /v3/api-docs or /swagger-json
    participant Validator as jq/HTTP checks
    participant Docs as AMRIT-Docs Repo
    participant GitHubAPI as GitHub API (PR)

    GH->>Runner: push to main / workflow_dispatch
    Runner->>Repo: checkout API repo
    Runner->>Build: set up Java 17 & build (skip tests)
    Build-->>Runner: artifact
    Runner->>API: start API on port 9090 (swagger profile)
    loop poll until healthy and valid
        Runner->>Endpoint: GET swagger JSON
        Endpoint-->>Runner: JSON
        Runner->>Validator: validate JSON & non-empty paths
        Validator-->>Runner: validation result
    end
    Runner->>API: stop API
    Runner->>Docs: checkout amrit-docs (token) & copy scheduler-api.json -> docs/swagger/
    Runner->>GitHubAPI: create pull request (auto/swagger-update-...)
    GitHubAPI-->>GH: 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 title clearly and concisely describes the main change: automating Swagger documentation synchronization to the amrit-docs repository via a new GitHub Actions workflow.
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 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.

@DurgaPrasad-54
Copy link
Contributor Author

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

✅ Actions performed

Full review triggered.

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: 1

🤖 Fix all issues with AI agents
In @.github/workflows/swagger-json.yml:
- Around line 69-74: The current Stop API step uses the line "kill -9 $(cat
api_pid.txt)" which only kills the Maven process and leaves the forked Java
child running; replace that single-kill with a process-group shutdown and
fallback: read the PID from api_pid.txt, send a graceful signal to the process
group with "kill -TERM -- -$(cat api_pid.txt) || true", wait briefly, then force
with "kill -KILL -- -$(cat api_pid.txt) || true"; as a safety alternative also
detect and kill direct Java children (e.g., use "pkill -P $(cat api_pid.txt) ||
true" or find the process listening on port 9090 with "fuser -k 9090/tcp ||
true") so the step that currently contains the "if [ -f api_pid.txt ]; then kill
-9 $(cat api_pid.txt) || true; fi" logic ensures both the Maven process group
and any forked Java processes are terminated.
🧹 Nitpick comments (3)
.github/workflows/swagger-json.yml (3)

26-37: Double Maven build is wasteful — package then spring-boot:run rebuilds.

Line 27 runs mvn clean package, then line 34 runs mvn spring-boot:run which compiles again. Consider running the packaged WAR directly instead:

Proposed optimization
       - 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 &
+          nohup java -jar target/scheduler-api-*.war \
+            --spring.profiles.active=swagger \
+            --server.port=9090 \
+            > app.log 2>&1 &
           echo $! > api_pid.txt

This also simplifies process cleanup since java -jar doesn't fork a child process — kill on the PID will work directly.


14-17: fetch-depth: 0 (full history clone) is unnecessary for Swagger generation.

The workflow only needs the current commit to build the project. A shallow clone (default fetch-depth: 1) would be faster.

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

29-30: Remove unnecessary jq installation step — jq is pre-installed on GitHub-hosted ubuntu-latest runners.

Proposed fix
-      - name: Install jq
-        run: sudo apt-get update && sudo apt-get install -y jq

@DurgaPrasad-54
Copy link
Contributor Author

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

✅ Actions performed

Full review triggered.

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: 1

🤖 Fix all issues with AI agents
In @.github/workflows/swagger-json.yml:
- Around line 67-81: The "Stop API" shell block has an extra closing fi causing
a syntax error; in the step that checks for api_pid.txt (the if [ -f api_pid.txt
]; then ... fi block in the "Stop API" step) remove the stray extra fi so the
fallback command fuser -k 9090/tcp executes; ensure there is exactly one
matching fi for the if that wraps the PID-based kill logic and that the fuser
fallback is placed outside that if-block.
🧹 Nitpick comments (3)
.github/workflows/swagger-json.yml (3)

30-36: Process-group kill (kill -- -PID) may not work unless the process is a group leader.

nohup java ... & does not guarantee the background process becomes a process group leader. The kill -- -"$PID" in the stop step targets the process group, which may be the shell's group instead. Consider using setsid to ensure a new process group:

♻️ Suggested change
       - name: Run API in swagger profile
         run: |
-          nohup java -jar target/scheduler-api-*.war \
+          setsid java -jar target/scheduler-api-*.war \
             --spring.profiles.active=swagger \
             --server.port=9090 \
             > app.log 2>&1 &
           echo $! > api_pid.txt

3-6: Consider restricting the trigger to avoid unnecessary runs.

This workflow runs on every push to main, including documentation-only or CI config changes. You could add a path filter to only trigger when source code or swagger config actually changes.

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

83-89: fetch-depth: 0 is unnecessary for the docs repo checkout.

A full clone of the AMRIT-Docs history is not needed since you're only copying a file and creating a PR. The default shallow clone (fetch-depth: 1) is sufficient and faster.

♻️ Suggested change
       - name: Checkout AMRIT-Docs
         uses: actions/checkout@v4
         with:
           repository: PSMRI/AMRIT-Docs
           token: ${{ secrets.DOCS_REPO_TOKEN }}
           path: amrit-docs
-          fetch-depth: 0

@sonarqubecloud
Copy link

@drtechie drtechie merged commit 81ad345 into PSMRI:main Feb 11, 2026
2 of 3 checks passed
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