chore(swagger): add env-driven servers to OpenAPI config#119
chore(swagger): add env-driven servers to OpenAPI config#119DurgaPrasad-54 wants to merge 14 commits intoPSMRI:mainfrom
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughUpdates fix the GitHub Actions PR branch name, change SwaggerConfig to accept an Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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: 2
🤖 Fix all issues with AI agents
In `@src/main/java/com/iemr/admin/config/SwaggerConfig.java`:
- Line 23: The Info() metadata in SwaggerConfig (the .info(new
Info().title("Admin API")...) call) has an incorrect description about "creation
and management of beneficiaries"; update the description string to accurately
describe the Admin API's purpose (e.g., administration, configuration, user/role
management or service-level operations for this microservice). Locate the
SwaggerConfig class and replace the description passed to
Info().description(...) with a concise, correct summary of the Admin API
responsibilities.
- Around line 18-31: customOpenAPI currently reads API_DEV_URL/ UAT/ DEMO into
devUrl/uatUrl/demoUrl and may pass nulls into new Server().url(...); update
customOpenAPI to guard against nulls by either supplying sensible defaults (e.g.
fallback to empty string or configured base URL) or by building the servers list
conditionally (only add a Server when its corresponding env property is
non-empty), and replace the inline fully-qualified class references with proper
imports for Arrays and io.swagger.v3.oas.models.servers.Server to improve
readability; ensure the OpenAPI.servers list is created from the
filtered/non-null URLs before returning the OpenAPI instance.
🧹 Nitpick comments (2)
src/main/resources/application-swagger.properties (1)
19-23: Hardcoded server URLs contradict the stated goal of removing hardcoded live defaults.The PR description says it "removes hardcoded live defaults," but these properties embed real environment URLs directly. If the intent is truly env-driven configuration, use Spring property placeholders so these only serve as fallback defaults:
Proposed fix
-API_DEV_URL=https://amritwprdev.piramalswasthya.org -API_UAT_URL=https://uatamrit.piramalswasthya.org -API_DEMO_URL=https://amritdemo.piramalswasthya.org +api.dev.url=${API_DEV_URL:https://amritwprdev.piramalswasthya.org} +api.uat.url=${API_UAT_URL:https://uatamrit.piramalswasthya.org} +api.demo.url=${API_DEMO_URL:https://amritdemo.piramalswasthya.org}Using dot-notation keys with
${ENV_VAR:default}placeholders is more idiomatic for Spring and makes the env-override mechanism explicit. You'd then updateSwaggerConfigto readapi.dev.url, etc.src/main/java/com/iemr/admin/config/SwaggerConfig.java (1)
5-5: Unused import:@Autowiredis not used.
Environmentis injected via the@Beanmethod parameter, so@Autowiredis not needed.-import org.springframework.beans.factory.annotation.Autowired;
|



Adds Dev/UAT/Demo servers to OpenAPI config using env vars and avoids hardcoded live defaults.
Summary by CodeRabbit
Release Notes