-
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
Changes from 3 commits
d948cc0
6fb31b8
397123b
afcf543
a50d679
d24ab17
ce0a804
4a66a41
7d63d88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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. | ||
| 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} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
💡 Result: In Spring Boot 3.x, the Redis properties used by What changed
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 Migration rule of thumbReplace:
This applies to the whole Redis property set (including things like 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.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:
💡 Result: In Spring Boot 3.2, the What to do (migration / compatibility)
Related (often confused) namespace
Sources: Citations:
Update property prefix from The current configuration has two issues:
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 |
||
|
|
||
| # 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} | ||
|
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 | ||
Uh oh!
There was an error while loading. Please reload this page.