Skip to content

Commit

Permalink
feat: Addition of swagger UI doc for patient-management
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsukoyachi committed Oct 14, 2024
1 parent 65b208d commit 3a66f4f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cloud/backend/patient-management/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,22 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.bson.types.ObjectId;
import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition;
import org.eclipse.microprofile.openapi.annotations.info.Info;
import org.eclipse.microprofile.openapi.annotations.tags.Tag;

import java.util.List;

@OpenAPIDefinition(
info = @Info(
title = "Patient Management API",
version = "1.0.0",
description = "API to manage patients in a hospital."
),
tags = {
@Tag(name = "patient", description = "Operations related to patients")
}
)
@Path("/patient")
public class PatientResource {
private static final String patientIdErrorMessage = "Missing or invalid patient ID format. ID must be a 24-character hexadecimal string.";
Expand All @@ -36,7 +49,7 @@ public Response getPatientById(@PathParam("patientId") @Pattern(regexp = "^[0-9a
@Path("/gateway/{gatewayId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getPatientByGatewayId(@PathParam("gatewayId") @Pattern(regexp = "^[0-9a-fA-F]{24}$", message = gatewayIdErrorMessage) String gatewayId) throws ResourceNotFoundException, ConstraintViolationException {
return repository.find("gatewayId",new ObjectId(gatewayId)).firstResultOptional().map(patient -> Response.ok(patient).build()).orElseThrow(() -> new ResourceNotFoundException("Patient with gateway ID " + gatewayId + " not found."));
return repository.find("gatewayId", new ObjectId(gatewayId)).firstResultOptional().map(patient -> Response.ok(patient).build()).orElseThrow(() -> new ResourceNotFoundException("Patient with gateway ID " + gatewayId + " not found."));
}

@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ quarkus.oidc.auth-server-url=${AUTH_SERVER_URL:http://localhost:8081/realms/poul
quarkus.oidc.client-id=${CLIENT_ID:backend-service}
quarkus.oidc.credentials.secret=${CLIENT_SECRET:J1jZPePtgzG4Q9ltZTHlBGKEyj93P4hd}
quarkus.oidc.application-type=web-app
# Quarkus swagger UI
quarkus.swagger-ui.always-include=true
quarkus.swagger-ui.path=/swagger-ui
# Docker build properties
quarkus.container-image.registry=ghcr.io

0 comments on commit 3a66f4f

Please sign in to comment.