chore(swagger): automate swagger sync to amrit-docs#113
Conversation
|
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:
📝 WalkthroughWalkthroughAdds a GitHub Actions workflow to build and run the API and sync its Swagger JSON to AMRIT-Docs; introduces a swagger profile properties file and H2 runtime dependency; marks RedisConfig to be disabled for the Changes
Sequence Diagram(s)sequenceDiagram
participant GH as "GitHub Actions"
participant Repo as "API repo"
participant Maven as "Java 17 / Maven"
participant API as "Local API (swagger profile)"
participant Validator as "jq / HTTP"
participant Docs as "AMRIT-Docs repo"
participant GitHub as "GitHub (PR)"
GH->>Repo: checkout code (full history)
GH->>Maven: setup Java 17 & build (skip tests)
GH->>API: start app on :9090 (background)
API-->>GH: PID & logs
loop poll up to 40 times (4s interval)
GH->>API: GET /v3/api-docs
API-->>GH: 200 + JSON or non-200
end
GH->>Validator: validate JSON (ensure non-empty paths)
alt valid JSON
GH->>Docs: checkout amrit-docs via token
GH->>Docs: copy inventory-api.json -> docs/swagger/
GH->>GitHub: commit branch & create PR (auto-delete branch)
else invalid / timeout
GH->>GH: dump logs, fail job
end
GH->>API: stop process (graceful then force)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/main/resources/application-swagger.properties`:
- Around line 6-9: The swagger profile currently sets
spring.data.redis.host/port but does not disable Redis auto-configuration;
update the application-swagger properties to explicitly exclude Redis
auto-configuration by adding the spring.autoconfigure.exclude property
referencing
org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration (and
optionally
org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration)
so Spring Boot won't attempt to connect to Redis during the swagger profile.
🧹 Nitpick comments (2)
src/main/resources/application-swagger.properties (1)
15-16: Avoid committing a default JWT secret.The fallback secret can be reused accidentally in shared environments. Prefer requiring
JWT_SECRET_KEY(and set it in the workflow) or generate a per-run secret.🔐 Suggested update
-jwt.secret=${JWT_SECRET_KEY:default-swagger-secret-change-me} +jwt.secret=${JWT_SECRET_KEY}.github/workflows/swagger-json.yml (1)
69-74: Prefer graceful shutdown before SIGKILL.SIGKILL skips cleanup; a brief SIGTERM attempt is safer and still deterministic.
🛠️ Suggested change
- if [ -f api_pid.txt ]; then - kill -9 $(cat api_pid.txt) || true - fi + if [ -f api_pid.txt ]; then + PID=$(cat api_pid.txt) + kill "$PID" || true + sleep 5 + kill -9 "$PID" || true + fi
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/main/java/com/iemr/inventory/config/RedisConfig.java`:
- Around line 36-39: RoleMasterApplication.redisTemplate() is still being
created when the swagger profile is active, causing missing
LettuceConnectionFactory and injection failures for RedisTemplate in
JwtAuthenticationUtil and TokenDenylist; either annotate the redisTemplate()
method with `@Profile`("!swagger") or move its bean definition into RedisConfig so
the existing `@Profile`("!swagger") on RedisConfig covers it, ensuring the bean
depends on LettuceConnectionFactory and is excluded when swagger is active.
|



Add Swagger Json Automation file swagger-json.yml and application-swagger.properties
Summary by CodeRabbit
New Features
Chores