From fa2577de76265512962b5699dcd81f44813759e1 Mon Sep 17 00:00:00 2001 From: mherman22 Date: Sat, 19 Oct 2024 22:38:52 +0300 Subject: [PATCH] RESTWS-958: Ensure the module's rest is updated to use swagger 3.0 --- .../web/resources/QueueEntryResource.java | 114 ++++++++++-------- .../web/resources/QueueEntrySubResource.java | 92 +++++++------- .../queue/web/resources/QueueResource.java | 65 +++++----- .../web/resources/QueueRoomResource.java | 37 +++--- .../resources/RoomProviderMapResource.java | 34 +++--- pom.xml | 2 +- 6 files changed, 174 insertions(+), 170 deletions(-) diff --git a/omod/src/main/java/org/openmrs/module/queue/web/resources/QueueEntryResource.java b/omod/src/main/java/org/openmrs/module/queue/web/resources/QueueEntryResource.java index e60873e..7bacde4 100644 --- a/omod/src/main/java/org/openmrs/module/queue/web/resources/QueueEntryResource.java +++ b/omod/src/main/java/org/openmrs/module/queue/web/resources/QueueEntryResource.java @@ -16,9 +16,13 @@ import java.util.Map; import java.util.Optional; -import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.properties.*; +import io.swagger.v3.oas.models.media.BooleanSchema; +import io.swagger.v3.oas.models.media.DateTimeSchema; +import io.swagger.v3.oas.models.media.NumberSchema; +import io.swagger.v3.oas.models.media.ObjectSchema; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.media.StringSchema; +import io.swagger.v3.oas.models.media.UUIDSchema; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.openmrs.PersonName; @@ -131,53 +135,67 @@ public DelegatingResourceDescription getCreatableProperties() throws ResourceDoe } @Override - public Model getGETModel(Representation rep) { - ModelImpl model = (ModelImpl) super.getGETModel(rep); + public Schema getGETSchema(Representation rep) { + Schema model = super.getGETSchema(rep); if (rep instanceof RefRepresentation || rep instanceof DefaultRepresentation) { - model.property("uuid", new StringProperty()).property("queue", new RefProperty("#/definitions/QueueGetRef")) - .property("display", new StringProperty()) - .property("status", new RefProperty("#/definitions/ConceptGetRef")) - .property("priority", new RefProperty("#/definitions/ConceptGetRef")) - .property("priorityComment", new StringProperty()) - .property("patient", new RefProperty("#/definitions/PatientGetRef")) - .property("visit", new RefProperty("#/definitions/VisitGetRef")) - .property("sortWeight", new DoubleProperty()).property("startedAt", new DateProperty()) - .property("endedAt", new DateProperty()) - .property("locationWaitingFor", new RefProperty("#/definitions/LocationGetRef")) - .property("queueComingFrom", new RefProperty("#/definitions/QueueGetRef")) - .property("providerWaitingFor", new RefProperty("#/definitions/ProviderGetRef")); + model.addProperty("uuid", new UUIDSchema()) + .addProperty("queue", new Schema<>().$ref("#/components/schemas/QueueGetRef")) + .addProperty("display", new StringSchema()) + .addProperty("status", new Schema<>().$ref("#/components/schemas/ConceptGetRef")) + .addProperty("priority", new Schema<>().$ref("#/components/schemas/ConceptGetRef")) + .addProperty("priorityComment", new StringSchema()) + .addProperty("patient", new Schema<>().$ref("#/components/schemas/PatientGetRef")) + .addProperty("visit", new Schema<>().$ref("#/components/schemas/VisitGetRef")) + .addProperty("sortWeight", new NumberSchema().format("double")) + .addProperty("startedAt", new DateTimeSchema()).addProperty("endedAt", new DateTimeSchema()) + .addProperty("locationWaitingFor", new Schema<>().$ref("#/components/schemas/LocationGetRef")) + .addProperty("queueComingFrom", new Schema<>().$ref("#/components/schemas/QueueGetRef")) + .addProperty("providerWaitingFor", new Schema<>().$ref("#/components/schemas/ProviderGetRef")); } else if (rep instanceof FullRepresentation) { - model.property("uuid", new StringProperty()).property("queue", new RefProperty("#/definitions/QueueGetRef")) - .property("display", new StringProperty()) - .property("status", new RefProperty("#/definitions/ConceptGetRef")) - .property("priority", new RefProperty("#/definitions/ConceptGetRef")) - .property("priorityComment", new StringProperty()) - .property("patient", new RefProperty("#/definitions/PatientGetRef")) - .property("visit", new RefProperty("#/definitions/VisitGetRef")) - .property("sortWeight", new DoubleProperty()).property("startedAt", new DateProperty()) - .property("endedAt", new DateProperty()) - .property("locationWaitingFor", new RefProperty("#/definitions/LocationGetRef")) - .property("queueComingFrom", new RefProperty("#/definitions/QueueGetRef")) - .property("providerWaitingFor", new RefProperty("#/definitions/ProviderGetRef")) - .property("voided", new BooleanProperty()).property("voidedReason", new StringProperty()) - .property("auditInfo", new StringProperty()) - .property("previousQueueEntry", new RefProperty("#/definitions/QueueGetRef")); + model.addProperty("uuid", new UUIDSchema()) + .addProperty("queue", new Schema<>().$ref("#/components/schemas/QueueGetRef")) + .addProperty("display", new StringSchema()) + .addProperty("status", new Schema<>().$ref("#/components/schemas/ConceptGetRef")) + .addProperty("priority", new Schema<>().$ref("#/components/schemas/ConceptGetRef")) + .addProperty("priorityComment", new StringSchema()) + .addProperty("patient", new Schema<>().$ref("#/components/schemas/PatientGetRef")) + .addProperty("visit", new Schema<>().$ref("#/components/schemas/VisitGetRef")) + .addProperty("sortWeight", new NumberSchema().format("double")) + .addProperty("startedAt", new DateTimeSchema()).addProperty("endedAt", new DateTimeSchema()) + .addProperty("locationWaitingFor", new Schema<>().$ref("#/components/schemas/LocationGetRef")) + .addProperty("queueComingFrom", new Schema<>().$ref("#/components/schemas/QueueGetRef")) + .addProperty("providerWaitingFor", new Schema<>().$ref("#/components/schemas/ProviderGetRef")) + .addProperty("voided", new BooleanSchema()).addProperty("voidedReason", new StringSchema()) + .addProperty("auditInfo", new StringSchema()) + .addProperty("previousQueueEntry", new Schema<>().$ref("#/components/schemas/QueueGetRef")); } return model; } @Override - public Model getCREATEModel(Representation rep) { - return new ModelImpl().property("queue", new RefProperty("#/definitions/QueueCreate")) - .property("status", new RefProperty("#/definitions/ConceptCreate")) - .property("priority", new RefProperty("#/definitions/ConceptCreate")) - .property("priorityComment", new StringProperty()) - .property("patient", new RefProperty("#/definitions/PatientCreate")) - .property("visit", new RefProperty("#/definitions/VisitCreate")).property("sortWeight", new DoubleProperty()) - .property("startedAt", new DateProperty()) - .property("locationWaitingFor", new RefProperty("#/definitions/LocationCreate")) - .property("queueComingFrom", new RefProperty("#/definitions/QueueCreate")) - .property("providerWaitingFor", new RefProperty("#/definitions/ProviderCreate")); + public Schema getCREATESchema(Representation rep) { + return new ObjectSchema().addProperty("queue", new Schema<>().$ref("#/components/schemas/QueueCreate")) + .addProperty("status", new Schema<>().$ref("#/components/schemas/ConceptCreate")) + .addProperty("priority", new Schema<>().$ref("#/components/schemas/ConceptCreate")) + .addProperty("priorityComment", new StringSchema()) + .addProperty("patient", new Schema<>().$ref("#/components/schemas/PatientCreate")) + .addProperty("visit", new Schema<>().$ref("#/components/schemas/VisitCreate")) + .addProperty("sortWeight", new NumberSchema().format("double")) + .addProperty("startedAt", new DateTimeSchema()) + .addProperty("locationWaitingFor", new Schema<>().$ref("#/components/schemas/LocationCreate")) + .addProperty("queueComingFrom", new Schema<>().$ref("#/components/schemas/QueueCreate")) + .addProperty("providerWaitingFor", new Schema<>().$ref("#/components/schemas/ProviderCreate")); + } + + @Override + public Schema getUPDATESchema(Representation rep) { + return super.getUPDATESchema(rep).addProperty("status", new Schema<>().$ref("#/components/schemas/ConceptCreate")) + .addProperty("priority", new Schema<>().$ref("#/components/schemas/ConceptCreate")) + .addProperty("priorityComment", new StringSchema()) + .addProperty("sortWeight", new NumberSchema().format("double")) + .addProperty("startedAt", new DateTimeSchema()).addProperty("endedAt", new DateTimeSchema()) + .addProperty("locationWaitingFor", new Schema<>().$ref("#/components/schemas/LocationCreate")) + .addProperty("providerWaitingFor", new Schema<>().$ref("#/components/schemas/ProviderCreate")); } @Override @@ -194,16 +212,6 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe return description; } - @Override - public Model getUPDATEModel(Representation rep) { - return new ModelImpl().property("status", new RefProperty("#/definitions/ConceptCreate")) - .property("priority", new RefProperty("#/definitions/ConceptCreate")) - .property("priorityComment", new StringProperty()).property("sortWeight", new DoubleProperty()) - .property("startedAt", new DateProperty()).property("endedAt", new DateProperty()) - .property("locationWaitingFor", new RefProperty("#/definitions/LocationCreate")) - .property("providerWaitingFor", new RefProperty("#/definitions/ProviderCreate")); - } - @Override public DelegatingResourceDescription getRepresentationDescription(Representation representation) { DelegatingResourceDescription description = new DelegatingResourceDescription(); diff --git a/omod/src/main/java/org/openmrs/module/queue/web/resources/QueueEntrySubResource.java b/omod/src/main/java/org/openmrs/module/queue/web/resources/QueueEntrySubResource.java index a0b30f7..0eca57f 100644 --- a/omod/src/main/java/org/openmrs/module/queue/web/resources/QueueEntrySubResource.java +++ b/omod/src/main/java/org/openmrs/module/queue/web/resources/QueueEntrySubResource.java @@ -16,9 +16,12 @@ import java.util.Collections; import java.util.Optional; -import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.properties.*; +import io.swagger.v3.oas.models.media.BooleanSchema; +import io.swagger.v3.oas.models.media.DateTimeSchema; +import io.swagger.v3.oas.models.media.NumberSchema; +import io.swagger.v3.oas.models.media.ObjectSchema; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.media.StringSchema; import org.openmrs.api.context.Context; import org.openmrs.module.queue.api.QueueServicesWrapper; import org.openmrs.module.queue.api.search.QueueEntrySearchCriteria; @@ -119,18 +122,6 @@ public DelegatingResourceDescription getCreatableProperties() throws ResourceDoe return description; } - @Override - public Model getCREATEModel(Representation rep) { - return new ModelImpl().property("priorityComment", new StringProperty()).property("sortWeight", new DoubleProperty()) - .property("startedAt", new DateProperty()) - .property("patient", new RefProperty("#/definitions/PatientCreate")) - .property("priority", new RefProperty("#/definitions/ConceptCreate")) - .property("locationWaitingFor", new RefProperty("#/definitions/LocationCreate")) - .property("queueComingFrom", new RefProperty("#/definitions/QueueCreate")) - .property("status", new RefProperty("#/definitions/ConceptCreate")) - .property("providerWaitingFor", new RefProperty("#/definitions/ProviderCreate")); - } - @Override public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException { DelegatingResourceDescription description = new DelegatingResourceDescription(); @@ -140,12 +131,6 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe return description; } - @Override - public Model getUPDATEModel(Representation rep) { - return new ModelImpl().property("priorityComment", new StringProperty()).property("sortWeight", new DoubleProperty()) - .property("endedAt", new DateProperty()); - } - @Override public DelegatingResourceDescription getRepresentationDescription(Representation representation) { DelegatingResourceDescription resourceDescription = new DelegatingResourceDescription(); @@ -199,35 +184,54 @@ private void addSharedResourceDescriptionProperties(DelegatingResourceDescriptio } @Override - public Model getGETModel(Representation rep) { - ModelImpl model = (ModelImpl) super.getGETModel(rep); + public Schema getGETSchema(Representation rep) { + Schema model = super.getGETSchema(rep); if (rep instanceof RefRepresentation || rep instanceof DefaultRepresentation) { - model.property("uuid", new StringProperty()).property("display", new StringProperty()) - .property("sortWeight", new DoubleProperty()).property("startedAt", new DateProperty()) - .property("endedAt", new DateProperty()) - .property("status", new RefProperty("#/definitions/ConceptGetRef")) - .property("priority", new RefProperty("#/definitions/ConceptGetRef")) - .property("priorityComment", new StringProperty()) - .property("patient", new RefProperty("#/definitions/PatientGetRef")) - .property("locationWaitingFor", new RefProperty("#/definitions/LocationGetRef")) - .property("queueComingFrom", new RefProperty("#/definitions/QueueGetRef")) - .property("providerWaitingFor", new RefProperty("#/definitions/ProviderGetRef")); + model.addProperty("uuid", new StringSchema()).addProperty("display", new StringSchema()) + .addProperty("sortWeight", new NumberSchema().format("double")) + .addProperty("startedAt", new DateTimeSchema()).addProperty("endedAt", new DateTimeSchema()) + .addProperty("status", new Schema<>().$ref("#/components/schemas/ConceptGetRef")) + .addProperty("priority", new Schema<>().$ref("#/components/schemas/ConceptGetRef")) + .addProperty("priorityComment", new StringSchema()) + .addProperty("patient", new Schema<>().$ref("#/components/schemas/PatientGetRef")) + .addProperty("locationWaitingFor", new Schema<>().$ref("#/components/schemas/LocationGetRef")) + .addProperty("queueComingFrom", new Schema<>().$ref("#/components/schemas/QueueGetRef")) + .addProperty("providerWaitingFor", new Schema<>().$ref("#/components/schemas/ProviderGetRef")); } else if (rep instanceof FullRepresentation) { - model.property("uuid", new StringProperty()).property("display", new StringProperty()) - .property("sortWeight", new DoubleProperty()).property("startedAt", new DateProperty()) - .property("endedAt", new DateProperty()) - .property("status", new RefProperty("#/definitions/ConceptGetFull")) - .property("priority", new RefProperty("#/definitions/ConceptGetFull")) - .property("priorityComment", new StringProperty()).property("voided", new BooleanProperty()) - .property("voidedReason", new StringProperty()).property("auditInfo", new StringProperty()) - .property("patient", new RefProperty("#/definitions/PatientGetRef")) - .property("locationWaitingFor", new RefProperty("#/definitions/LocationGetFull")) - .property("queueComingFrom", new RefProperty("#/definitions/QueueGetFull")) - .property("providerWaitingFor", new RefProperty("#/definitions/ProviderGetFull")); + model.addProperty("uuid", new StringSchema()).addProperty("display", new StringSchema()) + .addProperty("sortWeight", new NumberSchema().format("double")) + .addProperty("startedAt", new DateTimeSchema()).addProperty("endedAt", new DateTimeSchema()) + .addProperty("status", new Schema<>().$ref("#/components/schemas/ConceptGetFull")) + .addProperty("priority", new Schema<>().$ref("#/components/schemas/ConceptGetFull")) + .addProperty("priorityComment", new StringSchema()).addProperty("voided", new BooleanSchema()) + .addProperty("voidedReason", new StringSchema()).addProperty("auditInfo", new StringSchema()) + .addProperty("patient", new Schema<>().$ref("#/components/schemas/PatientGetRef")) + .addProperty("locationWaitingFor", new Schema<>().$ref("#/components/schemas/LocationGetFull")) + .addProperty("queueComingFrom", new Schema<>().$ref("#/components/schemas/QueueGetFull")) + .addProperty("providerWaitingFor", new Schema<>().$ref("#/components/schemas/ProviderGetFull")); } return model; } + @Override + public Schema getCREATESchema(Representation rep) { + return new ObjectSchema().addProperty("priorityComment", new StringSchema()) + .addProperty("sortWeight", new NumberSchema().format("double")) + .addProperty("startedAt", new DateTimeSchema()) + .addProperty("patient", new Schema<>().$ref("#/components/schemas/PatientCreate")) + .addProperty("priority", new Schema<>().$ref("#/components/schemas/ConceptCreate")) + .addProperty("locationWaitingFor", new Schema<>().$ref("#/components/schemas/LocationCreate")) + .addProperty("queueComingFrom", new Schema<>().$ref("#/components/schemas/QueueCreate")) + .addProperty("status", new Schema<>().$ref("#/components/schemas/ConceptCreate")) + .addProperty("providerWaitingFor", new Schema<>().$ref("#/components/schemas/ProviderCreate")); + } + + @Override + public Schema getUPDATESchema(Representation rep) { + return super.getUPDATESchema(rep).addProperty("priorityComment", new StringSchema()) + .addProperty("sortWeight", new NumberSchema().format("double")).addProperty("endedAt", new DateTimeSchema()); + } + @PropertyGetter("display") public String getDisplay(QueueEntry queueEntry) { //Display patient name diff --git a/omod/src/main/java/org/openmrs/module/queue/web/resources/QueueResource.java b/omod/src/main/java/org/openmrs/module/queue/web/resources/QueueResource.java index 9b8fed8..2735d7f 100644 --- a/omod/src/main/java/org/openmrs/module/queue/web/resources/QueueResource.java +++ b/omod/src/main/java/org/openmrs/module/queue/web/resources/QueueResource.java @@ -16,10 +16,9 @@ import java.util.Map; import java.util.Optional; -import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.properties.RefProperty; -import io.swagger.models.properties.StringProperty; +import io.swagger.v3.oas.models.media.ObjectSchema; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.media.StringSchema; import org.openmrs.api.context.Context; import org.openmrs.module.queue.api.QueueServicesWrapper; import org.openmrs.module.queue.api.search.QueueSearchCriteria; @@ -157,48 +156,48 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe } @Override - public Model getGETModel(Representation rep) { - ModelImpl model = (ModelImpl) super.getGETModel(rep); + public Schema getGETSchema(Representation rep) { + Schema model = super.getGETSchema(rep); if (rep instanceof RefRepresentation) { - model.property("uuid", new StringProperty().example("uuid")).property("display", new StringProperty()) - .property("name", new StringProperty()).property("description", new StringProperty()); + model.addProperty("uuid", new StringSchema().example("uuid")).addProperty("display", new StringSchema()) + .addProperty("name", new StringSchema()).addProperty("description", new StringSchema()); } if (rep instanceof DefaultRepresentation) { - model.property("uuid", new StringProperty().example("uuid")).property("display", new StringProperty()) - .property("name", new StringProperty()).property("description", new StringProperty()) - .property("location", new RefProperty("#/definitions/LocationGet")) - .property("service", new RefProperty("#/definitions/ConceptGet")) - .property("priorityConceptSet", new RefProperty("#/definitions/ConceptGet")) - .property("statusConceptSet", new RefProperty("#/definitions/ConceptGet")) - .property("allowedPriorities", new RefProperty("#/definitions/ConceptGet")) - .property("allowedStatuses", new RefProperty("#/definitions/ConceptGet")); + model.addProperty("uuid", new StringSchema().example("uuid")).addProperty("display", new StringSchema()) + .addProperty("name", new StringSchema()).addProperty("description", new StringSchema()) + .addProperty("location", new Schema<>().$ref("#/components/schemas/LocationGet")) + .addProperty("service", new Schema<>().$ref("#/components/schemas/ConceptGet")) + .addProperty("priorityConceptSet", new Schema<>().$ref("#/components/schemas/ConceptGet")) + .addProperty("statusConceptSet", new Schema<>().$ref("#/components/schemas/ConceptGet")) + .addProperty("allowedPriorities", new Schema<>().$ref("#/components/schemas/ConceptGet")) + .addProperty("allowedStatuses", new Schema<>().$ref("#/components/schemas/ConceptGet")); } if (rep instanceof FullRepresentation) { - model.property("uuid", new StringProperty().example("uuid")).property("display", new StringProperty()) - .property("name", new StringProperty()).property("description", new StringProperty()) - .property("location", new RefProperty("#/definitions/LocationGet")) - .property("service", new RefProperty("#/definitions/ConceptGet")) - .property("priorityConceptSet", new RefProperty("#/definitions/ConceptGet")) - .property("statusConceptSet", new RefProperty("#/definitions/ConceptGet")) - .property("allowedPriorities", new RefProperty("#/definitions/ConceptGet")) - .property("allowedStatuses", new RefProperty("#/definitions/ConceptGet")) - .property("auditInfo", new StringProperty()); + model.addProperty("uuid", new StringSchema().example("uuid")).addProperty("display", new StringSchema()) + .addProperty("name", new StringSchema()).addProperty("description", new StringSchema()) + .addProperty("location", new Schema<>().$ref("#/components/schemas/LocationGet")) + .addProperty("service", new Schema<>().$ref("#/components/schemas/ConceptGet")) + .addProperty("priorityConceptSet", new Schema<>().$ref("#/components/schemas/ConceptGet")) + .addProperty("statusConceptSet", new Schema<>().$ref("#/components/schemas/ConceptGet")) + .addProperty("allowedPriorities", new Schema<>().$ref("#/components/schemas/ConceptGet")) + .addProperty("allowedStatuses", new Schema<>().$ref("#/components/schemas/ConceptGet")) + .addProperty("auditInfo", new StringSchema()); } return model; } @Override - public Model getCREATEModel(Representation rep) { - return new ModelImpl().property("name", new StringProperty()).property("description", new StringProperty()) - .property("location", new RefProperty("#/definitions/LocationCreate")) - .property("service", new RefProperty("#/definitions/ConceptCreate")) - .property("priorityConceptSet", new RefProperty("#/definitions/ConceptCreate")) - .property("statusConceptSet", new RefProperty("#/definitions/ConceptCreate")); + public Schema getCREATESchema(Representation rep) { + return new ObjectSchema().addProperty("name", new StringSchema()).addProperty("description", new StringSchema()) + .addProperty("location", new Schema<>().$ref("#/components/schemas/LocationCreate")) + .addProperty("service", new Schema<>().$ref("#/components/schemas/ConceptCreate")) + .addProperty("priorityConceptSet", new Schema<>().$ref("#/components/schemas/ConceptCreate")) + .addProperty("statusConceptSet", new Schema<>().$ref("#/components/schemas/ConceptCreate")); } @Override - public Model getUPDATEModel(Representation rep) { - return getCREATEModel(rep); + public Schema getUPDATESchema(Representation rep) { + return getCREATESchema(rep); } @Override diff --git a/omod/src/main/java/org/openmrs/module/queue/web/resources/QueueRoomResource.java b/omod/src/main/java/org/openmrs/module/queue/web/resources/QueueRoomResource.java index f7f017a..2174a37 100644 --- a/omod/src/main/java/org/openmrs/module/queue/web/resources/QueueRoomResource.java +++ b/omod/src/main/java/org/openmrs/module/queue/web/resources/QueueRoomResource.java @@ -14,10 +14,9 @@ import java.util.Map; import java.util.Optional; -import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.properties.RefProperty; -import io.swagger.models.properties.StringProperty; +import io.swagger.v3.oas.models.media.ObjectSchema; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.media.StringSchema; import org.openmrs.api.context.Context; import org.openmrs.module.queue.api.QueueServicesWrapper; import org.openmrs.module.queue.api.search.QueueRoomSearchCriteria; @@ -147,35 +146,35 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe } @Override - public Model getGETModel(Representation rep) { - ModelImpl model = (ModelImpl) super.getGETModel(rep); + public Schema getGETSchema(Representation rep) { + Schema model = super.getGETSchema(rep); if (rep instanceof DefaultRepresentation) { - model.property("uuid", new StringProperty()).property("display", new StringProperty()) - .property("name", new StringProperty()).property("description", new StringProperty()) - .property("queue", new RefProperty("#/definitions/QueueGet")); + model.addProperty("uuid", new StringSchema()).addProperty("display", new StringSchema()) + .addProperty("name", new StringSchema()).addProperty("description", new StringSchema()) + .addProperty("queue", new Schema<>().$ref("#/components/schemas/QueueGet")); } if (rep instanceof FullRepresentation) { - model.property("queue", new RefProperty("#/definitions/QueueGetFull")) - .property("auditInfo", new StringProperty()).property("queue", new StringProperty()); + model.addProperty("queue", new Schema<>().$ref("#/components/schemas/QueueGetFull")) + .addProperty("auditInfo", new StringSchema()).addProperty("queue", new StringSchema()); } if (rep instanceof RefRepresentation) { - model.property("uuid", new StringProperty()).property("display", new StringProperty()) - .property("name", new StringProperty()).property("description", new StringProperty()) - .property("queue", new RefProperty("#/definitions/QueueGetRef")); + model.addProperty("uuid", new StringSchema()).addProperty("display", new StringSchema()) + .addProperty("name", new StringSchema()).addProperty("description", new StringSchema()) + .addProperty("queue", new Schema<>().$ref("#/components/schemas/QueueGetRef")); } return model; } @Override - public Model getCREATEModel(Representation rep) { - return new ModelImpl().property("name", new StringProperty()).property("description", new StringProperty()) - .property("queue", new RefProperty("#/definitions/QueueCreate")); + public Schema getCREATESchema(Representation rep) { + return new ObjectSchema().addProperty("name", new StringSchema()).addProperty("description", new StringSchema()) + .addProperty("queue", new Schema<>().$ref("#/components/schemas/QueueCreate")); } @Override - public Model getUPDATEModel(Representation rep) { - return getCREATEModel(rep); + public Schema getUPDATESchema(Representation rep) { + return getCREATESchema(rep); } @PropertyGetter("display") diff --git a/omod/src/main/java/org/openmrs/module/queue/web/resources/RoomProviderMapResource.java b/omod/src/main/java/org/openmrs/module/queue/web/resources/RoomProviderMapResource.java index 8704c14..b1b1f30 100644 --- a/omod/src/main/java/org/openmrs/module/queue/web/resources/RoomProviderMapResource.java +++ b/omod/src/main/java/org/openmrs/module/queue/web/resources/RoomProviderMapResource.java @@ -14,10 +14,9 @@ import java.util.Map; import java.util.Optional; -import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.properties.RefProperty; -import io.swagger.models.properties.StringProperty; +import io.swagger.v3.oas.models.media.ObjectSchema; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.media.StringSchema; import org.openmrs.api.context.Context; import org.openmrs.module.queue.api.QueueServicesWrapper; import org.openmrs.module.queue.api.search.RoomProviderMapSearchCriteria; @@ -146,35 +145,30 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe } @Override - public Model getGETModel(Representation rep) { - ModelImpl model = (ModelImpl) super.getGETModel(rep); + public Schema getGETSchema(Representation rep) { + Schema model = super.getGETSchema(rep); if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { - model.property("uuid", new StringProperty()).property("queueRoom", new StringProperty()).property("provider", - new RefProperty("#/definitions/ProviderGetRef")); + model.addProperty("uuid", new StringSchema()).addProperty("queueRoom", new StringSchema()) + .addProperty("provider", new Schema<>().$ref("#/components/schemas/ProviderGetRef")); } if (rep instanceof FullRepresentation) { - model.property("provider", new RefProperty("#/definitions/ProviderGet")); + model.addProperty("provider", new Schema<>().$ref("#/components/schemas/ProviderGet")); } return model; } @Override - public Model getCREATEModel(Representation rep) { - ModelImpl model = new ModelImpl().property("provider", new StringProperty().example("uuid")).property("queueRoom", - new StringProperty().example("uuid")); + public Schema getCREATESchema(Representation rep) { + Schema model = new ObjectSchema().addProperty("provider", new StringSchema().example("uuid")) + .addProperty("queueRoom", new StringSchema().example("uuid")); if (rep instanceof FullRepresentation) { - model.property("provider", new RefProperty("#/definitions/ProviderCreate")); + model.addProperty("provider", new Schema<>().$ref("#/components/schemas/ProviderCreate")); } return model; } @Override - public Model getUPDATEModel(Representation rep) { - ModelImpl model = new ModelImpl().property("provider", new StringProperty().example("uuid")).property("queueRoom", - new StringProperty().example("uuid")); - if (rep instanceof FullRepresentation) { - model.property("provider", new RefProperty("#/definitions/ProviderCreate")); - } - return model; + public Schema getUPDATESchema(Representation rep) { + return getCREATESchema(rep); } } diff --git a/pom.xml b/pom.xml index 655c8a1..10ec81b 100644 --- a/pom.xml +++ b/pom.xml @@ -349,7 +349,7 @@ UTF-8 1.18.20 2.0.9 - 2.32.0 + 2.46.0-SNAPSHOT 2.3.4 2.4.0