Skip to content

Commit 5b646dc

Browse files
Add new workflow and server urls (#129)
* docs(readme): add documentation badge * chore(swagger): automate swagger sync to amrit-docs * chore(swagger): automate swagger sync to amrit-docs * chore(swagger): update swagger work flow and properties * chore(swagger): update swagger workflow and add server urls * chore(swagger): fix the version issue in swaggerconfig.java
1 parent 732e6e7 commit 5b646dc

3 files changed

Lines changed: 26 additions & 9 deletions

File tree

.github/workflows/swagger-json.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ 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-tm-api
101101
base: main
102102
commit-message: "chore(docs): auto-update TM-API swagger"
103103
title: "chore(docs): auto-update TM-API swagger"

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

Lines changed: 21 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,26 @@
1112

1213
@Configuration
1314
public class SwaggerConfig {
14-
15-
@Bean
16-
public OpenAPI customOpenAPI() {
17-
return new OpenAPI().info(new
18-
Info().title("TeleMedicine(TM) 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()
24+
.title("TeleMedicine(TM) API")
25+
.version("1.0.0")
26+
.description("A microservice for TeleMedicine, providing APIs for remote healthcare consultations, patient management, and related telehealth operations."))
27+
.addSecurityItem(new SecurityRequirement().addList("my security"))
28+
.components(new Components().addSecuritySchemes("my security",
29+
new SecurityScheme().name("my security").type(SecurityScheme.Type.HTTP).scheme("bearer")))
30+
.servers(java.util.Arrays.asList(
31+
new io.swagger.v3.oas.models.servers.Server().url(devUrl).description("Dev"),
32+
new io.swagger.v3.oas.models.servers.Server().url(uatUrl).description("UAT"),
33+
new io.swagger.v3.oas.models.servers.Server().url(demoUrl).description("Demo")
34+
));
2235
}
2336

2437
}

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
spring.datasource.url=jdbc:h2:mem:swaggerdb
26
spring.datasource.driver-class-name=org.h2.Driver
37
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect

0 commit comments

Comments
 (0)