Skip to content

Commit 5a94fa4

Browse files
Add server urls and update GitHub workflow (#114)
* docs: add DeepWiki badge and documentation link * chore(swagger): automate swagger sync to amrit-docs * chore(swagger): automate swagger sync to amrit-docs * chore(swagger): automate swagger sync to amrit-docs * chore(swagger): fix jwt token in application-swagger.properties * chore(swagger): update swagger workflow and properties * fix(redis): fix the redis issue and add swagger profile * fix(redis): fix the redis swagger profile issue * fix : fix the redis server issue * chore(swagger): add env-driven Dev/UAT/Demo servers and update workflow * chore(swagger): add new description for swagger doc * chore(swagger): add variable for bearerAuth in SwaggerConfig
1 parent 152acd0 commit 5a94fa4

3 files changed

Lines changed: 27 additions & 9 deletions

File tree

.github/workflows/swagger-json.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
with:
100100
token: ${{ secrets.DOCS_REPO_TOKEN }}
101101
path: amrit-docs
102-
branch: auto/swagger-update-${{ github.run_id }}-${{ github.run_attempt }}
102+
branch: auto/swagger-update-inventory-api
103103
base: main
104104
commit-message: "chore(docs): auto-update Inventory-API swagger"
105105
title: "chore(docs): auto-update Inventory-API swagger"

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

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,37 @@
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;
89
import io.swagger.v3.oas.models.info.Info;
10+
911
import io.swagger.v3.oas.models.security.SecurityRequirement;
1012
import io.swagger.v3.oas.models.security.SecurityScheme;
13+
import java.util.List;
14+
import io.swagger.v3.oas.models.servers.Server;
1115

1216
@Configuration
1317
public class SwaggerConfig {
14-
15-
@Bean
16-
public OpenAPI customOpenAPI() {
17-
return new OpenAPI().info(new
18-
Info().title("Inventory 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")));
18+
private static final String DEFAULT_SERVER_URL = "http://localhost:9090";
19+
private static final String BEARER_AUTH_SCHEME = "bearerAuth";
20+
21+
@Bean
22+
public OpenAPI customOpenAPI(Environment env) {
23+
String devUrl = env.getProperty("api.dev.url", DEFAULT_SERVER_URL);
24+
String uatUrl = env.getProperty("api.uat.url", DEFAULT_SERVER_URL);
25+
String demoUrl = env.getProperty("api.demo.url", DEFAULT_SERVER_URL);
26+
return new OpenAPI()
27+
.info(new Info().title("Inventory API").version("version").description("A microservice for inventory management of items, stock levels, and related operations."))
28+
.addSecurityItem(new SecurityRequirement().addList(BEARER_AUTH_SCHEME))
29+
.components(new Components().addSecuritySchemes(BEARER_AUTH_SCHEME,
30+
new SecurityScheme().name(BEARER_AUTH_SCHEME).type(SecurityScheme.Type.HTTP).scheme("bearer")))
31+
.servers(List.of(
32+
new Server().url(devUrl).description("Dev"),
33+
new Server().url(uatUrl).description("UAT"),
34+
new Server().url(demoUrl).description("Demo")
35+
));
2236
}
2337

2438
}

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)