partial global swagger implmentation

This commit is contained in:
Michele Artini 2023-11-20 16:16:50 +01:00
parent c4827a0af9
commit 3f6ce2a7e2
21 changed files with 129 additions and 78 deletions

View File

@ -8,16 +8,19 @@ server {
server_name _;
location /ajax/ {
proxy_pass http://is-manager:$SPRING_BOOT_PORT/ajax/;
}
location /ajax-is/ {
proxy_pass http://is-manager:$SPRING_BOOT_PORT/ajax-is/;
}
location /swagger/ {
proxy_pass http://is-manager:$SPRING_BOOT_PORT/swagger/;
}
location / {
proxy_pass http://angular-dev:4200/;
}
location /ajax/ {
proxy_pass http://is-manager:$SPRING_BOOT_PORT/is/ajax/;
}
location /is/ {
proxy_pass http://is-manager:$SPRING_BOOT_PORT/is/api/;
}
}

View File

@ -1,6 +1,5 @@
server.title = D-NET Context Manager
server.description = D-NET Context Manager
server.servlet.context-path = /context-manager
server.title = D-NET Context Manager
server.description = D-NET Context Manager
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-context-manager/effective-pom.xml

View File

@ -1,6 +1,5 @@
server.title = D-NET Datasource Manager
server.description = D-NET Datasource Manager
server.servlet.context-path = /dsm
server.public_url =
server.title = D-NET Datasource Manager
server.description = D-NET Datasource Manager
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-datasource-manager/effective-pom.xml

View File

@ -1,7 +1,6 @@
server.title = D-NET Mail Sender API
server.description = Simple service that sends mails
server.servlet.context-path = /mail-sender
server.public_url =
server.title = D-NET Mail Sender API
server.description = Simple service that sends mails
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-email-sender/effective-pom.xml

View File

@ -1,7 +1,6 @@
server.title = D-NET Metadata Indexer (SOLR)
server.description = D-NET Metadata Indexer (SOLR)
server.servlet.context-path = /indexer
server.public_url =
server.title = D-NET Metadata Indexer (SOLR)
server.description = D-NET Metadata Indexer (SOLR)
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-index-manager/effective-pom.xml

View File

@ -22,7 +22,7 @@ import eu.dnetlib.errors.DnetRuntimeException;
import eu.dnetlib.is.service.ServiceRegistry;
@RestController
@RequestMapping(value = "/api")
@RequestMapping(value = { "/ajax-is", "/api" })
public class ApiController extends DnetRestController {
private static final int SHORT_TIMEOUT = 5000; // 5 seconds

View File

@ -0,0 +1,50 @@
package eu.dnetlib.is.controller;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestTemplate;
import eu.dnetlib.is.service.ServiceRegistry;
@Controller
@RequestMapping("/swagger")
public class SwaggerProxyController {
@Autowired
private ServiceRegistry registry;
private static final Log log = LogFactory.getLog(SwaggerProxyController.class);
@RequestMapping("/{service}/{file}")
public ResponseEntity<?> swaggerServiceHome(@PathVariable final String service, @PathVariable final String file) {
try {
final String baseUrl = registry.findBaseUrl(service);
if (StringUtils.isBlank(baseUrl)) { return ResponseEntity.status(HttpStatus.NOT_FOUND).body("The required service is not registered: " + service); }
final RestTemplate restTemplate = new RestTemplate();
final String body = restTemplate.getForObject(baseUrl + "/swagger-ui/" + URLEncoder.encode(file, StandardCharsets.UTF_8), String.class);
return ResponseEntity.status(HttpStatus.OK).body(body);
} catch (final HttpStatusCodeException e) {
return ResponseEntity.status(e.getStatusCode())
.headers(e.getResponseHeaders())
.body(e.getResponseBodyAsString());
}
}
}

View File

@ -1,7 +1,6 @@
server.title = D-NET Information Service
server.description = D-NET Information Service
server.servlet.context-path = /is
server.public_url =
server.title = D-NET Information Service
server.description = D-NET Information Service
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-is-manager/effective-pom.xml

View File

@ -1,7 +1,6 @@
server.title = D-NET MDSM
server.description = D-NET Metadata Store Manager
server.servlet.context-path = /mdsm
server.public_url =
server.title = D-NET MDSM
server.description = D-NET Metadata Store Manager
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-mdstore-manager/effective-pom.xml

View File

@ -1,7 +1,6 @@
server.title = D-NET OAI Exporter
server.description = D-NET Service for metadata export using OAI-PMH
server.servlet.context-path = /oai-manager
server.public_url =
server.title = D-NET OAI Exporter
server.description = D-NET Service for metadata export using OAI-PMH
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-oai-manager/effective-pom.xml

View File

@ -1,7 +1,6 @@
server.title = D-NET Resource Manager
server.description = D-NET Resource Manager
server.servlet.context-path = /resource-manager
server.public_url =
server.title = D-NET Resource Manager
server.description = D-NET Resource Manager
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-resource-manager/effective-pom.xml

View File

@ -1,6 +1,5 @@
server.title = D-NET Vocabulary Manager
server.description = D-NET Vocabulary Manager
server.servlet.context-path = /vocabulary-manager
server.title = D-NET Vocabulary Manager
server.description = D-NET Vocabulary Manager
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-vocabulary-manager/effective-pom.xml

View File

@ -1,7 +1,6 @@
server.title = D-NET Wf executor that uses postgres as backend
server.description = D-NET Wf executor that uses postgres as backend
server.servlet.context-path = /wf-exec
server.public_url =
server.title = D-NET Wf executor that uses postgres as backend
server.description = D-NET Wf executor that uses postgres as backend
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-wf-aggregation-postgres/effective-pom.xml

View File

@ -1,7 +1,6 @@
server.title = D-NET Workflow Manager
server.description = D-NET Workflow Manager
server.servlet.context-path = /wf-manager
server.public_url =
server.title = D-NET Workflow Manager
server.description = D-NET Workflow Manager
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-wf-manager/effective-pom.xml

View File

@ -8,15 +8,15 @@ import { Service } from '../common/is.model';
export class InfoClient extends ISClient {
availableServices(onSuccess: Function): void {
this.httpGet<Service[]>("/is/services", onSuccess);
this.httpGet<Service[]>("/ajax-is/services", onSuccess);
}
infoService(service: string, onSuccess: Function): void {
this.httpGet<any>("/is/info/" + encodeURIComponent(service), onSuccess);
this.httpGet<any>("/ajax-is/info/" + encodeURIComponent(service), onSuccess);
}
pingService(service: string, onSuccess: Function): void {
this.httpGet<number>("/is/ping/" + encodeURIComponent(service), onSuccess);
this.httpGet<number>("/ajax-is/ping/" + encodeURIComponent(service), onSuccess);
}
}

View File

@ -27,7 +27,9 @@
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef style="width: 30%;" mat-sort-header sortActionDescription="Sort by Name"> Name
</th>
<td mat-cell *matCellDef="let element"> <a (click)="showInfoDialog(element.name)">{{element.name}}</a></td>
<td mat-cell *matCellDef="let element"> <a href="/swagger/{{element.name}}/index.html"
target="_blank">{{element.name}}</a>
</td>
</ng-container>
<ng-container matColumnDef="type">
@ -37,11 +39,17 @@
</ng-container>
<ng-container matColumnDef="baseUrl">
<th mat-header-cell *matHeaderCellDef style="width: 30%;" mat-sort-header sortActionDescription="Sort by BaseUrl">
<th mat-header-cell *matHeaderCellDef style="width: 15%;" mat-sort-header sortActionDescription="Sort by BaseUrl">
BaseUrl </th>
<td mat-cell *matCellDef="let element"> {{element.baseUrl}} </td>
</ng-container>
<ng-container matColumnDef="info">
<th mat-header-cell *matHeaderCellDef align="center" style="width: 10%;"> Info </th>
<td mat-cell *matCellDef="let element" align="center"> <a (click)="showInfoDialog(element.name)"><mat-icon
fontIcon="info_outline"></mat-icon></a> </td>
</ng-container>
<ng-container matColumnDef="date">
<th mat-header-cell *matHeaderCellDef mat-sort-header sortActionDescription="Sort by Date"> Date </th>
<td mat-cell *matCellDef="let element"> {{element.date}} </td>

View File

@ -20,7 +20,7 @@ export class InfoComponent {
servicesDatasource: MatTableDataSource<Service> = new MatTableDataSource<Service>([]);
colums: string[] = ['ping', 'name', 'type', 'baseUrl', 'date'];
colums: string[] = ['ping', 'name', 'type', 'baseUrl', 'info', 'date'];
@ViewChild(MatSort) sort: MatSort | undefined

View File

@ -1,10 +1,14 @@
{
"/ajax": {
"target": "http://localhost:8888",
"target": "http://localhost:8888/ajax",
"secure": false
},
"/api": {
"target": "http://localhost:8888",
"/ajax-is": {
"target": "http://localhost:8888/ajax-is",
"secure": false
},
"/swagger": {
"target": "http://localhost:8888/swagger",
"secure": false
}
}

View File

@ -49,9 +49,6 @@ public abstract class AbstractDnetApp {
@Value("${server.port:8080}")
private int serverPort;
@Value("${server.servlet.context-path}")
private String serverContextPath;
@Value("${server.title}")
private String serverTitle;
@ -91,7 +88,7 @@ public abstract class AbstractDnetApp {
try {
final ServiceStatus status =
client.registerService(serviceType(), "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + serverPort + serverContextPath);
client.registerService(serviceType(), "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + serverPort);
log.info("Service registered with name: " + status.getName());

View File

@ -8,7 +8,7 @@ services:
- backend
- frontend
environment:
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}
profiles:
- base
@ -22,7 +22,7 @@ services:
- is-manager
- db-main
environment:
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_CONTEXTS_DB}
- SPRING_DATASOURCE_USERNAME=${PG_USER}
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
@ -39,7 +39,7 @@ services:
- is-manager
- db-main
environment:
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_VOCS_DB}
- SPRING_DATASOURCE_USERNAME=${PG_USER}
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
@ -56,7 +56,7 @@ services:
- db-main
- is-manager
environment:
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_DSM_DB}
- SPRING_DATASOURCE_USERNAME=${PG_USER}
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
@ -73,7 +73,7 @@ services:
- db-main
- is-manager
environment:
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_INDEX_DB}
- SPRING_DATASOURCE_USERNAME=${PG_USER}
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
@ -93,7 +93,7 @@ services:
- db-mdstores-data
- is-manager
environment:
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_MAIN_DB}
- SPRING_DATASOURCE_USERNAME=${PG_USER}
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
@ -113,7 +113,7 @@ services:
- db-oai
- is-manager
environment:
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-oai:${PG_PORT}/${PG_OAI_DB}
- SPRING_DATASOURCE_USERNAME=${PG_USER}
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
@ -130,7 +130,7 @@ services:
- db-main
- is-manager
environment:
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_MAIN_DB}
- SPRING_DATASOURCE_USERNAME=${PG_USER}
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
@ -148,7 +148,7 @@ services:
- db-mdstores-data
- is-manager
environment:
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_WFS_DB}
- SPRING_DATASOURCE_USERNAME=${PG_USER}
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
@ -173,7 +173,7 @@ services:
- db-main
- is-manager
environment:
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_WFS_DB}
- SPRING_DATASOURCE_USERNAME=${PG_USER}
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
@ -189,7 +189,7 @@ services:
depends_on:
- is-manager
environment:
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}
profiles:
- mail

View File

@ -19,8 +19,8 @@ export PG_MDSTORES_DATA_DB=dnet_mdstores_data
export PG_INDEX_DB=dnet_index_configs
export PG_OAI_DB=dnet_oai
#export COMPOSE_PROFILES=base
export COMPOSE_PROFILES=base,mail,dsm,vocs,mdstores,wfs,index,contexts,oai,ui
export COMPOSE_PROFILES=base ui
#export COMPOSE_PROFILES=base,mail,dsm,vocs,mdstores,wfs,index,contexts,oai,ui
docker-compose -f docker-compose.dev.yml up --force-recreate --build