Skip to content
Merged
100 changes: 100 additions & 0 deletions .github/workflows/swagger-json.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Sync Swagger to AMRIT-Docs

on:
push:
branches: [ main ]
workflow_dispatch:

jobs:
swagger-sync:
runs-on: ubuntu-latest
timeout-minutes: 20

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

- name: Set up Java 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: maven

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

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

- 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 &
echo $! > api_pid.txt

- name: Wait for API & fetch Swagger
run: |
for i in {1..40}; do
CODE=$(curl --connect-timeout 2 --max-time 5 -s -o swagger_raw.json -w "%{http_code}" http://localhost:9090/v3/api-docs || true)

if [ "$CODE" = "200" ]; then
jq . swagger_raw.json > scheduler-api.json || {
echo "Swagger JSON invalid"
cat swagger_raw.json
exit 1
}

if [ "$(jq '.paths | length' scheduler-api.json)" -eq 0 ]; then
echo "Swagger paths empty – failing"
exit 1
fi

echo "Swagger generated successfully"
exit 0
fi

echo "Waiting for API... ($i)"
sleep 4
done

echo "Swagger not generated"
cat app.log || true
exit 1

- name: Stop API
if: always()
run: |
if [ -f api_pid.txt ]; then
kill -9 $(cat api_pid.txt) || true
fi

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

- name: Copy Swagger JSON
run: |
mkdir -p amrit-docs/docs/swagger
cp scheduler-api.json amrit-docs/docs/swagger/scheduler-api.json

- 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.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AMRIT - Scheduler Service
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![DeepWiki](https://img.shields.io/badge/DeepWiki-PSMRI%2FScheduler--API-blue)](https://deepwiki.com/PSMRI/Scheduler-API)

It acts as an interface between client and the scheduling services provided, allowing users to interact for consultation with specialists. It also provides the info of availability and unavailability of specialists, retrieving available slots for specialists, booking and cancelling slots, and fetching day views of specialists for a particular specialization.

Expand Down
6 changes: 5 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@
<version>0.12.6</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<!-- end newly added dependencies -->
</dependencies>

Expand Down
18 changes: 18 additions & 0 deletions src/main/resources/application-swagger.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
spring.datasource.url=jdbc:h2:mem:swaggerdb
spring.datasource.driver-class-name=org.h2.Driver
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=create-drop

# Disable Redis if not needed for docs (optional)
spring.redis.host=${REDIS_HOST:localhost}
spring.redis.port=${REDIS_PORT:6379}
Copy link
Copy Markdown

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.


# CORS for Swagger UI
cors.allowed-origins=${CORS_ALLOWED_ORIGINS:http://localhost:9090,http://localhost:8080}
# Logging
logging.level.root=INFO

# Use environment variable for JWT secret
jwt.secret=${JWT_SECRET_KEY:defualt-key}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
common-api-url-searchBeneficiary=http://localhost:8080/beneficiary/search
common-api-url-searchuserbyid=http://localhost:8080/user/searchbyid
Loading