Skip to content

Commit 2ba9e4a

Browse files
authored
Merge pull request #119 from DurgaPrasad-54/main
chore(swagger): add env-driven Dev/UAT/Demo servers and update proper…
2 parents c1a95b3 + e7b22b1 commit 2ba9e4a

3 files changed

Lines changed: 24 additions & 9 deletions

File tree

.github/workflows/swagger-json.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,12 @@ jobs:
9797
with:
9898
token: ${{ secrets.DOCS_REPO_TOKEN }}
9999
path: amrit-docs
100-
branch: auto/swagger-update-${{ github.run_id }}-${{ github.run_attempt }}
100+
branch: auto/swagger-update-ecd-api
101101
base: main
102102
commit-message: "chore(docs): auto-update ECD-API swagger"
103103
title: "chore(docs): auto-update ECD-API swagger"
104104
delete-branch: true
105105
body: |
106106
This PR automatically updates ECD-API Swagger JSON
107107
from the latest main branch build.
108+

src/main/java/com/iemr/ecd/config/SwaggerConfig.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.springframework.context.annotation.Bean;
44
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.core.env.Environment;
56

67
import io.swagger.v3.oas.models.Components;
78
import io.swagger.v3.oas.models.OpenAPI;
@@ -11,14 +12,23 @@
1112

1213
@Configuration
1314
public class SwaggerConfig {
14-
15-
@Bean
16-
public OpenAPI customOpenAPI() {
17-
return new OpenAPI().info(new
18-
Info().title("ECD API").version("version").description("A microservice for the creation and management of beneficiaries."))
19-
.addSecurityItem(new SecurityRequirement().addList("my security"))
20-
.components(new Components().addSecuritySchemes("my security",
21-
new SecurityScheme().name("my security").type(SecurityScheme.Type.HTTP).scheme("bearer")));
15+
private static final String DEFAULT_SERVER_URL = "http://localhost:9090";
16+
17+
@Bean
18+
public OpenAPI customOpenAPI(Environment env) {
19+
String devUrl = env.getProperty("api.dev.url", DEFAULT_SERVER_URL);
20+
String uatUrl = env.getProperty("api.uat.url", DEFAULT_SERVER_URL);
21+
String demoUrl = env.getProperty("api.demo.url", DEFAULT_SERVER_URL);
22+
return new OpenAPI()
23+
.info(new Info().title("ECD API").version("version").description("A microservice for the creation and management of beneficiaries."))
24+
.addSecurityItem(new SecurityRequirement().addList("my security"))
25+
.components(new Components().addSecuritySchemes("my security",
26+
new SecurityScheme().name("my security").type(SecurityScheme.Type.HTTP).scheme("bearer")))
27+
.servers(java.util.Arrays.asList(
28+
new io.swagger.v3.oas.models.servers.Server().url(devUrl).description("Dev"),
29+
new io.swagger.v3.oas.models.servers.Server().url(uatUrl).description("UAT"),
30+
new io.swagger.v3.oas.models.servers.Server().url(demoUrl).description("Demo")
31+
));
2232
}
2333

2434
}

src/main/resources/application-swagger.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Swagger server URLs
2+
api.dev.url=${API_DEV_URL:https://amritwprdev.piramalswasthya.org}
3+
api.uat.url=${API_UAT_URL:https://uatamrit.piramalswasthya.org}
4+
api.demo.url=${API_DEMO_URL:https://amritdemo.piramalswasthya.org}
15
# Minimal properties for running ECD-API in swagger profile
26
# Use H2 in-memory DB and disable security for OpenAPI doc generation
37

0 commit comments

Comments
 (0)