Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RESTWS-958: Ensure the module's rest is updated to use swagger 3.0 #78

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading