-
Notifications
You must be signed in to change notification settings - Fork 26
chore(swagger): automate swagger sync to amrit-docs #63
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
Conversation
Added a badge for DeepWiki to the README.
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds a GitHub Actions workflow that builds the scheduler API using a swagger profile, extracts and validates Swagger JSON, and opens a PR to sync Changes
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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: 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
maintriggers 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 packagethenmvn spring-boot:runrecompiles the project.
spring-boot:runforks 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.txtThis also improves PID tracking —
$!will capture the actual Java process PID rather than anohup mvnshell wrapper, making the kill in the cleanup step more reliable.
14-17:fetch-depth: 0is 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:jqis pre-installed on GitHub-hostedubuntu-latestrunners.Remove this step to save CI time.
Remove unnecessary step
- - name: Install jq - run: sudo apt-get update && sudo apt-get install -y jq
| # Disable Redis if not needed for docs (optional) | ||
| spring.redis.host=${REDIS_HOST:localhost} | ||
| spring.redis.port=${REDIS_PORT:6379} |
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.
🧩 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 -5Repository: PSMRI/Scheduler-API
Length of output: 72
🏁 Script executed:
# Check application properties files to understand configuration patterns
fd "application.*\.properties$" | head -20Repository: 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 20Repository: 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.propertiesRepository: PSMRI/Scheduler-API
Length of output: 887
🏁 Script executed:
# Read the main properties file
cat -n src/main/resources/application.propertiesRepository: 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 -10Repository: PSMRI/Scheduler-API
Length of output: 201
🏁 Script executed:
# Search for version info in pom.xml
grep -i "version" pom.xml | head -10Repository: 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:
RedisPropertiesis bound with@ConfigurationProperties(prefix="spring.redis")(docs.enterprise.spring.io) - Spring Boot 3.x:
RedisPropertiesis 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=60sExample confirmation (Boot 3.x uses spring.data.redis.*): (baeldung.com)
Migration rule of thumb
Replace:
spring.redis.*→spring.data.redis.*(lightrun.com)
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:
- 1: https://docs.spring.io/spring-boot/docs/3.2.7/api/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.html?utm_source=openai
- 2: https://docs.enterprise.spring.io/spring-boot/docs/2.7.25/api/org/springframework/boot/autoconfigure/data/redis/RedisProperties.html?utm_source=openai
- 3: https://docs.enterprise.spring.io/spring-boot/docs/3.0.16/api/org/springframework/boot/autoconfigure/data/redis/RedisProperties.html?utm_source=openai
- 4: https://www.baeldung.com/spring-data-redis-properties?utm_source=openai
- 5: https://lightrun.com/answers/spring-projects-experimental-spring-boot-migrator-300-m5-redis-properties?utm_source=openai
- 6: https://docs.spring.io/spring-boot/docs/3.2.7/api/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.html?utm_source=openai
🏁 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.xmlRepository: 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 -10Repository: 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.host→spring.data.redis.hostspring.redis.port→spring.data.redis.portspring.redis.password→spring.data.redis.passwordspring.redis.ssl→spring.data.redis.ssl.enabled(see current docs for SSL structure) [4]
- Example:
Related (often confused) namespace
- Redis cache settings are separate and use
spring.cache.redis.*(e.g., TTL), notspring.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.redis → spring.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:
- 1: https://docs.enterprise.spring.io/spring-boot/docs/3.2.15.1/api/org/springframework/boot/autoconfigure/data/redis/RedisProperties.html?utm_source=openai
- 2: https://docs.spring.io/spring-boot/docs/2.4.5/api/org/springframework/boot/autoconfigure/data/redis/RedisProperties.html?utm_source=openai
- 3: https://lightrun.com/answers/spring-projects-experimental-spring-boot-migrator-300-m5-redis-properties?utm_source=openai
- 4: https://docs.enterprise.spring.io/spring-boot/docs/3.2.14/reference/html/data.html?utm_source=openai
- 5: https://docs.spring.io/spring-boot/docs/3.2.0-SNAPSHOT/reference/htmlsingle/index.html?utm_source=openai
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:
-
Wrong property prefix for Spring Boot 3.2: The code uses
spring.redis.*, but Spring Boot 3.2 requiresspring.data.redis.*. Thespring.redis.*namespace is no longer recognized byRedisAutoConfigurationin Boot 3.x. -
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=redisfrom 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.
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
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: 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 —packagethenspring-boot:runrebuilds.Line 27 runs
mvn clean package, then line 34 runsmvn spring-boot:runwhich 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.txtThis also simplifies process cleanup since
java -jardoesn't fork a child process —killon 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 unnecessaryjqinstallation step —jqis pre-installed on GitHub-hostedubuntu-latestrunners.Proposed fix
- - name: Install jq - run: sudo apt-get update && sudo apt-get install -y jq
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
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: 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. Thekill -- -"$PID"in the stop step targets the process group, which may be the shell's group instead. Consider usingsetsidto 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: 0is 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
|



Summary by CodeRabbit
New Features
Chores
Configuration
Documentation