From 881c32ec109f0fff6f5661940ad035c3dfc0c7d9 Mon Sep 17 00:00:00 2001 From: Jorge Hernandez Date: Thu, 25 May 2017 16:44:15 -0500 Subject: [POLICY-16] generic introduction of swagger On a per-server basis append /swagger.json or /swagger.yaml ie: HTTP GET :6969/swagger.json HTTP GET :9696/swagger.json Resulting specification can be used by swagger clients. Change-Id: I4b1a8b53d50b1528664150934b04e92447e4d4d7 Signed-off-by: Jorge Hernandez --- .../policy/drools/healthcheck/RestHealthCheck.java | 39 +++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'policy-healthcheck/src/main/java/org') diff --git a/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/RestHealthCheck.java b/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/RestHealthCheck.java index e37e758a..06854042 100644 --- a/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/RestHealthCheck.java +++ b/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/RestHealthCheck.java @@ -4,23 +4,54 @@ import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.openecomp.policy.drools.healthcheck.HealthCheck.Reports; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.Info; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Tag; + @Path("/") +@Api +@Produces(MediaType.APPLICATION_JSON) +@SwaggerDefinition( + info = @Info( + description = "PDP-D Healthcheck Service", + version = "v1.0", + title = "PDP-D Healthcheck" + ), + consumes = {MediaType.APPLICATION_JSON}, + produces = {MediaType.APPLICATION_JSON}, + schemes = {SwaggerDefinition.Scheme.HTTP}, + tags = { + @Tag(name = "pdp-d-healthcheck", description = "Drools PDP Healthcheck Operations") + } +) public class RestHealthCheck { @GET - @Path("{a:healthcheck|test}") + @Path("healthcheck") @Produces(MediaType.APPLICATION_JSON) - public Reports healthcheck() { - Reports reports = HealthCheck.monitor.healthCheck(); - return reports; + @ApiOperation( + value="Perform a system healthcheck", + notes="Provides healthy status of the PDP-D plus the components defined in its configuration by using a REST interface", + response=Reports.class + ) + public Response healthcheck() { + return Response.status(Response.Status.OK).entity(HealthCheck.monitor.healthCheck()).build(); } @GET @Path("healthcheck/configuration") @Produces(MediaType.APPLICATION_JSON) + @ApiOperation( + value="Configuration", + notes="Provides the Healthcheck server configuration and monitored REST clients", + response=HealthCheck.class + ) public HealthCheck configuration() { return HealthCheck.monitor; } -- cgit 1.2.3-korg