diff --git a/OpenMRSFormatter.xml b/OpenMRSFormatter.xml
index 35c5cdf8e..cbab4e765 100644
--- a/OpenMRSFormatter.xml
+++ b/OpenMRSFormatter.xml
@@ -263,5 +263,6 @@
+
diff --git a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/CareSettingResource1_10.java b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/CareSettingResource1_10.java
index 9bc2bf73a..31875922e 100644
--- a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/CareSettingResource1_10.java
+++ b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/CareSettingResource1_10.java
@@ -13,8 +13,11 @@
import java.util.List;
import java.util.regex.Pattern;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
import org.openmrs.CareSetting;
import org.openmrs.api.context.Context;
+import org.openmrs.module.webservices.docs.swagger.core.property.EnumProperty;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
@@ -67,6 +70,16 @@ public DelegatingResourceDescription getCreatableProperties() {
throw new ResourceDoesNotSupportOperationException();
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("careSettingType", new EnumProperty(CareSetting.CareSettingType.class));
+ }
+ return model;
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#newDelegate()
*/
diff --git a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderResource1_10.java b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderResource1_10.java
index 196565130..ada37b829 100644
--- a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderResource1_10.java
+++ b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderResource1_10.java
@@ -12,11 +12,17 @@
import java.util.Date;
import java.util.List;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.DateProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.apache.commons.lang.StringUtils;
import org.openmrs.CareSetting;
import org.openmrs.Order;
import org.openmrs.Patient;
import org.openmrs.api.context.Context;
+import org.openmrs.module.webservices.docs.swagger.SwaggerSpecificationCreator;
import org.openmrs.module.webservices.rest.web.ConversionUtil;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.RestConstants;
@@ -102,6 +108,43 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
}
}
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = new ModelImpl()
+ .property("encounter", new StringProperty().example("uuid"))
+ .property("action", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(Order.Action.class)))
+ .property("accessionNumber", new StringProperty())
+ .property("dateActivated", new DateProperty())
+ .property("scheduledDate", new DateProperty())
+ .property("patient", new StringProperty().example("uuid"))
+ .property("concept", new StringProperty().example("uuid"))
+ .property("careSetting", new StringProperty().example("uuid"))
+ .property("dateStopped", new DateProperty())
+ .property("autoExpireDate", new DateProperty())
+ .property("orderer", new StringProperty().example("uuid"))
+ .property("previousOrder", new StringProperty().example("uuid"))
+ .property("urgency", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(Order.Urgency.class)))
+ .property("orderReason", new StringProperty().example("uuid"))
+ .property("orderReasonNonCoded", new StringProperty())
+ .property("instructions", new StringProperty())
+ .property("commentToFulfiller", new StringProperty())
+
+ .required("orderType").required("patient").required("concept");
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("encounter", new RefProperty("#/definitions/EncounterCreate"))
+ .property("patient", new RefProperty("#/definitions/PatientCreate"))
+ .property("concept", new RefProperty("#/definitions/ConceptCreate"))
+ .property("orderer", new RefProperty("#/definitions/UserCreate"))
+ .property("previousOrder", new RefProperty("#/definitions/OrderCreate"))
+ .property("orderReason", new RefProperty("#/definitions/ConceptCreate"));
+ }
+ //FIXME missing prop: type
+ return model;
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties()
*/
diff --git a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderTypeResource1_10.java b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderTypeResource1_10.java
index f8032150c..2ad6e70d5 100644
--- a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderTypeResource1_10.java
+++ b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderTypeResource1_10.java
@@ -13,6 +13,11 @@
import java.util.List;
import java.util.regex.Pattern;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.OrderType;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
@@ -146,4 +151,33 @@ public DelegatingResourceDescription getCreatableProperties() {
d.addProperty("conceptClasses");
return d;
}
+
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("javaClassName", new StringProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("conceptClasses", new ArrayProperty(new RefProperty("#/definitions/ConceptclassGetRef")))
+ .property("parent", new RefProperty("#/definitions/OrdertypeGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("conceptClasses", new ArrayProperty(new RefProperty("#/definitions/ConceptclassGet")))
+ .property("parent", new RefProperty("#/definitions/OrdertypeGet"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .property("javaClassName", new StringProperty())
+ .property("parent", new StringProperty().example("uuid")) //FIXME type
+ .property("conceptClasses", new ArrayProperty(new StringProperty().example("uuid")))
+
+ .required("javaClassName");
+ }
}
diff --git a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderableResource1_10.java b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderableResource1_10.java
index a91fbe82f..671019f53 100644
--- a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderableResource1_10.java
+++ b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderableResource1_10.java
@@ -13,6 +13,8 @@
import java.util.Collection;
import java.util.List;
import java.util.Locale;
+
+import io.swagger.models.Model;
import org.openmrs.ConceptClass;
import org.openmrs.ConceptName;
import org.openmrs.ConceptSearchResult;
@@ -184,6 +186,11 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return description;
}
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return null;
+ }
+
@PropertyGetter("display")
public String getDisplayString(ConceptSearchResult csr) {
ConceptName cn = csr.getConcept().getName();
diff --git a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramEnrollmentResource1_10.java b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramEnrollmentResource1_10.java
index 6d573b0ec..7379c8639 100644
--- a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramEnrollmentResource1_10.java
+++ b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramEnrollmentResource1_10.java
@@ -9,6 +9,12 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_10;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.DateProperty;
+import io.swagger.models.properties.RefProperty;
import org.openmrs.PatientProgram;
import org.openmrs.PatientState;
import org.openmrs.api.context.Context;
@@ -93,6 +99,32 @@ public DelegatingResourceDescription getCreatableProperties() {
return d;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ return super.getGETModel(rep);
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .property("states", new ArrayProperty(new RefProperty("#/definitions/ProgramenrollmentStateCreate")))
+ .property("outcome", new RefProperty("#/definitions/ConceptCreate"));
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl() //FIXME use super.
+ .property("dateEnrolled", new DateProperty())
+ .property("states", new ArrayProperty(new RefProperty("#/definitions/ProgramenrollmentStateCreate")))
+ .property("outcome", new RefProperty("#/definitions/ConceptCreate"))
+ .property("location", new RefProperty("#/definitions/LocationCreate"))
+ .property("voided", new BooleanProperty())
+ .property("dateCompleted", new DateProperty())
+
+ .required("dateEnrolled");
+
+ }
+
@Override
public DelegatingResourceDescription getUpdatableProperties() {
DelegatingResourceDescription d = new DelegatingResourceDescription();
diff --git a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramResource1_10.java b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramResource1_10.java
index 7c78930cd..70981dfbc 100644
--- a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramResource1_10.java
+++ b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramResource1_10.java
@@ -9,6 +9,10 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_10;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Program;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
@@ -60,6 +64,17 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = ((ModelImpl) super.getCREATEModel(rep))
+ .property("outcomesConcept", new StringProperty().example("uuid"));
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("outcomesConcept", new RefProperty("#/definitions/ConceptCreate"));
+ }
+ return model;
+ }
+
@Override
public DelegatingResourceDescription getCreatableProperties() {
DelegatingResourceDescription description = new DelegatingResourceDescription();
diff --git a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/TestOrderSubclassHandler1_10.java b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/TestOrderSubclassHandler1_10.java
index 06a38cf88..73f2338de 100644
--- a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/TestOrderSubclassHandler1_10.java
+++ b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/TestOrderSubclassHandler1_10.java
@@ -11,6 +11,11 @@
import java.util.List;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.IntegerProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.apache.commons.lang.StringUtils;
import org.openmrs.CareSetting;
import org.openmrs.Order;
@@ -19,6 +24,7 @@
import org.openmrs.TestOrder;
import org.openmrs.api.OrderService;
import org.openmrs.api.context.Context;
+import org.openmrs.module.webservices.docs.swagger.core.property.EnumProperty;
import org.openmrs.module.webservices.rest.web.ConversionUtil;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter;
@@ -123,6 +129,47 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe
return orderResource.getUpdatableProperties();
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ OrderResource1_10 orderResource = (OrderResource1_10) Context.getService(RestService.class).getResourceBySupportedClass(Order.class);
+ ModelImpl orderModel = (ModelImpl) orderResource.getGETModel(rep);
+ orderModel
+ .property("laterality", new EnumProperty(TestOrder.Laterality.class))
+ .property("clinicalHistory", new StringProperty())
+ .property("numberOfRepeats", new IntegerProperty());
+
+ if (rep instanceof DefaultRepresentation) {
+ orderModel
+ .property("specimenSource", new RefProperty("#/definitions/ConceptGetRef"))
+ .property("frequency", new RefProperty("#/definitions/OrderfrequencyGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ orderModel
+ .property("specimenSource", new RefProperty("#/definitions/ConceptGet"))
+ .property("frequency", new RefProperty("#/definitions/OrderfrequencyGet"));
+ }
+ return orderModel;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ OrderResource1_10 orderResource = (OrderResource1_10) Context.getService(RestService.class)
+ .getResourceBySupportedClass(Order.class);
+ ModelImpl orderModel = (ModelImpl) orderResource.getCREATEModel(rep);
+ return orderModel
+ .property("specimenSource", new StringProperty().example("uuid"))
+ .property("laterality", new EnumProperty(TestOrder.Laterality.class))
+ .property("clinicalHistory", new StringProperty())
+ .property("frequency", new StringProperty().example("uuid"))
+ .property("numberOfRepeats", new IntegerProperty());
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ OrderResource1_10 orderResource = (OrderResource1_10) Context.getService(RestService.class)
+ .getResourceBySupportedClass(Order.class);
+ return orderResource.getUPDATEModel(rep);
+ }
+
public PageableResult getActiveOrders(Patient patient, RequestContext context) {
String careSettingUuid = context.getRequest().getParameter("careSetting");
String asOfDateString = context.getRequest().getParameter("asOfDate");
diff --git a/omod-1.11/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/DrugIngredientResource1_11.java b/omod-1.11/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/DrugIngredientResource1_11.java
index a30395d9d..30f094a7f 100644
--- a/omod-1.11/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/DrugIngredientResource1_11.java
+++ b/omod-1.11/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/DrugIngredientResource1_11.java
@@ -12,6 +12,11 @@
import java.util.ArrayList;
import java.util.List;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.DoubleProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Drug;
import org.openmrs.DrugIngredient;
import org.openmrs.api.context.Context;
@@ -80,6 +85,42 @@ public DelegatingResourceDescription getUpdatableProperties() {
return getCreatableProperties();
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ modelImpl
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("strength", new DoubleProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ modelImpl
+ .property("ingredient", new RefProperty("#/definitions/ConceptGetRef"))
+ .property("units", new RefProperty("#/definitions/ConceptGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ modelImpl
+ .property("ingredient", new RefProperty("#/definitions/ConceptGet"))
+ .property("units", new RefProperty("#/definitions/ConceptGet"));
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("ingredient", new StringProperty().example("uuid"))
+ .property("strength", new DoubleProperty())
+ .property("units", new StringProperty().example("uuid"))
+
+ .required("ingredient");
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#getParent(java.lang.Object)
*/
diff --git a/omod-1.11/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/ObsResource1_11.java b/omod-1.11/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/ObsResource1_11.java
index 3573d5278..3e7d8dc9d 100644
--- a/omod-1.11/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/ObsResource1_11.java
+++ b/omod-1.11/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/ObsResource1_11.java
@@ -9,6 +9,9 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_11;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Obs;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
@@ -35,6 +38,20 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ return ((ModelImpl) super.getGETModel(rep))
+ .property("formFieldPath", new StringProperty())
+ .property("formFieldNamespace", new StringProperty());
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .property("formFieldPath", new StringProperty())
+ .property("formFieldNamespace", new StringProperty());
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties()
*/
diff --git a/omod-1.11/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/PersonResource1_11.java b/omod-1.11/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/PersonResource1_11.java
index 67a493efc..add1f50b5 100644
--- a/omod-1.11/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/PersonResource1_11.java
+++ b/omod-1.11/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/PersonResource1_11.java
@@ -9,9 +9,15 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_11;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.DateTimeProperty;
import org.openmrs.Person;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
+import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation;
+import org.openmrs.module.webservices.rest.web.representation.FullRepresentation;
import org.openmrs.module.webservices.rest.web.representation.Representation;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription;
@@ -61,6 +67,30 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ return addNewProperties(super.getGETModel(rep), rep);
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return addNewProperties(super.getCREATEModel(rep), rep);
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return addNewProperties(super.getUPDATEModel(rep), rep);
+ }
+
+ private Model addNewProperties(Model model, Representation rep) {
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ ((ModelImpl) model)
+ .property("deathdateEstimated", new BooleanProperty()._default(false))
+ .property("birthtime", new DateTimeProperty());
+ }
+ return model;
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getResourceVersion()
*/
diff --git a/omod-1.12/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_12/OrderSetMemberResource1_12.java b/omod-1.12/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_12/OrderSetMemberResource1_12.java
index ee0e0eaff..941516567 100644
--- a/omod-1.12/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_12/OrderSetMemberResource1_12.java
+++ b/omod-1.12/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_12/OrderSetMemberResource1_12.java
@@ -9,6 +9,12 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_12;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.ObjectProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.OrderSet;
import org.openmrs.OrderSetMember;
import org.openmrs.api.context.Context;
@@ -98,6 +104,44 @@ public DelegatingResourceDescription getUpdatableProperties() {
return creatableProperties;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ modelImpl
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("retired", new BooleanProperty())
+ .property("orderTemplate", new StringProperty())
+ .property("orderTemplateType", new StringProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ modelImpl
+ .property("orderType", new RefProperty("#/definitions/OrdertypeGetRef"))
+ .property("concept", new RefProperty("#/definitions/ConceptGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ modelImpl
+ .property("orderType", new RefProperty("#/definitions/OrdertypeGet"))
+ .property("concept", new RefProperty("#/definitions/ConceptGet"));
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("orderType", new ObjectProperty()
+ .property("uuid", new StringProperty()))
+ .property("orderTemplate", new StringProperty())
+ .property("concept", new StringProperty().example("uuid"))
+ .property("retired", new BooleanProperty());
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
@Override
public OrderSetMember getByUniqueId(String uniqueId) {
return Context.getOrderSetService().getOrderSetMemberByUuid(uniqueId);
diff --git a/omod-1.12/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_12/OrderSetResource1_12.java b/omod-1.12/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_12/OrderSetResource1_12.java
index f40fdf8b0..e89e44f7f 100644
--- a/omod-1.12/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_12/OrderSetResource1_12.java
+++ b/omod-1.12/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_12/OrderSetResource1_12.java
@@ -9,11 +9,16 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_12;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.RefProperty;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.openmrs.OrderSet;
import org.openmrs.OrderSetMember;
import org.openmrs.api.context.Context;
+import org.openmrs.module.webservices.docs.swagger.core.property.EnumProperty;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.PropertySetter;
@@ -102,4 +107,28 @@ public DelegatingResourceDescription getCreatableProperties() {
d.addProperty("orderSetMembers");
return d;
}
+
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ modelImpl
+ .property("operator", new EnumProperty(OrderSet.Operator.class));
+ }
+ if (rep instanceof DefaultRepresentation) {
+ modelImpl
+ .property("orderSetMembers", new ArrayProperty(new RefProperty("#/definitions/OrdersetOrdersetmemberGetRef")));
+ } else if (rep instanceof FullRepresentation) {
+ modelImpl
+ .property("orderSetMembers", new ArrayProperty(new RefProperty("#/definitions/OrdersetOrdersetmemberGet")));
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation representation) {
+ return new ModelImpl()
+ .property("operator", new EnumProperty(OrderSet.Operator.class))
+ .property("orderSetMembers", new ArrayProperty(new RefProperty("#/definitions/OrdersetOrdersetmemberCreate")));
+ }
}
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/AllergyResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/AllergyResource1_8.java
index 66a64202a..407131978 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/AllergyResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/AllergyResource1_8.java
@@ -9,9 +9,17 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ObjectProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Patient;
import org.openmrs.activelist.Allergy;
+import org.openmrs.activelist.AllergySeverity;
+import org.openmrs.activelist.AllergyType;
import org.openmrs.api.context.Context;
+import org.openmrs.module.webservices.docs.swagger.SwaggerSpecificationCreator;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter;
@@ -55,6 +63,35 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = ((ModelImpl) super.getGETModel(rep))
+ .property("allergyType", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(AllergyType.class)))
+ .property("reaction", new RefProperty("#/definitions/ConceptGetRef"))
+ .property("severity", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(AllergySeverity.class)))
+ .property("allergen", new RefProperty("#/definitions/ConceptGetRef"));
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("reaction", new RefProperty("#/definitions/ConceptGet"))
+ .property("allergen", new RefProperty("#/definitions/ConceptGet"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .property("allergyType", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(AllergyType.class)))
+ .property("reaction", new ObjectProperty()
+ .property("uuid", new StringProperty()))
+ .property("severity", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(AllergySeverity.class)))
+ .property("allergen", new StringProperty());
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/BaseActiveListItemResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/BaseActiveListItemResource1_8.java
index f570f79b0..9ef1b74c0 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/BaseActiveListItemResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/BaseActiveListItemResource1_8.java
@@ -9,6 +9,12 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.DateProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.activelist.ActiveListItem;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
@@ -26,6 +32,25 @@
*/
public abstract class BaseActiveListItemResource1_8 extends DataDelegatingCrudResource {
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = new ModelImpl()
+ .property("person", new StringProperty())
+ .property("startDate", new DateProperty())
+ .property("comments", new StringProperty())
+ .property("startObs", new StringProperty())
+ .property("stopObs", new StringProperty())
+
+ .required("person").required("startDate");
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("person", new RefProperty("#/definitions/PersonCreate"))
+ .property("startObs", new RefProperty("#/definitions/ObsCreate"))
+ .property("stopObs", new RefProperty("#/definitions/ObsCreate"));
+ }
+ return model;
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation)
*/
@@ -65,6 +90,30 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = ((ModelImpl) super.getGETModel(rep))
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("startDate", new DateProperty())
+ .property("endDate", new DateProperty())
+ .property("comments", new StringProperty())
+ .property("voided", new BooleanProperty());
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("person", new RefProperty("#/definitions/PersonGet"))
+ .property("activeListType", new StringProperty()) //FIXME type
+ .property("startObs", new RefProperty("#/definitions/ObsGet"))
+ .property("stopObs", new RefProperty("#/definitions/ObsGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("person", new RefProperty("#/definitions/PersonGetRef"))
+ .property("activeListType", new StringProperty()) //FIXME type
+ .property("startObs", new RefProperty("#/definitions/ObsGetRef"))
+ .property("stopObs", new RefProperty("#/definitions/ObsGetRef"));
+ }
+ return model;
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortMemberResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortMemberResource1_8.java
index f2c93b04a..e7c970916 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortMemberResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortMemberResource1_8.java
@@ -12,6 +12,10 @@
import java.util.ArrayList;
import java.util.List;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Cohort;
import org.openmrs.Patient;
import org.openmrs.api.context.Context;
@@ -116,6 +120,40 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof RefRepresentation) {
+ modelImpl
+ .property("display", new StringProperty());
+ } else if (rep instanceof DefaultRepresentation) {
+ modelImpl
+ .property("display", new StringProperty())
+ .property("patient", new RefProperty("#/definitions/PatientGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ modelImpl
+ .property("display", new StringProperty())
+ .property("patient", new RefProperty("#/definitions/PatientGetRef"));
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = new ModelImpl()
+ .property("patient", new StringProperty().example("uuid"))
+ .required("patient");
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("patient", new RefProperty("#/definitions/PatientCreate"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortResource1_8.java
index b19f97f00..e0b9fb97b 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortResource1_8.java
@@ -11,6 +11,11 @@
import java.util.List;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.IntegerProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Cohort;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
@@ -87,6 +92,37 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = ((ModelImpl) super.getGETModel(rep));
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("name", new StringProperty())
+ .property("description", new StringProperty())
+ .property("voided", new StringProperty())
+ .property("memberIds", new ArrayProperty(new IntegerProperty())); //FIXME
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("name", new StringProperty())
+ .property("description", new StringProperty())
+ .property("memberIds", new ArrayProperty(new IntegerProperty())) //FIXME
+ .required("name").required("description").required("memberIds");
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation representation) {
+ return new ModelImpl()
+ .property("name", new StringProperty())
+ .property("description", new StringProperty())
+ .required("name").required("description");
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptClassResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptClassResource1_8.java
index 1b961b5dc..ea30562e9 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptClassResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptClassResource1_8.java
@@ -9,11 +9,13 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
import org.openmrs.ConceptClass;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
+import org.openmrs.module.webservices.rest.web.representation.Representation;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource;
import org.openmrs.module.webservices.rest.web.resource.impl.MetadataDelegatingCrudResource;
import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging;
@@ -65,6 +67,21 @@ public void purge(ConceptClass conceptClass, RequestContext context) throws Resp
Context.getConceptService().purgeConceptClass(conceptClass);
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ return super.getGETModel(rep);
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return super.getCREATEModel(rep);
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext)
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDatatypeResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDatatypeResource1_8.java
index ff5c8cf7b..7bf103fe9 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDatatypeResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDatatypeResource1_8.java
@@ -9,6 +9,10 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.ConceptDatatype;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.SimpleObject;
@@ -63,6 +67,25 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = ((ModelImpl) super.getGETModel(rep));
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("name", new StringProperty())
+ .property("description", new StringProperty())
+ .property("hl7Abbreviation", new StringProperty())
+ .property("retired", new BooleanProperty());
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return super.getCREATEModel(rep);
+ }
+
/**
* @see DelegatingCrudResource#newDelegate()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDescriptionResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDescriptionResource1_8.java
index c4dab51a8..d5465bd38 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDescriptionResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDescriptionResource1_8.java
@@ -12,6 +12,9 @@
import java.util.ArrayList;
import java.util.List;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Concept;
import org.openmrs.ConceptDescription;
import org.openmrs.api.context.Context;
@@ -64,6 +67,36 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof RefRepresentation) {
+ modelImpl
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty());
+ } else if (rep instanceof DefaultRepresentation) {
+ modelImpl
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("description", new StringProperty())
+ .property("locale", new StringProperty());
+ } else if (rep instanceof FullRepresentation) {
+ modelImpl
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("description", new StringProperty())
+ .property("locale", new StringProperty());
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation representation) {
+ return new ModelImpl()
+ .property("description", new StringProperty())
+ .property("locale", new StringProperty().example("fr"))
+ .required("description").required("locale");
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptMapResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptMapResource1_8.java
index e6c3e859e..798d54364 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptMapResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptMapResource1_8.java
@@ -12,6 +12,9 @@
import java.util.ArrayList;
import java.util.List;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Concept;
import org.openmrs.ConceptMap;
import org.openmrs.api.context.Context;
@@ -62,6 +65,33 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation) {
+ modelImpl
+ .property("display", new StringProperty())
+ .property("uuid", new StringProperty())
+ .property("source", new StringProperty()) //FIXME
+ .property("sourceCode", new StringProperty());
+ } else if (rep instanceof FullRepresentation) {
+ modelImpl
+ .property("display", new StringProperty())
+ .property("uuid", new StringProperty())
+ .property("source", new StringProperty()) //FIXME
+ .property("sourceCode", new StringProperty())
+ .property("comment", new StringProperty());
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation representation) {
+ return new ModelImpl()
+ .property("source", new StringProperty())
+ .property("sourceCode", new StringProperty())
+ .required("source").required("sourceCode");
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptNameResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptNameResource1_8.java
index 20e5788c2..9faa08abb 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptNameResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptNameResource1_8.java
@@ -13,9 +13,15 @@
import java.util.Date;
import java.util.List;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Concept;
import org.openmrs.ConceptName;
+import org.openmrs.api.ConceptNameType;
import org.openmrs.api.context.Context;
+import org.openmrs.module.webservices.docs.swagger.SwaggerSpecificationCreator;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter;
@@ -64,6 +70,39 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = ((ModelImpl) super.getGETModel(rep))
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty());
+
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("name", new StringProperty())
+ .property("locale", new StringProperty().example("en"))
+ .property("localePreferred", new BooleanProperty())
+ .property("conceptNameType", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(ConceptNameType.class)));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("name", new StringProperty())
+ .property("locale", new StringProperty().example("en"))
+ .property("localePreferred", new BooleanProperty()._default(false))
+ .property("conceptNameType", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(ConceptNameType.class)))
+ .required("name").required("locale");
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation representation) {
+ return new ModelImpl()
+ .property("name", new StringProperty()); //FIXME missing props
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptResource1_8.java
index 28ce1839c..68accd94d 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptResource1_8.java
@@ -9,6 +9,13 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.ObjectProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.apache.commons.lang.StringUtils;
import org.openmrs.Concept;
import org.openmrs.ConceptAnswer;
@@ -209,6 +216,72 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = ((ModelImpl) super.getGETModel(rep))
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty());
+ if (rep instanceof DefaultRepresentation) {
+ modelImpl
+ .property("name", new RefProperty("#/definitions/ConceptNameGet"))
+ .property("datatype", new RefProperty("#/definitions/ConceptdatatypeGetRef"))
+ .property("conceptClass", new RefProperty("#/definitions/ConceptclassGetRef"))
+ .property("set", new BooleanProperty())
+ .property("version", new StringProperty())
+ .property("retired", new BooleanProperty())
+ .property("names", new ArrayProperty(new RefProperty("#/definitions/ConceptNameGetRef"))) //FIXME
+ .property("descriptions", new ArrayProperty(new RefProperty("#/definitions/ConceptDescriptionGetRef"))) //FIXME
+ .property("mappings", new ArrayProperty(new RefProperty("#/definitions/ConceptMappingGetRef"))) //FIXME
+ .property("answers", new ArrayProperty(new ObjectProperty())) //FIXME
+ .property("setMembers", new ArrayProperty(new ObjectProperty())); //FIXME
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = new ModelImpl()
+ .property("names", new ArrayProperty(new RefProperty("#/definitions/ConceptNameCreate")))
+ .property("datatype", new StringProperty().example("uuid"))
+ .property("set", new BooleanProperty())
+ .property("version", new StringProperty())
+ .property("answers", new ArrayProperty(new StringProperty().example("uuid")))
+ .property("setMembers", new ArrayProperty(new StringProperty().example("uuid")))
+
+ //ConceptNumeric properties
+ .property("hiNormal", new StringProperty())
+ .property("hiAbsolute", new StringProperty())
+ .property("hiCritical", new StringProperty())
+ .property("lowNormal", new StringProperty())
+ .property("lowAbsolute", new StringProperty())
+ .property("lowCritical", new StringProperty())
+ .property("units", new StringProperty())
+ .property("allowDecimal", new StringProperty())
+ .property("displayPrecision", new StringProperty())
+
+ .required("names").required("datatype").required("conceptClass");
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("conceptClass", new StringProperty())
+ .property("descriptions", new ArrayProperty(new StringProperty()))
+ .property("mappings", new ArrayProperty(new StringProperty()));
+ }
+ else if (rep instanceof FullRepresentation) {
+ model
+ .property("conceptClass", new RefProperty("#/definitions/ConceptclassCreate"))
+ .property("descriptions", new ArrayProperty(new RefProperty("#/definitions/ConceptDescriptionCreate")))
+ .property("mappings", new ArrayProperty(new RefProperty("#/definitions/ConceptMappingCreate")));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation representation) {
+ return new ModelImpl()
+ .property("name", new RefProperty("#/definitions/ConceptNameCreate"))
+ .property("names", new ArrayProperty(new RefProperty("#/definitions/ConceptNameCreate")))
+ .property("descriptions", new ArrayProperty(new RefProperty("#/definitions/ConceptDescriptionCreate")));
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptSourceResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptSourceResource1_8.java
index a7d37507d..8d723b2be 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptSourceResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptSourceResource1_8.java
@@ -9,6 +9,10 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.ConceptSource;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
@@ -66,6 +70,25 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ public Model getGETModel(Representation rep) {
+ return ((ModelImpl) super.getGETModel(rep))
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("name", new StringProperty())
+ .property("description", new StringProperty())
+ .property("hl7Code", new StringProperty())
+ .property("retired", new BooleanProperty());
+ }
+
+ @Override
+ public Model getCREATEModel(Representation representation) {
+ return new ModelImpl()
+ .property("name", new StringProperty())
+ .property("description", new StringProperty())
+ .property("hl7Code", new StringProperty())
+ .required("name").required("description");
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugOrderSubclassHandler1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugOrderSubclassHandler1_8.java
index fe206362f..8040cae95 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugOrderSubclassHandler1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugOrderSubclassHandler1_8.java
@@ -11,6 +11,13 @@
import java.util.List;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.DoubleProperty;
+import io.swagger.models.properties.IntegerProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.DrugOrder;
import org.openmrs.Order;
import org.openmrs.Patient;
@@ -35,7 +42,7 @@
*/
@SubClassHandler(supportedClass = DrugOrder.class, supportedOpenmrsVersions = { "1.8.*", "1.9.*" })
public class DrugOrderSubclassHandler1_8 extends BaseDelegatingSubclassHandler implements DelegatingSubclassHandler {
-
+
public DrugOrderSubclassHandler1_8() {
//RESTWS-439
//Order subclass fields
@@ -129,6 +136,49 @@ public DelegatingResourceDescription getCreatableProperties() {
return d;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ OrderResource1_8 orderResource = (OrderResource1_8) Context.getService(RestService.class)
+ .getResourceBySupportedClass(Order.class);
+ ModelImpl orderModel = (ModelImpl) orderResource.getGETModel(rep);
+ orderModel
+ .property("dose", new DoubleProperty())
+ .property("units", new StringProperty())
+ .property("frequency", new StringProperty())
+ .property("prn", new BooleanProperty())
+ .property("complex", new BooleanProperty())
+ .property("quantity", new IntegerProperty());
+
+ if (rep instanceof DefaultRepresentation) {
+ orderModel
+ .property("drug", new RefProperty("#/definitions/DrugGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ orderModel
+ .property("drug", new RefProperty("#/definitions/DrugGet"));
+ }
+ return orderModel;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ OrderResource1_8 orderResource = (OrderResource1_8) Context.getService(RestService.class)
+ .getResourceBySupportedClass(Order.class);
+ ModelImpl orderModel = (ModelImpl) orderResource.getCREATEModel(rep);
+ orderModel
+ .property("dose", new DoubleProperty())
+ .property("units", new StringProperty())
+ .property("frequency", new StringProperty())
+ .property("prn", new BooleanProperty())
+ .property("complex", new BooleanProperty())
+ .property("quantity", new IntegerProperty())
+ .property("drug", new RefProperty("#/definitions/DrugCreate"));
+
+ // DrugOrders have a specific hardcoded value for this property
+ orderModel.getProperties().remove("orderType");
+
+ return orderModel;
+ }
+
/**
* Handles getOrdersByPatient for {@link OrderResource1_8} when type=drugorder
*
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugResource1_8.java
index 4575d1cc2..7d6ba1abf 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugResource1_8.java
@@ -9,6 +9,12 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.DoubleProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Drug;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
@@ -114,6 +120,57 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ modelImpl
+ .property("doseStrength", new DoubleProperty())
+ .property("maximumDailyDose", new DoubleProperty())
+ .property("minimumDailyDose", new DoubleProperty())
+ .property("units", new StringProperty())
+ .property("combination", new BooleanProperty()._default(false));
+ }
+ if (rep instanceof DefaultRepresentation) {
+ modelImpl
+ .property("dosageForm", new RefProperty("#/definitions/ConceptGetRef"))
+ .property("concept", new RefProperty("#/definitions/ConceptGetRef"))
+ .property("route", new RefProperty("#/definitions/ConceptGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ modelImpl
+ .property("dosageForm", new RefProperty("#/definitions/ConceptGet"))
+ .property("concept", new RefProperty("#/definitions/ConceptGet"))
+ .property("route", new RefProperty("#/definitions/ConceptGet"));
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = ((ModelImpl) super.getCREATEModel(rep))
+ .property("combination", new BooleanProperty()._default(false))
+ .property("concept", new StringProperty())
+ .property("doseStrength", new DoubleProperty())
+ .property("maximumDailyDose", new DoubleProperty())
+ .property("minimumDailyDose", new DoubleProperty())
+ .property("units", new StringProperty())
+ .property("dosageForm", new StringProperty())
+ .property("route", new StringProperty())
+
+ .required("combination").required("concept");
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("concept", new RefProperty("#/definitions/ConceptCreate"))
+ .property("dosageForm", new RefProperty("#/definitions/ConceptCreate"))
+ .property("route", new RefProperty("#/definitions/ConceptCreate"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep); //FIXME no updatableProperties()
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.MetadataDelegatingCrudResource#getCreatableProperties()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterResource1_8.java
index 65431aa72..47272728e 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterResource1_8.java
@@ -9,6 +9,13 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.DateProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Encounter;
import org.openmrs.Obs;
import org.openmrs.Order;
@@ -37,6 +44,8 @@
import java.util.List;
import java.util.Set;
+import static org.hibernate.criterion.Projections.property;
+
/**
* Resource for Encounters, supporting standard CRUD operations
*/
@@ -84,6 +93,56 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ modelImpl
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("encounterDatetime", new DateProperty())
+ .property("provider", new StringProperty()) //FIXME
+ .property("voided", new BooleanProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ modelImpl
+ .property("patient", new RefProperty("#/definitions/PatientGetRef")) //FIXME
+ .property("location", new RefProperty("#/definitions/LocationGetRef")) //FIXME
+ .property("form", new RefProperty("#/definitions/FormGetRef")) //FIXME
+ .property("encounterType", new RefProperty("#/definitions/EncountertypeGetRef")) //FIXME
+ .property("obs", new ArrayProperty(new RefProperty("#/definitions/ObsGetRef"))) //FIXME
+ .property("orders", new ArrayProperty(new RefProperty("#/definitions/OrderGetRef"))); //FIXME
+ } else if (rep instanceof FullRepresentation) {
+ modelImpl
+ .property("patient", new RefProperty("#/definitions/PatientGet")) //FIXME
+ .property("location", new RefProperty("#/definitions/LocationGet")) //FIXME
+ .property("form", new RefProperty("#/definitions/FormGet")) //FIXME
+ .property("encounterType", new RefProperty("#/definitions/EncountertypeGet")) //FIXME
+ .property("obs", new ArrayProperty(new RefProperty("#/definitions/ObsGet"))) //FIXME
+ .property("orders", new ArrayProperty(new RefProperty("#/definitions/OrderGet"))); //FIXME
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("patient", new RefProperty("#/definitions/PatientCreate"))
+ .property("encounterType", new RefProperty("#/definitions/EncountertypeCreate"))
+ .property("encounterDatetime", new DateProperty())
+ .property("location", new RefProperty("#/definitions/LocationCreate"))
+ .property("form", new RefProperty("#/definitions/FormCreate"))
+ .property("provider", new StringProperty())
+ .property("orders", new ArrayProperty(new RefProperty("#/definitions/OrderCreate")))
+ .property("obs", new ArrayProperty(new RefProperty("#/definitions/ObsCreate")))
+
+ .required("patient").required("encounterType");
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties()
* @should create an encounter type
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterTypeResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterTypeResource1_8.java
index afb412b2b..ef024a23a 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterTypeResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterTypeResource1_8.java
@@ -9,11 +9,14 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
import org.openmrs.EncounterType;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
+import org.openmrs.module.webservices.rest.web.representation.Representation;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription;
import org.openmrs.module.webservices.rest.web.resource.impl.MetadataDelegatingCrudResource;
@@ -40,6 +43,17 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ return super.getGETModel(rep);
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .required("description");
+ }
+
/**
* @see DelegatingCrudResource#newDelegate()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldAnswerResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldAnswerResource1_8.java
index 1e3a9d561..6a1b5a081 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldAnswerResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldAnswerResource1_8.java
@@ -12,6 +12,10 @@
import java.util.ArrayList;
import java.util.List;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Field;
import org.openmrs.FieldAnswer;
import org.openmrs.api.context.Context;
@@ -76,6 +80,38 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation) {
+ modelImpl
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("concept", new RefProperty("#/definitions/ConceptGetRef"))
+ .property("field", new RefProperty("#/definitions/FieldGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ modelImpl
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("concept", new RefProperty("#/definitions/ConceptGet"))
+ .property("field", new RefProperty("#/definitions/FieldGet"));
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = new ModelImpl()
+ .property("concept", new StringProperty().example("uuid"))
+ .property("field", new StringProperty().example("uuid"))
+ .required("field").required("concept");
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("concept", new RefProperty("#/definitions/ConceptCreate"))
+ .property("field", new RefProperty("#/definitions/FieldCreate"));
+ }
+ return model;
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.MetadataDelegatingCrudResource#getCreatableProperties()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldResource1_8.java
index 6a9f15113..730a22626 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldResource1_8.java
@@ -9,6 +9,11 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Field;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
@@ -32,6 +37,45 @@
"1.9.*", "1.10.*", "1.11.*", "1.12.*", "2.0.*", "2.1.*" })
public class FieldResource1_8 extends MetadataDelegatingCrudResource {
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ modelImpl
+ .property("tableName", new StringProperty())
+ .property("attributeName", new StringProperty())
+ .property("defaultValue", new StringProperty())
+ .property("selectMultiple", new BooleanProperty()._default(false));
+ }
+ if (rep instanceof DefaultRepresentation) {
+ modelImpl
+ .property("fieldType", new RefProperty("#/definitions/FieldtypeGetRef"))
+ .property("concept", new RefProperty("#/definitions/ConceptGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ modelImpl
+ .property("fieldType", new RefProperty("#/definitions/FieldtypeGet"))
+ .property("concept", new RefProperty("#/definitions/ConceptGet"));
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .property("fieldType", new RefProperty("#/definitions/FieldtypeCreate"))
+ .property("selectMultiple", new BooleanProperty()._default(false))
+ .property("concept", new RefProperty("#/definitions/ConceptCreate"))
+ .property("tableName", new StringProperty())
+ .property("attributeName", new StringProperty())
+ .property("defaultValue", new StringProperty())
+
+ .required("fieldType").required("selectMultiple");
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation representation) {
+ return new ModelImpl(); //FIXME missing props
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation)
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldTypeResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldTypeResource1_8.java
index 24d9d9b9d..75c16d802 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldTypeResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldTypeResource1_8.java
@@ -9,6 +9,9 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
import org.openmrs.FieldType;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
@@ -29,6 +32,25 @@
"1.8.*", "1.9.*", "1.10.*", "1.11.*", "1.12.*", "2.0.*", "2.1.*" })
public class FieldTypeResource1_8 extends MetadataDelegatingCrudResource {
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ modelImpl
+ .property("isSet", new BooleanProperty()._default(false));
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return super.getCREATEModel(rep); //FIXME missing props
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl(); //FIXME missing props
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation)
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormFieldResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormFieldResource1_8.java
index 07fef9d85..3936641db 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormFieldResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormFieldResource1_8.java
@@ -12,6 +12,13 @@
import java.util.ArrayList;
import java.util.List;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.FloatProperty;
+import io.swagger.models.properties.IntegerProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Form;
import org.openmrs.FormField;
import org.openmrs.api.context.Context;
@@ -35,6 +42,64 @@
"1.8.*", "1.9.*", "1.10.*", "1.11.*", "1.12.*", "2.0.*", "2.1.*" })
public class FormFieldResource1_8 extends DelegatingSubResource {
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ modelImpl
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("fieldNumber", new IntegerProperty())
+ .property("fieldPart", new StringProperty())
+ .property("pageNumber", new IntegerProperty())
+ .property("minOccurs", new IntegerProperty())
+ .property("maxOccurs", new IntegerProperty())
+ .property("required", new BooleanProperty()._default(false))
+ .property("sortWeight", new FloatProperty())
+ .property("retired", new BooleanProperty()); //FIXME
+ }
+ if (rep instanceof DefaultRepresentation) {
+ modelImpl
+ .property("parent", new RefProperty("#/definitions/FormFormfieldGetRef"))
+ .property("form", new RefProperty("#/definitions/FormGetRef"))
+ .property("field", new RefProperty("#/definitions/FieldGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ modelImpl
+ .property("parent", new RefProperty("#/definitions/FormFormfieldGet"))
+ .property("form", new RefProperty("#/definitions/FormGet"))
+ .property("field", new RefProperty("#/definitions/FieldGet"));
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = new ModelImpl() //FIXME validate if correct
+ .property("form", new StringProperty().example("uuid"))
+ .property("field", new StringProperty().example("uuid"))
+ .property("required", new BooleanProperty()._default(false))
+ .property("parent", new StringProperty().example("uuid"))
+ .property("fieldNumber", new IntegerProperty())
+ .property("fieldPart", new StringProperty())
+ .property("pageNumber", new IntegerProperty())
+ .property("minOccurs", new IntegerProperty())
+ .property("maxOccurs", new IntegerProperty())
+ .property("sortWeight", new BooleanProperty()._default(false))
+
+ .required("form").required("field").required("required");
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("form", new RefProperty("#/definitions/FormCreate"))
+ .property("field", new RefProperty("#/definitions/FieldCreate"))
+ .property("parent", new RefProperty("#/definitions/FormFormfieldCreate"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl(); //FIXME missing props
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation)
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormResource1_8.java
index 9f0f015e0..3d90f9f50 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormResource1_8.java
@@ -9,6 +9,13 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.IntegerProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Form;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
@@ -89,6 +96,57 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ modelImpl
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("name", new StringProperty())
+ .property("description", new StringProperty())
+ .property("version", new StringProperty())
+ .property("build", new IntegerProperty())
+ .property("published", new BooleanProperty()._default(false))
+ .property("retired", new BooleanProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ modelImpl
+ .property("encounterType", new RefProperty("#/definitions/EncountertypeGetRef"))
+ .property("formFields", new ArrayProperty(new RefProperty("#/definitions/FormFormfieldGetRef")));
+ } else if (rep instanceof FullRepresentation) {
+ modelImpl
+ .property("encounterType", new RefProperty("#/definitions/EncountertypeGet"))
+ .property("formFields", new ArrayProperty(new RefProperty("#/definitions/FormFormfieldGet")));
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = ((ModelImpl) super.getCREATEModel(rep))
+ .property("version", new StringProperty())
+ .property("encounterType", new StringProperty())
+ .property("build", new IntegerProperty())
+ .property("published", new BooleanProperty()._default(false))
+ .property("formFields", new ArrayProperty(new StringProperty()))
+ .property("xslt", new StringProperty())
+ .property("template", new StringProperty())
+
+ .required("version");
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("encounterType", new RefProperty("#/definitions/EncountertypeCreate"))
+ .property("formFields", new ArrayProperty(new RefProperty("#/definitions/FormFormfieldCreate")));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String)
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7MessageResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7MessageResource1_8.java
index 144b50352..46e6cd5b9 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7MessageResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7MessageResource1_8.java
@@ -9,6 +9,11 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.IntegerProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.RestConstants;
@@ -90,6 +95,33 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation) {
+ modelImpl
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("messageState", new IntegerProperty());
+ } else if (rep instanceof FullRepresentation) {
+ modelImpl
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("source", new RefProperty("#/definitions/Hl7sourceGet"))
+ .property("sourceKey", new StringProperty())
+ .property("data", new StringProperty())
+ .property("messageState", new IntegerProperty());
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("hl7", new StringProperty()) //FIXME TYPE
+ .required("hl7");
+ }
+
/**
* It needs to be overwritten to allow for hidden properties: source, sourceKey and data. They
* are automatically extracted from the hl7 property and populated in
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7SourceResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7SourceResource1_8.java
index ca740067f..d52c09fde 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7SourceResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7SourceResource1_8.java
@@ -9,6 +9,8 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
import org.openmrs.api.context.Context;
import org.openmrs.hl7.HL7Source;
import org.openmrs.module.webservices.rest.web.RequestContext;
@@ -55,6 +57,23 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ return super.getGETModel(rep);
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+
+ .required("description");
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/LocationResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/LocationResource1_8.java
index b44a8ae05..201064c5b 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/LocationResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/LocationResource1_8.java
@@ -11,6 +11,11 @@
import java.util.List;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.apache.commons.collections.CollectionUtils;
import org.openmrs.Location;
import org.openmrs.LocationTag;
@@ -134,6 +139,65 @@ public DelegatingResourceDescription getUpdatableProperties() {
return getCreatableProperties();
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ modelImpl
+ .property("address1", new StringProperty())
+ .property("address2", new StringProperty())
+ .property("cityVillage", new StringProperty())
+ .property("stateProvince", new StringProperty())
+ .property("country", new StringProperty())
+ .property("postalCode", new StringProperty())
+ .property("latitude", new StringProperty())
+ .property("longitude", new StringProperty())
+ .property("countyDistrict", new StringProperty())
+ .property("address3", new StringProperty())
+ .property("address4", new StringProperty())
+ .property("address5", new StringProperty())
+ .property("address6", new StringProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ modelImpl
+ .property("tags", new ArrayProperty(new RefProperty("#/definitions/LocationtagGetRef")))
+ .property("parentLocation", new RefProperty("#/definitions/LocationGetRef"))
+ .property("childLocations", new ArrayProperty(new RefProperty("#/definitions/LocationGetRef")));
+ } else if (rep instanceof FullRepresentation) {
+ modelImpl
+ .property("tags", new ArrayProperty(new RefProperty("#/definitions/LocationtagGet")))
+ .property("parentLocation", new RefProperty("#/definitions/LocationGet"))
+ .property("childLocations", new ArrayProperty(new RefProperty("#/definitions/LocationGet")));
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .property("address1", new StringProperty())
+ .property("address2", new StringProperty())
+ .property("cityVillage", new StringProperty())
+ .property("stateProvince", new StringProperty())
+ .property("country", new StringProperty())
+ .property("postalCode", new StringProperty())
+ .property("latitude", new StringProperty())
+ .property("longitude", new StringProperty())
+ .property("countyDistrict", new StringProperty())
+ .property("address3", new StringProperty())
+ .property("address4", new StringProperty())
+ .property("address5", new StringProperty())
+ .property("address6", new StringProperty())
+ .property("tags", new ArrayProperty(new StringProperty()))
+ .property("parentLocation", new StringProperty())
+ .property("childLocations", new ArrayProperty(new StringProperty()));
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
/**
* @see DelegatingCrudResource#newDelegate()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/LocationTagResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/LocationTagResource1_8.java
index 3322710a6..65b49bf00 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/LocationTagResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/LocationTagResource1_8.java
@@ -9,6 +9,10 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.LocationTag;
import org.openmrs.api.LocationService;
import org.openmrs.api.context.Context;
@@ -89,6 +93,18 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ return super.getGETModel(rep);
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .property("retired", new BooleanProperty())
+ .property("retiredReason", new StringProperty());
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext)
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleActionResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleActionResource1_8.java
index b41f4ce25..8cc631c1a 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleActionResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleActionResource1_8.java
@@ -9,8 +9,15 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.module.Module;
import org.openmrs.module.ModuleException;
+import org.openmrs.module.webservices.docs.swagger.SwaggerSpecificationCreator;
import org.openmrs.module.webservices.helper.ModuleAction;
import org.openmrs.module.webservices.helper.ModuleFactoryWrapper;
import org.openmrs.module.webservices.rest.SimpleObject;
@@ -228,6 +235,25 @@ public DelegatingResourceDescription getCreatableProperties() throws ResourceDoe
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ return ((ModelImpl) super.getGETModel(rep))
+ .property("modules", new ArrayProperty(new RefProperty("#/definitions/ModuleGetRef")))
+ .property("action", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(ModuleAction.Action.class)));
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("modules", new ArrayProperty(new StringProperty().example("moduleId")))
+ .property("allModules", new BooleanProperty())
+ .property("action", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(ModuleAction.Action.class)))
+
+ .required("action");
+ }
+
/**
* Converter does not handle getters starting with 'is' instead of 'get'
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleResource1_8.java
index a39f354b6..b4e9a73c8 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleResource1_8.java
@@ -9,6 +9,11 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.StringProperty;
import org.apache.commons.io.FileUtils;
import org.openmrs.module.Module;
import org.openmrs.module.webservices.helper.ModuleFactoryWrapper;
@@ -101,6 +106,39 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("name", new StringProperty())
+ .property("description", new StringProperty())
+ .property("started", new BooleanProperty()) //FIXME check type
+ .property("startupErrorMessage", new StringProperty()); //FIXME add-link: action
+ }
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("packageName", new StringProperty())
+ .property("author", new StringProperty())
+ .property("version", new StringProperty())
+ .property("requireOpenmrsVersion", new StringProperty())
+ .property("awareOfModules", new ArrayProperty(new StringProperty())) //FIXME check type
+ .property("requiredModules", new ArrayProperty(new StringProperty()));
+ } else if (rep instanceof RefRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty());
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return null;
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext)
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ObsResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ObsResource1_8.java
index 06c798747..e4f13b4ec 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ObsResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ObsResource1_8.java
@@ -9,6 +9,14 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.DateProperty;
+import io.swagger.models.properties.DateTimeProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.apache.commons.lang.StringUtils;
import org.openmrs.Concept;
import org.openmrs.ConceptNumeric;
@@ -157,6 +165,69 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("obsDatetime", new DateProperty())
+ .property("accessionNumber", new StringProperty())
+ .property("comment", new StringProperty())
+ .property("voided", new BooleanProperty())
+ .property("value", new StringProperty())
+ .property("valueModifier", new StringProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("concept", new RefProperty("#/definitions/ConceptGetRef"))
+ .property("person", new RefProperty("#/definitions/PersonGetRef"))
+ .property("obsGroup", new RefProperty("#/definitions/ObsGetRef"))
+ .property("groupMembers", new ArrayProperty(new RefProperty("#/definitions/ObsGetRef")))
+ .property("valueCodedName", new RefProperty("#/definitions/ConceptNameGetRef"))
+ .property("location", new RefProperty("#/definitions/LocationGetRef"))
+ .property("order", new RefProperty("#/definitions/OrderGetRef"))
+ .property("encounter", new RefProperty("#/definitions/EncounterGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("concept", new RefProperty("#/definitions/ConceptGet"))
+ .property("person", new RefProperty("#/definitions/PersonGet"))
+ .property("obsGroup", new RefProperty("#/definitions/ObsGet"))
+ .property("groupMembers", new ArrayProperty(new RefProperty("#/definitions/ObsGet")))
+ .property("valueCodedName", new RefProperty("#/definitions/ConceptNameGet"))
+ .property("location", new RefProperty("#/definitions/LocationGet"))
+ .property("order", new RefProperty("#/definitions/OrderGet"))
+ .property("encounter", new RefProperty("#/definitions/EncounterGet"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("person", new StringProperty().example("uuid"))
+ .property("obsDatetime", new DateTimeProperty())
+ .property("concept", new StringProperty().example("uuid"))
+ .property("location", new StringProperty())
+ .property("order", new StringProperty())
+ .property("encounter", new StringProperty())
+ .property("accessionNumber", new StringProperty())
+ .property("groupMembers", new ArrayProperty(new StringProperty()))
+ .property("valueCodedName", new StringProperty())
+ .property("comment", new StringProperty())
+ .property("voided", new BooleanProperty())
+ .property("value", new StringProperty())
+ .property("valueModifier", new StringProperty())
+
+ .required("person").required("obsDatetime").required("concept");
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl(); //FIXME missing props
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderResource1_8.java
index 87187d597..b70ff08d8 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderResource1_8.java
@@ -11,6 +11,12 @@
import java.util.List;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.DateProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Order;
import org.openmrs.Patient;
import org.openmrs.api.OrderService.ORDER_STATUS;
@@ -192,6 +198,80 @@ public DelegatingResourceDescription getCreatableProperties() {
return d;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("instructions", new StringProperty())
+ .property("startDate", new DateProperty())
+ .property("autoExpireDate", new DateProperty())
+ .property("accessionNumber", new StringProperty())
+ .property("discontinuedDate", new DateProperty())
+ .property("discontinuedReasonNonCoded", new StringProperty())
+ .property("voided", new BooleanProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("orderType", new RefProperty("#/definitions/OrdertypeGetRef"))
+ .property("patient", new RefProperty("#/definitions/PatientGetRef"))
+ .property("concept", new RefProperty("#/definitions/ConceptGetRef"))
+ .property("encounter", new RefProperty("#/definitions/EncounterGetRef"))
+ .property("orderer", new RefProperty("#/definitions/UserGetRef"))
+ .property("discontinuedBy", new RefProperty("#/definitions/UserGetRef"))
+ .property("discontinuedReason", new RefProperty("#/definitions/ConceptGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("orderType", new RefProperty("#/definitions/OrdertypeGet"))
+ .property("patient", new RefProperty("#/definitions/PatientGet"))
+ .property("concept", new RefProperty("#/definitions/ConceptGet"))
+ .property("encounter", new RefProperty("#/definitions/EncounterGet"))
+ .property("orderer", new RefProperty("#/definitions/UserGet"))
+ .property("discontinuedBy", new RefProperty("#/definitions/UserGet"))
+ .property("discontinuedReason", new RefProperty("#/definitions/ConceptGet"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = new ModelImpl()
+ .property("orderType", new StringProperty().example("uuid"))
+ .property("patient", new StringProperty().example("uuid"))
+ .property("concept", new StringProperty().example("uuid"))
+ .property("instructions", new StringProperty())
+ .property("startDate", new DateProperty())
+ .property("autoExpireDate", new DateProperty())
+ .property("encounter", new StringProperty().example("uuid"))
+ .property("orderer", new StringProperty().example("uuid"))
+ .property("discontinuedBy", new StringProperty().example("uuid"))
+ .property("discontinuedDate", new DateProperty())
+ .property("discontinuedReason", new RefProperty("#/definitions/ConceptCreate"))
+ .property("discontinuedReasonNonCoded", new StringProperty())
+ .property("accessionNumber", new StringProperty())
+
+ .required("orderType").required("patient").required("concept");
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("orderType", new RefProperty("#/definitions/OrdertypeCreate"))
+ .property("patient", new RefProperty("#/definitions/PatientCreate"))
+ .property("concept", new RefProperty("#/definitions/ConceptCreate"))
+ .property("encounter", new RefProperty("#/definitions/EncounterCreate"))
+ .property("orderer", new RefProperty("#/definitions/UserCreate"))
+ .property("discontinuedBy", new RefProperty("#/definitions/UserCreate"))
+ .property("discontinuedReason", new RefProperty("#/definitions/ConceptCreate"));
+ }
+ //FIXME missing prop: type
+ return model;
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl(); //FIXME missing props
+ }
+
/**
* Gets orders by given patient (paged according to context if necessary) only if a patient
* parameter exists in the request set on the {@link RequestContext} otherwise
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderTypeResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderTypeResource1_8.java
index fc07ebd67..c06e9b6e0 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderTypeResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderTypeResource1_8.java
@@ -60,5 +60,4 @@ public void purge(OrderType delegate, RequestContext context) throws ResponseExc
}
Context.getOrderService().purgeOrderType(delegate);
}
-
}
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierResource1_8.java
index 61abc3cbc..9886a15e7 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierResource1_8.java
@@ -10,6 +10,11 @@
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
import org.apache.commons.lang3.StringUtils;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Location;
import org.openmrs.Patient;
import org.openmrs.PatientIdentifier;
@@ -128,6 +133,51 @@ public DelegatingResourceDescription getUpdatableProperties() {
return getCreatableProperties();
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("identifier", new StringProperty())
+ .property("preferred", new BooleanProperty()._default(false))
+ .property("voided", new BooleanProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("identifierType", new RefProperty("#/definitions/PatientidentifiertypeGetRef"))
+ .property("location", new RefProperty("#/definitions/LocationGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("identifierType", new RefProperty("#/definitions/PatientidentifiertypeGet"))
+ .property("location", new RefProperty("#/definitions/LocationGet"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = new ModelImpl()
+ .property("identifier", new StringProperty())
+ .property("identifierType", new StringProperty().example("uuid"))
+ .property("location", new StringProperty().example("uuid"))
+ .property("preferred", new BooleanProperty()._default(false))
+
+ .required("identifier").required("identifierType");
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("identifierType", new RefProperty("#/definitions/PatientidentifiertypeCreate"))
+ .property("location", new RefProperty("#/definitions/LocationCreate"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
private PatientService service() {
return Context.getPatientService();
}
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierTypeResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierTypeResource1_8.java
index 2051525f0..ae7f03706 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierTypeResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierTypeResource1_8.java
@@ -9,9 +9,14 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.PatientIdentifierType;
import org.openmrs.api.PatientService;
import org.openmrs.api.context.Context;
+import org.openmrs.module.webservices.docs.swagger.SwaggerSpecificationCreator;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
@@ -74,7 +79,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
description.addProperty("validator");
description.addProperty("locationBehavior");
description.addProperty("uniquenessBehavior");
- description.addProperty("validator");
+ description.addProperty("validator"); //FIXME duplicate
description.addProperty("retired");
description.addProperty("auditInfo");
description.addSelfLink();
@@ -110,6 +115,41 @@ public DelegatingResourceDescription getUpdatableProperties() {
return getCreatableProperties();
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("format", new StringProperty())
+ .property("formatDescription", new StringProperty())
+ .property("required", new BooleanProperty())
+ .property("checkDigit", new BooleanProperty())
+ .property("validator", new StringProperty())
+ .property("locationBehavior", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(PatientIdentifierType.LocationBehavior.class)))
+ .property("uniquenessBehavior", new StringProperty()); //FIXME check type
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .property("format", new StringProperty())
+ .property("formatDescription", new StringProperty())
+ .property("required", new BooleanProperty())
+ .property("checkDigit", new BooleanProperty())
+ .property("validator", new StringProperty())
+ .property("locationBehavior", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(PatientIdentifierType.LocationBehavior.class)))
+ .property("uniquenessBehavior", new StringProperty()); //FIXME check type
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String)
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientResource1_8.java
index a1b8c9f39..5ebbecbcc 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientResource1_8.java
@@ -9,12 +9,12 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
-import java.util.Arrays;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Patient;
import org.openmrs.PatientIdentifier;
import org.openmrs.Person;
@@ -40,6 +40,12 @@
import org.openmrs.module.webservices.rest.web.response.ResponseException;
import org.openmrs.module.webservices.validation.ValidateUtil;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
/**
* {@link Resource} for Patients, supporting standard CRUD operations
*/
@@ -136,6 +142,50 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ //FIXME check uuid, display in ref rep
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("identifiers", new ArrayProperty(new RefProperty("#/definitions/PatientIdentifierGetRef")))
+ .property("preferred", new BooleanProperty()._default(false))
+ .property("voided", new BooleanProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("person", new RefProperty("#/definitions/PersonGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("person", new RefProperty("#/definitions/PersonGet"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = new ModelImpl()
+ .property("person", new StringProperty().example("uuid"))
+ .property("identifiers", new ArrayProperty(new RefProperty("#/definitions/PatientIdentifierCreate")))
+
+ .required("person").required("identifiers");
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("person", new RefProperty("#/definitions/PersonCreate"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("person", new RefProperty("#/definitions/PersonGet"))
+
+ .required("person");
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientStateResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientStateResource1_8.java
index 9d8d187ce..785dd80da 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientStateResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientStateResource1_8.java
@@ -9,6 +9,13 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.DateProperty;
+import io.swagger.models.properties.ObjectProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.PatientProgram;
import org.openmrs.PatientState;
import org.openmrs.ProgramWorkflow;
@@ -170,4 +177,45 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe
updatableProperties.addProperty("voided");
return updatableProperties;
}
+
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof RefRepresentation || rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("startDate", new DateProperty())
+ .property("endDate", new DateProperty())
+ .property("voided", new BooleanProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("state", new RefProperty("#/definitions/WorkflowStateGet"));
+ } else if (rep instanceof RefRepresentation) {
+ model
+ .property("state", new RefProperty("#/definitions/WorkflowStateGetRef"))
+ .property("patientProgram", new ObjectProperty()); //FIXME type
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("state", new RefProperty("#/definitions/WorkflowStateGetRef"))
+ .property("patientProgram", new ObjectProperty()); //FIXME type
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("state", new RefProperty("#/definitions/WorkflowStateCreate"))
+
+ .required("state");
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("startDate", new DateProperty())
+ .property("endDate", new DateProperty())
+ .property("voided", new BooleanProperty());
+ }
}
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAddressResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAddressResource1_8.java
index b0a849f01..9a74cd322 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAddressResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAddressResource1_8.java
@@ -9,6 +9,11 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.DateProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Person;
import org.openmrs.PersonAddress;
import org.openmrs.api.context.Context;
@@ -135,6 +140,61 @@ public DelegatingResourceDescription getUpdatableProperties() {
return getCreatableProperties();
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = ((ModelImpl) super.getGETModel(rep))
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty());
+
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("preferred", new BooleanProperty()._default(false))
+ .property("address1", new StringProperty())
+ .property("address2", new StringProperty())
+ .property("cityVillage", new StringProperty())
+ .property("stateProvince", new StringProperty())
+ .property("country", new StringProperty())
+ .property("postalCode", new StringProperty())
+ .property("countyDistrict", new StringProperty())
+ .property("address3", new StringProperty())
+ .property("address4", new StringProperty())
+ .property("address5", new StringProperty())
+ .property("address6", new StringProperty())
+ .property("startDate", new DateProperty())
+ .property("endDate", new DateProperty())
+ .property("latitude", new StringProperty())
+ .property("longitude", new StringProperty())
+ .property("voided", new BooleanProperty());
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("preferred", new BooleanProperty()._default(false))
+ .property("address1", new StringProperty())
+ .property("address2", new StringProperty())
+ .property("cityVillage", new StringProperty())
+ .property("stateProvince", new StringProperty())
+ .property("country", new StringProperty())
+ .property("postalCode", new StringProperty())
+ .property("countyDistrict", new StringProperty())
+ .property("address3", new StringProperty())
+ .property("address4", new StringProperty())
+ .property("address5", new StringProperty())
+ .property("address6", new StringProperty())
+ .property("startDate", new DateProperty())
+ .property("endDate", new DateProperty())
+ .property("latitude", new StringProperty())
+ .property("longitude", new StringProperty());
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String)
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeResource1_8.java
index 75aac04fc..34d99d35a 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeResource1_8.java
@@ -9,6 +9,11 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Attributable;
import org.openmrs.Concept;
import org.openmrs.Person;
@@ -139,6 +144,48 @@ public DelegatingResourceDescription getUpdatableProperties() {
return getCreatableProperties();
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("display", new StringProperty())
+ .property("uuid", new StringProperty())
+ .property("value", new StringProperty())
+ .property("attributeType", new RefProperty("#/definitions/PersonattributetypeGetRef"))
+ .property("voided", new BooleanProperty());
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("display", new StringProperty())
+ .property("uuid", new StringProperty())
+ .property("value", new StringProperty())
+ .property("attributeType", new RefProperty("#/definitions/PersonattributetypeGetRef"))
+ .property("voided", new BooleanProperty())
+ .property("hydratedObject", new StringProperty());
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = new ModelImpl()
+ .property("attributeType", new StringProperty().example("uuid"))
+ .property("value", new StringProperty())
+ .property("hydratedObject", new StringProperty().example("uuid"))
+
+ .required("attributeType");
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("attributeType", new RefProperty("#/definitions/PersonattributetypeCreate"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#getParent(java.lang.Object)
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeTypeResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeTypeResource1_8.java
index 15025dcd1..b64a11315 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeTypeResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeTypeResource1_8.java
@@ -9,6 +9,13 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.DoubleProperty;
+import io.swagger.models.properties.IntegerProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Concept;
import org.openmrs.PersonAttributeType;
import org.openmrs.api.PersonService;
@@ -106,6 +113,44 @@ public DelegatingResourceDescription getUpdatableProperties() {
return getCreatableProperties();
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("format", new StringProperty())
+ .property("foreignKey", new IntegerProperty())
+ .property("sortWeight", new DoubleProperty())
+ .property("searchable", new BooleanProperty()._default(false));
+ }
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("editPrivilege", new RefProperty("#/definitions/PrivilegeGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("editPrivilege", new RefProperty("#/definitions/PrivilegeGet"))
+ .property("concept", new StringProperty());
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .property("format", new StringProperty().example("java.lang.String"))
+ .property("foreignKey", new IntegerProperty())
+ .property("sortWeight", new DoubleProperty())
+ .property("searchable", new BooleanProperty()._default(false))
+ .property("editPrivilege", new RefProperty("#/definitions/PrivilegeCreate"))
+
+ .required("description");
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String)
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonNameResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonNameResource1_8.java
index 140121701..fe65dfd94 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonNameResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonNameResource1_8.java
@@ -9,11 +9,10 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Person;
import org.openmrs.PersonName;
import org.openmrs.api.context.Context;
@@ -32,6 +31,11 @@
import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging;
import org.openmrs.module.webservices.rest.web.response.ResponseException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
/**
* {@link Resource} for PersonNames, supporting standard CRUD operations
*/
@@ -101,6 +105,51 @@ public DelegatingResourceDescription getUpdatableProperties() {
return getCreatableProperties();
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("display", new StringProperty())
+ .property("uuid", new StringProperty())
+ .property("givenName", new StringProperty())
+ .property("middleName", new StringProperty())
+ .property("familyName", new StringProperty())
+ .property("familyName2", new StringProperty())
+ .property("voided", new BooleanProperty());
+ }
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("preferred", new BooleanProperty())
+ .property("prefix", new StringProperty())
+ .property("familyNamePrefix", new StringProperty())
+ .property("familyNameSuffix", new StringProperty())
+ .property("degree", new StringProperty());
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("givenName", new StringProperty())
+ .property("middleName", new StringProperty())
+ .property("familyName", new StringProperty())
+ .property("familyName2", new StringProperty())
+ .property("preferred", new BooleanProperty()._default(false))
+ .property("prefix", new StringProperty())
+ .property("familyNamePrefix", new StringProperty())
+ .property("familyNameSuffix", new StringProperty())
+ .property("degree", new StringProperty())
+
+ .required("givenName").required("familyName");
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#getParent(java.lang.Object)
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonResource1_8.java
index 4c7d54b6d..18d29b360 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonResource1_8.java
@@ -14,6 +14,15 @@
import java.util.List;
import java.util.Set;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.DateProperty;
+import io.swagger.models.properties.DateTimeProperty;
+import io.swagger.models.properties.IntegerProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Person;
import org.openmrs.PersonAddress;
import org.openmrs.PersonAttribute;
@@ -133,6 +142,73 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("gender", new StringProperty()._enum("M")._enum("F"))
+ .property("age", new IntegerProperty())
+ .property("birthdate", new DateTimeProperty())
+ .property("birthdateEstimated", new BooleanProperty())
+ .property("dead", new BooleanProperty())
+ .property("deathDate", new DateProperty())
+ .property("causeOfDeath", new StringProperty())
+ .property("attributes", new ArrayProperty(new RefProperty("#/definitions/PersonAttributeGetRef")))
+ .property("voided", new BooleanProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("preferredName", new RefProperty("#/definitions/PersonNameGetRef"))
+ .property("preferredAddress", new RefProperty("#/definitions/PersonAddressGetRef"));
+
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("preferredName", new RefProperty("#/definitions/PersonNameGet"))
+ .property("preferredAddress", new RefProperty("#/definitions/PersonAddressGet"))
+ .property("names", new ArrayProperty(new RefProperty("#/definitions/PersonNameGet")))
+ .property("addresses", new ArrayProperty(new RefProperty("#/definitions/PersonAddressGet")));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation representation) {
+ ModelImpl model = new ModelImpl()
+ .property("names", new ArrayProperty(new RefProperty("#/definitions/PersonNameCreate")))
+ .property("gender", new StringProperty()._enum("M")._enum("F"))
+ .property("age", new IntegerProperty())
+ .property("birthdate", new DateProperty())
+ .property("birthdateEstimated", new BooleanProperty()._default(false))
+ .property("dead", new BooleanProperty()._default(false))
+ .property("deathDate", new DateProperty())
+ .property("causeOfDeath", new StringProperty())
+ .property("addresses", new ArrayProperty(new RefProperty("#/definitions/PersonAddressCreate")))
+ .property("attributes", new ArrayProperty(new RefProperty("#/definitions/PersonAttributeCreate")));
+
+ model.setRequired(Arrays.asList("names", "gender"));
+ return model;
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation representation) {
+ return new ModelImpl()
+ .property("dead", new BooleanProperty())
+ .property("causeOfDeath", new StringProperty())
+ .property("deathDate", new DateProperty())
+ .property("age", new IntegerProperty())
+ .property("gender", new StringProperty()._enum("M")._enum("F"))
+ .property("birthdate", new DateProperty())
+ .property("birthdateEstimated", new BooleanProperty()._default(false))
+ .property("preferredName", new StringProperty().example("uuid"))
+ .property("preferredAddress", new StringProperty().example("uuid"))
+ .property("attributes", new ArrayProperty(new RefProperty("#/definitions/PersonAttributeCreate")))
+
+ .required("dead").required("causeOfDeath");
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getPropertiesToExposeAsSubResources()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PrivilegeResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PrivilegeResource1_8.java
index 01bb9da10..44e304e78 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PrivilegeResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PrivilegeResource1_8.java
@@ -9,6 +9,9 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.StringProperty;
import org.apache.commons.lang.StringUtils;
import org.openmrs.Privilege;
import org.openmrs.api.context.Context;
@@ -90,6 +93,22 @@ public DelegatingResourceDescription getUpdatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ return super.getGETModel(rep); //FIXME
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return super.getCREATEModel(rep);
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("description", new StringProperty());
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProblemResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProblemResource1_8.java
index ac55a39be..6cc88c2c7 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProblemResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProblemResource1_8.java
@@ -9,9 +9,16 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.DoubleProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Patient;
import org.openmrs.activelist.Problem;
+import org.openmrs.activelist.ProblemModifier;
import org.openmrs.api.context.Context;
+import org.openmrs.module.webservices.docs.swagger.SwaggerSpecificationCreator;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter;
@@ -32,6 +39,27 @@
@Resource(name = RestConstants.VERSION_1 + "/problem", supportedClass = Problem.class, supportedOpenmrsVersions = { "1.8.*" })
public class ProblemResource1_8 extends BaseActiveListItemResource1_8 {
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("modifier", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(ProblemModifier.class)))
+ .property("sortWeight", new DoubleProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("problem", new RefProperty("#/definitions/ConceptGetRef"));
+
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("problem", new RefProperty("#/definitions/ConceptGet"));
+
+ }
+ return model;
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation)
*/
@@ -66,6 +94,17 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .property("problem", new RefProperty("#/definitions/ConceptCreate"))
+ .property("modifier", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(ProblemModifier.class)))
+ .property("sortWeight", new DoubleProperty())
+
+ .required("problem");
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramEnrollmentResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramEnrollmentResource1_8.java
index a5e67b9f3..6d74cebb0 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramEnrollmentResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramEnrollmentResource1_8.java
@@ -9,6 +9,12 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.DateProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Patient;
import org.openmrs.PatientProgram;
import org.openmrs.api.PatientService;
@@ -112,6 +118,59 @@ public DelegatingResourceDescription getCreatableProperties() {
return d;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("dateEnrolled", new DateProperty())
+ .property("dateCompleted", new DateProperty())
+ .property("voided", new BooleanProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("patient", new RefProperty("#/definitions/PatientGetRef"))
+ .property("program", new RefProperty("#/definitions/ProgramGetRef"))
+ .property("location", new RefProperty("#/definitions/LocationGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("patient", new RefProperty("#/definitions/PatientGet"))
+ .property("program", new RefProperty("#/definitions/ProgramGet"))
+ .property("location", new RefProperty("#/definitions/LocationGet"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = new ModelImpl()
+ .property("patient", new StringProperty().example("uuid"))
+ .property("program", new StringProperty().example("uuid"))
+ .property("dateEnrolled", new DateProperty())
+ .property("dateCompleted", new DateProperty())
+ .property("location", new StringProperty().example("uuid"))
+ .property("voided", new BooleanProperty())
+
+ .required("patient").required("program").required("dateEnrolled");
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("patient", new RefProperty("#/definitions/PatientCreate"))
+ .property("program", new RefProperty("#/definitions/ProgramCreate"))
+ .property("location", new RefProperty("#/definitions/LocationCreate"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("dateEnrolled", new DateProperty())
+ .property("dateCompleted", new DateProperty()); //FIXME missing props
+
+ }
+
/**
* Gets all the programs (excluding voided) of the given patient
*
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramResource1_8.java
index e9858c4fa..189c6f132 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramResource1_8.java
@@ -9,6 +9,12 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Program;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
@@ -107,6 +113,43 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("concept", new RefProperty("#/definitions/ConceptGetRef"))
+ .property("allWorkflows", new ArrayProperty(new RefProperty("#/definitions/WorkflowGetRef")));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("concept", new RefProperty("#/definitions/ConceptGet"))
+ .property("allWorkflows", new ArrayProperty(new RefProperty("#/definitions/WorkflowGet")));
+ } else if (rep instanceof RefRepresentation) {
+ model
+ .property("allWorkflows", new ArrayProperty(new RefProperty("#/definitions/WorkflowGetRef")));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = ((ModelImpl) super.getCREATEModel(rep))
+ .property("concept", new StringProperty().example("uuid"))
+ .property("retired", new BooleanProperty())
+
+ .required("concept").required("description");
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("concept", new RefProperty("#/definitions/ConceptCreate"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl(); //FIXME missing props
+ }
+
@Override
protected PageableResult doSearch(RequestContext context) {
String query = context.getParameter("q");
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowResource1_8.java
index 022879872..2f1bf4040 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowResource1_8.java
@@ -9,6 +9,10 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.RefProperty;
import org.openmrs.Program;
import org.openmrs.ProgramWorkflow;
import org.openmrs.api.context.Context;
@@ -63,6 +67,26 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("concept", new RefProperty("#/definitions/ConceptGetRef"))
+ .property("states", new ArrayProperty(new RefProperty("#/definitions/WorkflowStateGetRef")));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("concept", new RefProperty("#/definitions/ConceptGet"))
+ .property("states", new ArrayProperty(new RefProperty("#/definitions/WorkflowStateGet")));
+ } else if (rep instanceof RefRepresentation) {
+ model
+ .property("concept", new RefProperty("#/definitions/ConceptGet"))
+ .property("states", new ArrayProperty(new RefProperty("#/definitions/WorkflowStateGet")));
+ //FIXME should remove 'description'?
+ }
+ return model;
+ }
+
@Override
public ProgramWorkflow getByUniqueId(String uniqueId) {
return Context.getProgramWorkflowService().getWorkflowByUuid(uniqueId);
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowStateResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowStateResource1_8.java
index e989b246a..f73671969 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowStateResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowStateResource1_8.java
@@ -9,6 +9,11 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Program;
import org.openmrs.ProgramWorkflow;
import org.openmrs.ProgramWorkflowState;
@@ -114,4 +119,33 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
}
return null;
}
+
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("description", new StringProperty())
+ .property("retired", new BooleanProperty())
+ .property("concept", new RefProperty("#/definitions/ConceptGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("description", new StringProperty())
+ .property("retired", new BooleanProperty())
+ .property("concept", new RefProperty("#/definitions/ConceptGet"));
+ } else if (rep instanceof RefRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("retired", new BooleanProperty())
+ .property("concept", new RefProperty("#/definitions/ConceptGetRef"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl(); //FIXME missing props
+ }
}
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationShipTypeResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationShipTypeResource1_8.java
index b9fe4283b..4e80256bb 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationShipTypeResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationShipTypeResource1_8.java
@@ -10,6 +10,10 @@
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
import org.apache.commons.lang.StringUtils;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.IntegerProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.RelationshipType;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
@@ -121,6 +125,36 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("aIsToB", new StringProperty())
+ .property("bIsToA", new StringProperty());
+ }
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("weight", new IntegerProperty());
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .property("aIsToB", new StringProperty())
+ .property("bIsToA", new StringProperty())
+ .property("weight", new IntegerProperty())
+
+ .required("aIsToB").required("bIsToA");
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl(); //FIXME missing props
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext)
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationshipResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationshipResource1_8.java
index e504c76b6..7df0c6337 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationshipResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationshipResource1_8.java
@@ -9,6 +9,12 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.DateProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Person;
import org.openmrs.Relationship;
import org.openmrs.api.context.Context;
@@ -145,4 +151,53 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe
description.addProperty("voided");
return description;
}
+
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("voided", new BooleanProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("personA", new RefProperty("#/definitions/PersonGetRef"))
+ .property("relationshipType", new RefProperty("#/definitions/RelationshiptypeGetRef"))
+ .property("personB", new RefProperty("#/definitions/PersonGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("personA", new RefProperty("#/definitions/PersonGet"))
+ .property("relationshipType", new RefProperty("#/definitions/RelationshiptypeGet"))
+ .property("personB", new RefProperty("#/definitions/PersonGet"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = new ModelImpl()
+ .property("personA", new StringProperty().example("uuid"))
+ .property("relationshipType", new StringProperty().example("uuid"))
+ .property("personB", new StringProperty().example("uuid"))
+ .property("startDate", new DateProperty())
+ .property("endDate", new DateProperty())
+
+ .required("personA").required("relationshipType").required("personB");
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("personA", new RefProperty("#/definitions/PersonCreate"))
+
+ .property("relationshipType", new RefProperty("#/definitions/RelationshiptypeCreate"))
+ .property("personB", new RefProperty("#/definitions/PersonCreate"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("voided", new BooleanProperty()); //FIXME missing properties
+ }
}
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RoleResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RoleResource1_8.java
index 3d51b6f0f..e96d90f01 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RoleResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RoleResource1_8.java
@@ -9,6 +9,11 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.apache.commons.lang.StringUtils;
import org.openmrs.Privilege;
import org.openmrs.Role;
@@ -121,6 +126,38 @@ public DelegatingResourceDescription getUpdatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("privileges", new ArrayProperty(new RefProperty("#/definitions/PrivilegeGetRef")))
+ .property("inheritedRoles", new ArrayProperty(new RefProperty("#/definitions/RoleGetRef")));
+ }
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("privileges", new ArrayProperty(new RefProperty("#/definitions/PrivilegeGet")))
+ .property("inheritedRoles", new ArrayProperty(new RefProperty("#/definitions/RoleGet")))
+ .property("allInheritedRoles", new ArrayProperty(new RefProperty("#/definitions/RoleGet")));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .property("privileges", new ArrayProperty(new RefProperty("#/definitions/PrivilegeCreate")))
+ .property("inheritedRoles", new ArrayProperty(new RefProperty("#/definitions/RoleCreate")));
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("description", new StringProperty())
+ .property("privileges", new ArrayProperty(new RefProperty("#/definitions/PrivilegeCreate")))
+ .property("inheritedRoles", new ArrayProperty(new RefProperty("#/definitions/RoleCreate")));
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties()
*/
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/UserResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/UserResource1_8.java
index d55932a00..4a00e2a76 100644
--- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/UserResource1_8.java
+++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/UserResource1_8.java
@@ -16,6 +16,13 @@
import java.util.List;
import java.util.Set;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.MapProperty;
+import io.swagger.models.properties.ObjectProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang.StringUtils;
import org.openmrs.Role;
@@ -127,6 +134,48 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ //FIXME check valid supportedClass
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("username", new StringProperty())
+ .property("systemId", new StringProperty())
+ .property("userProperties", new MapProperty()); //FIXME type
+ }
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("person", new RefProperty("#/definitions/PersonGetRef"))
+ .property("privileges", new ArrayProperty(new RefProperty("#/definitions/PrivilegeGetRef")))
+ .property("roles", new ArrayProperty(new RefProperty("#/definitions/RoleGetRef")));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("person", new RefProperty("#/definitions/PersonGet"))
+ .property("privileges", new ArrayProperty(new RefProperty("#/definitions/PrivilegeGet")))
+ .property("roles", new ArrayProperty(new RefProperty("#/definitions/RoleGet")))
+ .property("allRoles", new ArrayProperty(new RefProperty("#/definitions/RoleGet")))
+ .property("proficientLocales", new ArrayProperty(new ObjectProperty()))
+ .property("secretQuestion", new StringProperty());
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .property("username", new StringProperty())
+ .property("password", new StringProperty())
+ .property("person", new RefProperty("#/definitions/PersonCreate"))
+ .property("systemId", new StringProperty())
+ .property("userProperties", new MapProperty()) //FIXME type
+ .property("roles", new ArrayProperty(new RefProperty("#/definitions/RoleCreate")))
+ .property("proficientLocales", new ArrayProperty(new ObjectProperty()))
+ .property("secretQuestion", new StringProperty())
+
+ .required("username").required("password").required("person");
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#newDelegate()
*/
diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/HivDrugOrderSubclassHandler.java b/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/HivDrugOrderSubclassHandler.java
index bc3ce3f8b..29bc81d9c 100644
--- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/HivDrugOrderSubclassHandler.java
+++ b/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/HivDrugOrderSubclassHandler.java
@@ -9,6 +9,11 @@
*/
package org.openmrs.module.webservices.rest.web;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.DateProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Order;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter;
@@ -82,6 +87,40 @@ public DelegatingResourceDescription getCreatableProperties() throws ResourceDoe
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = new ModelImpl();
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("startDate", new DateProperty())
+ .property("autoExpireDate", new DateProperty())
+ .property("standardRegimenCode", new StringProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("patient", new RefProperty("#/definitions/PatientGetRef"))
+ .property("concept", new RefProperty("#/definitions/ConceptGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("patient", new RefProperty("#/definitions/PatientGet"))
+ .property("concept", new RefProperty("#/definitions/ConceptGet"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("patient", new StringProperty().example("uuid"))
+ .property("concept", new StringProperty().example("uuid"))
+ .property("startDate", new DateProperty())
+ .property("autoExpireDate", new DateProperty())
+ .property("standardRegimenCode", new StringProperty())
+ .property("instructions", new StringProperty())
+
+ .required("patient").required("concept");
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#getAllByType(org.openmrs.module.webservices.rest.web.RequestContext)
*/
diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/BaseAttributeCrudResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/BaseAttributeCrudResource1_9.java
index bd9dfd5fd..d9f0b6ab1 100644
--- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/BaseAttributeCrudResource1_9.java
+++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/BaseAttributeCrudResource1_9.java
@@ -12,6 +12,10 @@
import java.util.Arrays;
import java.util.List;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.StringProperty;
import org.apache.commons.lang.StringUtils;
import org.openmrs.attribute.Attribute;
import org.openmrs.customdatatype.CustomDatatype;
@@ -104,6 +108,29 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("attributeType", new StringProperty().example("uuid"))
+ .property("value", new StringProperty())
+
+ .required("attributeType").required("value");
+ }
+
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("display", new StringProperty())
+ .property("uuid", new StringProperty())
+ .property("attributeType", new StringProperty()) //FIXME type
+ .property("value", new StringProperty()) //FIXME type
+ .property("voided", new BooleanProperty());
+ }
+ return model;
+ }
+
/**
* Gets the display string for an attribute.
*
diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/BaseAttributeTypeCrudResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/BaseAttributeTypeCrudResource1_9.java
index 59c8b6667..0fd108aba 100644
--- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/BaseAttributeTypeCrudResource1_9.java
+++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/BaseAttributeTypeCrudResource1_9.java
@@ -9,6 +9,10 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.IntegerProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.attribute.AttributeType;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation;
@@ -25,6 +29,38 @@
*/
public abstract class BaseAttributeTypeCrudResource1_9> extends MetadataDelegatingCrudResource {
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("minOccurs", new IntegerProperty())
+ .property("maxOccurs", new IntegerProperty())
+ .property("datatypeClassname", new StringProperty())
+ .property("preferredHandlerClassname", new StringProperty());
+ }
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("datatypeConfig", new StringProperty())
+ .property("handlerConfig", new StringProperty());
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .property("datatypeClassname", new StringProperty())
+ .property("minOccurs", new IntegerProperty())
+ .property("maxOccurs", new IntegerProperty())
+ .property("datatypeConfig", new StringProperty())
+ .property("preferredHandlerClassname", new StringProperty())
+ .property("handlerConfig", new StringProperty())
+
+ .required("datatypeClassname");
+
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation)
*/
diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptMapResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptMapResource1_9.java
index 795c6bc53..ee167fdbb 100644
--- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptMapResource1_9.java
+++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptMapResource1_9.java
@@ -9,6 +9,9 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.RefProperty;
import org.apache.commons.lang.StringUtils;
import org.openmrs.ConceptMap;
import org.openmrs.module.webservices.rest.web.RestConstants;
@@ -53,6 +56,33 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("conceptReferenceTerm", new RefProperty("#/definitions/ConceptreferencetermGetRef"))
+ .property("conceptMapType", new RefProperty("#/definitions/ConceptmaptypeGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("conceptReferenceTerm", new RefProperty("#/definitions/ConceptreferencetermGet"))
+ .property("conceptMapType", new RefProperty("#/definitions/ConceptmaptypeGet"));
+ }
+ model.getProperties().remove("source"); //FIXME check
+ model.getProperties().remove("sourceCode");
+ model.getProperties().remove("comment");
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation representation) {
+ return new ModelImpl()
+ .property("conceptReferenceTerm", new RefProperty("#/definitions/ConceptreferencetermCreate"))
+ .property("conceptMapType", new RefProperty("#/definitions/ConceptmaptypeCreate"))
+
+ .required("conceptReferenceTerm").required("conceptMapType");
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties()
*/
diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptMapTypeResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptMapTypeResource1_9.java
index 9cac8a74f..f46180556 100644
--- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptMapTypeResource1_9.java
+++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptMapTypeResource1_9.java
@@ -9,6 +9,9 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
import org.openmrs.ConceptMapType;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
@@ -79,6 +82,22 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("isHidden", new BooleanProperty());
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .property("isHidden", new BooleanProperty());
+ }
+
/**
* @see DelegatingCrudResource#newDelegate()
*/
diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptReferenceTermMapResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptReferenceTermMapResource1_9.java
index 8540f7208..aba5330f4 100644
--- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptReferenceTermMapResource1_9.java
+++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptReferenceTermMapResource1_9.java
@@ -9,6 +9,9 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.RefProperty;
import org.openmrs.ConceptReferenceTerm;
import org.openmrs.ConceptReferenceTermMap;
import org.openmrs.api.context.Context;
@@ -84,6 +87,38 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("termA", new RefProperty("#/definitions/ConceptreferencetermGetRef"))
+ .property("termB", new RefProperty("#/definitions/ConceptreferencetermGetRef"))
+ .property("conceptMapType", new RefProperty("#/definitions/ConceptmaptypeGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("termA", new RefProperty("#/definitions/ConceptreferencetermGet"))
+ .property("termB", new RefProperty("#/definitions/ConceptreferencetermGet"))
+ .property("conceptMapType", new RefProperty("#/definitions/ConceptmaptypeGet"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("termA", new RefProperty("#/definitions/ConceptreferencetermCreate"))
+ .property("termB", new RefProperty("#/definitions/ConceptreferencetermCreate"))
+ .property("conceptMapType", new RefProperty("#/definitions/ConceptmaptypeCreate"))
+
+ .required("termA").required("termB").required("conceptMapType");
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl(); //FIXME missing props
+ }
+
/**
* Gets the display string for a concept map.
*
diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptReferenceTermResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptReferenceTermResource1_9.java
index 4e2c49674..735f7f218 100644
--- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptReferenceTermResource1_9.java
+++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptReferenceTermResource1_9.java
@@ -9,6 +9,11 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9;
+import com.sun.org.apache.xpath.internal.operations.Mod;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.apache.commons.lang3.StringUtils;
import org.openmrs.ConceptReferenceTerm;
import org.openmrs.api.ConceptService;
@@ -88,6 +93,41 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("code", new StringProperty())
+ .property("version", new StringProperty());
+
+ }
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("conceptSource", new RefProperty("#/definitions/ConceptsourceGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("conceptSource", new RefProperty("#/definitions/ConceptsourceGet"));
+ }
+ return model;
+
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .property("code", new StringProperty())
+ .property("conceptSource", new StringProperty())
+ .property("version", new StringProperty())
+
+ .required("code").required("conceptSource");
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl(); //FIXME missing props
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.MetadataDelegatingCrudResource#getDisplayString(org.openmrs.OpenmrsMetadata)
*/
diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptSearchResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptSearchResource1_9.java
index 3c36e70d1..93f58ad4a 100644
--- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptSearchResource1_9.java
+++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptSearchResource1_9.java
@@ -9,10 +9,10 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.ConceptClass;
import org.openmrs.ConceptName;
import org.openmrs.ConceptSearchResult;
@@ -34,6 +34,10 @@
import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException;
import org.openmrs.module.webservices.rest.web.response.ResponseException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
/**
* {@link org.openmrs.module.webservices.rest.web.annotation.Resource} for
* {@link org.openmrs.ConceptSearchResult}, supporting only search operations for concepts and
@@ -68,6 +72,32 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("display", new StringProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("concept", new RefProperty("#/definitions/ConceptGetRef"))
+ .property("conceptName", new RefProperty("#/definitions/ConceptNameGetRef"));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("concept", new RefProperty("#/definitions/ConceptGet"))
+ .property("conceptName", new RefProperty("#/definitions/ConceptNameGetRef"))
+ .property("word", new StringProperty())
+ .property("transientWeight", new StringProperty());
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return null;
+ }
+
/**
* @see
*/
diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptStopwordResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptStopwordResource1_9.java
index 7fba9c94a..a5137ec5d 100644
--- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptStopwordResource1_9.java
+++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptStopwordResource1_9.java
@@ -9,6 +9,9 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.StringProperty;
import org.apache.commons.lang.StringUtils;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
@@ -81,6 +84,29 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = ((ModelImpl) super.getGETModel(rep))
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty());
+
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ modelImpl
+ .property("value", new StringProperty())
+ .property("locale", new StringProperty().example("en")); //FIXME type
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("value", new StringProperty())
+ .property("locale", new StringProperty().example("en"))
+
+ .required("value");
+ }
+
/**
* @see DelegatingCrudResource#getByUniqueId(java.lang.String)
*/
diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CustomDatatypeHandlerResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CustomDatatypeHandlerResource1_9.java
index a1a14f8a6..0566038a0 100644
--- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CustomDatatypeHandlerResource1_9.java
+++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CustomDatatypeHandlerResource1_9.java
@@ -9,9 +9,14 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.SubResource;
+import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation;
+import org.openmrs.module.webservices.rest.web.representation.FullRepresentation;
import org.openmrs.module.webservices.rest.web.representation.Representation;
import org.openmrs.module.webservices.rest.web.resource.api.PageableResult;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription;
@@ -35,6 +40,23 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("handlerClassname", new StringProperty())
+ .property("display", new StringProperty()); //FIXME delegate property name
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return null;
+ }
+
@Override
public CustomDatatypeHandlerRepresentation newDelegate() {
return new CustomDatatypeHandlerRepresentation();
diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CustomDatatypeResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CustomDatatypeResource1_9.java
index 003bc5f1f..10d252270 100644
--- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CustomDatatypeResource1_9.java
+++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CustomDatatypeResource1_9.java
@@ -9,9 +9,11 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9;
-import java.util.ArrayList;
-import java.util.List;
-
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.api.context.Context;
import org.openmrs.customdatatype.CustomDatatype;
import org.openmrs.customdatatype.CustomDatatypeHandler;
@@ -31,6 +33,9 @@
import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException;
import org.openmrs.module.webservices.rest.web.response.ResponseException;
+import java.util.ArrayList;
+import java.util.List;
+
@Resource(name = RestConstants.VERSION_1 + "/customdatatype", supportedClass = CustomDatatypeRepresentation.class, supportedOpenmrsVersions = {
"1.9.*", "1.10.*", "1.11.*", "1.12.*", "2.0.*", "2.1.*" })
public class CustomDatatypeResource1_9 extends DelegatingCrudResource {
@@ -97,6 +102,30 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("datatypeClassname", new StringProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("handlers", new ArrayProperty(new RefProperty("#/definitions/CustomdatatypeHandlersGetRef")));
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("handlers", new ArrayProperty(new RefProperty("#/definitions/CustomdatatypeHandlersGet")));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return null;
+ }
+
@Override
protected PageableResult doGetAll(RequestContext context) throws ResponseException {
List datatypes = getAllCustomDatatypes();
diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterProviderResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterProviderResource1_9.java
index b4eda3495..198b5f963 100644
--- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterProviderResource1_9.java
+++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterProviderResource1_9.java
@@ -9,6 +9,11 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Encounter;
import org.openmrs.EncounterProvider;
import org.openmrs.EncounterRole;
@@ -85,6 +90,47 @@ public DelegatingResourceDescription getUpdatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("provider", new RefProperty("#/definitions/ProviderGetRef"))
+ .property("encounterRole", new RefProperty("#/definitions/EncounterroleGetRef"))
+ .property("voided", new BooleanProperty());
+ }
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("provider", new RefProperty("#/definitions/ProviderGet"))
+ .property("encounterRole", new RefProperty("#/definitions/EncounterroleGet"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = new ModelImpl()
+ .property("provider", new StringProperty().example("uuid"))
+ .property("encounterRole", new StringProperty().example("uuid"))
+ .property("encounter", new StringProperty()); //FIXME remove if not needed
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("provider", new RefProperty("#/definitions/ProviderCreate"))
+ .property("encounter", new RefProperty("#/definitions/EncounterCreate"))
+ .property("encounterRole", new RefProperty("#/definitions/EncounterroleCreate"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("encounterRole", new StringProperty())
+ .property("voided", new BooleanProperty())
+ .property("voidReason", new StringProperty());
+ }
+
@Override
public Encounter getParent(EncounterProvider instance) {
return instance.getEncounter();
diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterRoleResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterRoleResource1_9.java
index dde7e3ea5..873f4e9c9 100644
--- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterRoleResource1_9.java
+++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterRoleResource1_9.java
@@ -9,11 +9,13 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9;
+import io.swagger.models.Model;
import org.openmrs.EncounterRole;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
+import org.openmrs.module.webservices.rest.web.representation.Representation;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription;
import org.openmrs.module.webservices.rest.web.resource.impl.MetadataDelegatingCrudResource;
@@ -40,6 +42,21 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ return super.getGETModel(rep);
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return super.getCREATEModel(rep);
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
/**
* @see DelegatingCrudResource#newDelegate()
*/
diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormResourceResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormResourceResource1_9.java
index 17a379c5c..ec29b91ae 100644
--- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormResourceResource1_9.java
+++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormResourceResource1_9.java
@@ -9,6 +9,10 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.apache.commons.lang.StringUtils;
import org.openmrs.Form;
import org.openmrs.FormResource;
@@ -137,6 +141,43 @@ public DelegatingResourceDescription getCreatableProperties() throws ResourceDoe
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = ((ModelImpl) super.getGETModel(rep))
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty());
+
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ modelImpl
+ .property("name", new StringProperty())
+ .property("valueReference", new StringProperty());
+ }
+ if (rep instanceof FullRepresentation) {
+ modelImpl
+ .property("dataType", new StringProperty())
+ .property("handler", new StringProperty())
+ .property("handlerConfig", new StringProperty());
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = new ModelImpl()
+ .property("form", new StringProperty())
+ .property("name", new StringProperty())
+ .property("dataType", new StringProperty())
+ .property("handler", new StringProperty())
+ .property("handlerConfig", new StringProperty())
+ .property("value", new StringProperty())
+ .property("valueReference", new StringProperty());
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("form", new RefProperty("#/definitions/FormCreate"));
+ }
+ return model;
+ }
+
@Override
protected void delete(FormResource delegate, String reason, RequestContext context) throws ResponseException {
purge(delegate, context);
diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProviderResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProviderResource1_9.java
index e02b15ea0..91b4badba 100644
--- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProviderResource1_9.java
+++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProviderResource1_9.java
@@ -9,6 +9,12 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Provider;
import org.openmrs.ProviderAttribute;
import org.openmrs.api.context.Context;
@@ -107,6 +113,45 @@ public DelegatingResourceDescription getUpdatableProperties() {
return getCreatableProperties();
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("person", new RefProperty("#/definitions/PersonGetRef"))
+ .property("identifier", new StringProperty())
+ .property("attributes", new ArrayProperty(new RefProperty("#/definitions/ProviderAttributeGetRef")))
+ .property("preferredHandlerClassname", new StringProperty());
+ }
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("person", new RefProperty("#/definitions/PersonGet"))
+ .property("attributes", new ArrayProperty(new RefProperty("#/definitions/ProviderAttributeGet")));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = ((ModelImpl) super.getCREATEModel(rep))
+ .property("person", new StringProperty().example("uuid"))
+ .property("identifier", new StringProperty())
+ .property("attributes", new ArrayProperty(new RefProperty("#/definitions/ProviderAttributeCreate")))
+ .property("retired", new BooleanProperty())
+
+ .required("person").required("identifier");
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("person", new RefProperty("#/definitions/PersonCreate"));
+ }
+ return model;
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#newDelegate()
*/
diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/SystemSettingResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/SystemSettingResource1_9.java
index a74610c22..52433b61e 100644
--- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/SystemSettingResource1_9.java
+++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/SystemSettingResource1_9.java
@@ -11,6 +11,9 @@
import java.util.List;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.StringProperty;
import org.apache.commons.lang.StringUtils;
import org.openmrs.GlobalProperty;
import org.openmrs.api.APIException;
@@ -107,6 +110,48 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = ((ModelImpl) super.getGETModel(rep));
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("property", new StringProperty())
+ .property("value", new StringProperty())
+ .property("description", new StringProperty())
+ .property("display", new StringProperty());
+ }
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("datatypeClassname", new StringProperty())
+ .property("datatypeConfig", new StringProperty())
+ .property("preferredHandlerClassname", new StringProperty())
+ .property("handlerConfig", new StringProperty());
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("property", new StringProperty())
+ .property("description", new StringProperty())
+ .property("datatypeClassname", new StringProperty())
+ .property("datatypeConfig", new StringProperty())
+ .property("preferredHandlerClassname", new StringProperty())
+ .property("handlerConfig", new StringProperty())
+ .property("value", new StringProperty())
+
+ .required("property");
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ Model model = getCREATEModel(rep);
+ model.getProperties().remove("property");
+ return model;
+ }
+
/**
* @see DelegatingCrudResource#newDelegate()
*/
diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/VisitResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/VisitResource1_9.java
index a00bb4f4c..3ef1e30e5 100644
--- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/VisitResource1_9.java
+++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/VisitResource1_9.java
@@ -9,6 +9,13 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.DateProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Patient;
import org.openmrs.Visit;
import org.openmrs.VisitAttribute;
@@ -137,6 +144,72 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ modelImpl
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("startDatetime", new DateProperty())
+ .property("stopDatetime", new DateProperty())
+ .property("attributes", new ArrayProperty(new StringProperty())) //FIXME type
+ .property("voided", new BooleanProperty());
+ }
+ if (rep instanceof DefaultRepresentation) {
+ modelImpl
+ .property("patient", new RefProperty("#/definitions/PatientGetRef"))
+ .property("visitType", new RefProperty("#/definitions/VisittypeGetRef"))
+ .property("indication", new RefProperty("#/definitions/ConceptGetRef"))
+ .property("location", new RefProperty("#/definitions/LocationGetRef"))
+ .property("encounters", new ArrayProperty(new RefProperty("#/definitions/EncounterGetRef")));
+ } else if (rep instanceof FullRepresentation) {
+ modelImpl
+ .property("patient", new RefProperty("#/definitions/PatientGet"))
+ .property("visitType", new RefProperty("#/definitions/VisittypeGet"))
+ .property("indication", new RefProperty("#/definitions/ConceptGet"))
+ .property("location", new RefProperty("#/definitions/LocationGet"))
+ .property("encounters", new ArrayProperty(new RefProperty("#/definitions/EncounterGet")));
+ }
+ return modelImpl;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ ModelImpl model = new ModelImpl()
+ .property("patient", new StringProperty().example("uuid"))
+ .property("visitType", new StringProperty().example("uuid"))
+ .property("startDatetime", new DateProperty())
+ .property("location", new StringProperty().example("uuid"))
+ .property("indication", new StringProperty())
+ .property("stopDatetime", new DateProperty())
+ .property("encounters", new ArrayProperty(new StringProperty().example("uuid")))
+ .property("attributes", new ArrayProperty(new RefProperty("#/definitions/VisitAttributeCreate")))
+
+ .required("patient").required("visitType");
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("patient", new RefProperty("#/definitions/PatientCreate"))
+ .property("visitType", new RefProperty("#/definitions/VisittypeCreate"))
+ .property("location", new RefProperty("#/definitions/LocationCreate"))
+ .property("indication", new RefProperty("#/definitions/ConceptCreate"))
+ .property("encounters", new ArrayProperty(new RefProperty("#/definitions/EncounterCreate")));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("visitType", new RefProperty("#/definitions/VisittypeCreate"))
+ .property("startDatetime", new DateProperty())
+ .property("location", new RefProperty("#/definitions/LocationCreate"))
+ .property("indication", new RefProperty("#/definitions/ConceptCreate"))
+ .property("stopDatetime", new DateProperty())
+ .property("encounters", new ArrayProperty(new RefProperty("#/definitions/EncounterCreate")))
+ .property("attributes", new ArrayProperty(new StringProperty())); //FIXME type
+ }
+
/**
* @see DelegatingCrudResource#newDelegate()
*/
diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/VisitTypeResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/VisitTypeResource1_9.java
index eac157dcd..258c3c62f 100644
--- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/VisitTypeResource1_9.java
+++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/VisitTypeResource1_9.java
@@ -12,11 +12,13 @@
import java.util.ArrayList;
import java.util.List;
+import io.swagger.models.Model;
import org.openmrs.VisitType;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
+import org.openmrs.module.webservices.rest.web.representation.Representation;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription;
import org.openmrs.module.webservices.rest.web.resource.impl.MetadataDelegatingCrudResource;
@@ -43,6 +45,16 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ return super.getGETModel(rep);
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return super.getCREATEModel(rep);
+ }
+
/**
* @see DelegatingCrudResource#newDelegate()
*/
diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProviderResource1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProviderResource1_9Test.java
index dda19a201..4c043601f 100644
--- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProviderResource1_9Test.java
+++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProviderResource1_9Test.java
@@ -15,7 +15,6 @@
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RestTestConstants1_9;
import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest;
-import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.ProviderResource1_9;
public class ProviderResource1_9Test extends BaseDelegatingResourceTest {
diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/test/GenericChildResource.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/test/GenericChildResource.java
index e64617b61..32c2a48d3 100644
--- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/test/GenericChildResource.java
+++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/test/GenericChildResource.java
@@ -9,6 +9,9 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.test;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
@@ -40,6 +43,24 @@ public DelegatingResourceDescription getCreatableProperties() {
return description;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ return ((ModelImpl) super.getGETModel(rep))
+ .property("uuid", new StringProperty())
+ .property("value", new StringProperty());
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("value", new StringProperty());
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl();
+ }
+
@Override
public GenericChild newDelegate() {
return new GenericChild();
diff --git a/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PatientAllergyResource2_0.java b/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PatientAllergyResource2_0.java
index 9b2cb8057..2fe788bd0 100644
--- a/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PatientAllergyResource2_0.java
+++ b/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PatientAllergyResource2_0.java
@@ -12,8 +12,14 @@
import java.util.ArrayList;
import java.util.List;
-import org.openmrs.Allergies;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.ObjectProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Allergy;
+import org.openmrs.Allergies;
import org.openmrs.AllergyReaction;
import org.openmrs.Patient;
import org.openmrs.api.context.Context;
@@ -89,6 +95,47 @@ public DelegatingResourceDescription getUpdatableProperties() {
return getCreatableProperties();
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = ((ModelImpl) super.getGETModel(rep));
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("display", new StringProperty())
+ .property("uuid", new StringProperty())
+ .property("allergen", new ObjectProperty()) //FIXME type
+ .property("severity", new RefProperty("#/definitions/ConceptGetRef"))
+ .property("comment", new StringProperty())
+ .property("reactions", new ArrayProperty(new RefProperty("#/definitions/ConceptGetRef")))
+ .property("patient", new RefProperty("#/definitions/PatientGetRef"));
+ }
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("severity", new RefProperty("#/definitions/ConceptGet"))
+ .property("reactions", new ArrayProperty(new RefProperty("#/definitions/ConceptGet")))
+ .property("patient", new RefProperty("#/definitions/PatientGet"));
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("allergen", new ObjectProperty()) //FIXME type
+ .property("severity", new ObjectProperty()
+ .property("uuid", new StringProperty()))
+ .property("comment", new StringProperty())
+ .property("reactions", new ArrayProperty(new ObjectProperty()
+ .property("allergy", new ObjectProperty().property("uuid", new StringProperty()))
+ .property("reaction", new ObjectProperty().property("uuid", new StringProperty()))))
+
+ .required("allergen");
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#getParent(java.lang.Object)
*/
diff --git a/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/CohortMembershipResource2_1.java b/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/CohortMembershipResource2_1.java
index deaa64b0d..6192fbe2e 100644
--- a/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/CohortMembershipResource2_1.java
+++ b/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/CohortMembershipResource2_1.java
@@ -11,6 +11,10 @@
import java.util.ArrayList;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.DateProperty;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Cohort;
import org.openmrs.CohortMembership;
import org.openmrs.Patient;
@@ -93,6 +97,36 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe
return d;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("startDate", new DateProperty())
+ .property("endDate", new DateProperty())
+ .property("patientUuid", new StringProperty());
+ }
+ //FIXME missing props
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("patientUuid", new StringProperty())
+ .property("startDate", new DateProperty())
+ .property("endDate", new DateProperty());
+ }
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("startDate", new DateProperty())
+ .property("endDate", new DateProperty());
+ }
+
@PropertyGetter("display")
public String getDisplay(CohortMembership cohortMembership) {
return "Patient in cohort (see link with rel=patient)";
diff --git a/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/CohortResource2_1.java b/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/CohortResource2_1.java
index d7246e919..8d2158515 100644
--- a/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/CohortResource2_1.java
+++ b/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/CohortResource2_1.java
@@ -9,6 +9,7 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs2_1;
+import io.swagger.models.Model;
import org.openmrs.Cohort;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
@@ -30,6 +31,13 @@ public String getResourceVersion() {
return RestConstants2_1.RESOURCE_VERSION;
}
+ @Override
+ public Model getGETModel(Representation rep) {
+ Model model = super.getGETModel(rep);
+ model.getProperties().remove("memberIds");
+ return model;
+ }
+
@Override
public DelegatingResourceDescription getRepresentationDescription(Representation rep) {
// We do not override the CohortResource1_8 representation, because we want to basically do a clean-slate
diff --git a/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/ConceptSourceResource2_1.java b/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/ConceptSourceResource2_1.java
index 97ed5fec9..cdc6fa2fd 100644
--- a/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/ConceptSourceResource2_1.java
+++ b/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/ConceptSourceResource2_1.java
@@ -9,6 +9,10 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs2_1;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.StringProperty;
+import org.apache.xpath.operations.Mod;
import org.openmrs.ConceptSource;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
@@ -25,6 +29,22 @@
@Resource(name = RestConstants.VERSION_1 + "/conceptsource", supportedClass = ConceptSource.class, supportedOpenmrsVersions = { "2.1.*" })
public class ConceptSourceResource2_1 extends ConceptSourceResource2_0 {
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = (ModelImpl) super.getGETModel(rep);
+ if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
+ model
+ .property("uniqueId", new StringProperty());
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation representation) {
+ return ((ModelImpl) super.getCREATEModel(representation))
+ .property("uniqueId", new StringProperty());
+ }
+
/**
* @see DelegatingCrudResource#getRepresentationDescription(Representation)
*/
diff --git a/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/ObsResource2_1.java b/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/ObsResource2_1.java
index f922ebca1..750f2bd6e 100644
--- a/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/ObsResource2_1.java
+++ b/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/ObsResource2_1.java
@@ -9,7 +9,11 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs2_1;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.StringProperty;
import org.openmrs.Obs;
+import org.openmrs.module.webservices.docs.swagger.SwaggerSpecificationCreator;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
import org.openmrs.module.webservices.rest.web.representation.Representation;
@@ -23,6 +27,24 @@
@Resource(name = RestConstants.VERSION_1 + "/obs", supportedClass = Obs.class, supportedOpenmrsVersions = { "2.1.*" })
public class ObsResource2_1 extends ObsResource1_11 {
+ @Override
+ public Model getGETModel(Representation rep) {
+ return ((ModelImpl) super.getGETModel(rep))
+ .property("status", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(Obs.Status.class)))
+ .property("interpretation", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(Obs.Interpretation.class)));
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return ((ModelImpl) super.getCREATEModel(rep))
+ .property("status", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(Obs.Status.class)))
+ .property("interpretation", new StringProperty()
+ ._enum(SwaggerSpecificationCreator.getEnumsAsList(Obs.Interpretation.class)));
+ }
+
@Override
public DelegatingResourceDescription getRepresentationDescription(Representation rep) {
DelegatingResourceDescription description = super.getRepresentationDescription(rep);
diff --git a/omod-common/pom.xml b/omod-common/pom.xml
index 7bc2e2804..c1072d4bf 100644
--- a/omod-common/pom.xml
+++ b/omod-common/pom.xml
@@ -12,12 +12,12 @@
- org.apache.tomcat
- jasper
- 6.0.18
- provided
-
-
+ org.apache.tomcat
+ jasper
+ 6.0.18
+ provided
+
+
joda-time
joda-time
@@ -29,8 +29,24 @@
evo-inflector
1.2.1
+
+
+ io.swagger
+ swagger-core
+ 1.5.13
+
+
+ org.slf4j
+ slf4j-api
+
+
+ javax.validation
+ validation-api
+
+
+
-
+
@@ -72,7 +88,7 @@
-
+
org.jacoco
diff --git a/omod-common/src/main/java/org/openmrs/module/webservices/docs/swagger/SwaggerSpecificationCreator.java b/omod-common/src/main/java/org/openmrs/module/webservices/docs/swagger/SwaggerSpecificationCreator.java
index 33527370a..e19c012a4 100644
--- a/omod-common/src/main/java/org/openmrs/module/webservices/docs/swagger/SwaggerSpecificationCreator.java
+++ b/omod-common/src/main/java/org/openmrs/module/webservices/docs/swagger/SwaggerSpecificationCreator.java
@@ -9,20 +9,29 @@
*/
package org.openmrs.module.webservices.docs.swagger;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
+import io.swagger.models.Contact;
+import io.swagger.models.Info;
+import io.swagger.models.License;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.Operation;
+import io.swagger.models.Path;
+import io.swagger.models.RefModel;
+import io.swagger.models.Response;
+import io.swagger.models.Scheme;
+import io.swagger.models.SecurityRequirement;
+import io.swagger.models.Swagger;
+import io.swagger.models.auth.BasicAuthDefinition;
+import io.swagger.models.parameters.BodyParameter;
+import io.swagger.models.parameters.Parameter;
+import io.swagger.models.parameters.PathParameter;
+import io.swagger.models.parameters.QueryParameter;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.ObjectProperty;
+import io.swagger.models.properties.Property;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
+import io.swagger.util.Json;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
@@ -31,7 +40,6 @@
import org.openmrs.api.context.Context;
import org.openmrs.module.Module;
import org.openmrs.module.ModuleFactory;
-import org.openmrs.module.webservices.docs.ResourceRepresentation;
import org.openmrs.module.webservices.docs.SearchHandlerDoc;
import org.openmrs.module.webservices.docs.SearchQueryDoc;
import org.openmrs.module.webservices.rest.SimpleObject;
@@ -44,21 +52,27 @@
import org.openmrs.module.webservices.rest.web.resource.api.SearchHandler;
import org.openmrs.module.webservices.rest.web.resource.api.SearchParameter;
import org.openmrs.module.webservices.rest.web.resource.api.SearchQuery;
-import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription;
-import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription.Property;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubclassHandler;
import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException;
import org.openmrs.util.OpenmrsConstants;
import org.springframework.util.ReflectionUtils;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
public class SwaggerSpecificationCreator {
- private SwaggerSpecification swaggerSpecification;
+ private Swagger swagger = new Swagger();
private String baseUrl;
@@ -70,18 +84,12 @@ public class SwaggerSpecificationCreator {
Map originalLevels = new HashMap();
- Map definitionMap = new HashMap();
-
- private Map tags;
-
private Logger log = Logger.getLogger(this.getClass());
public SwaggerSpecificationCreator(String baseUrl) {
- this.swaggerSpecification = new SwaggerSpecification();
this.baseUrl = baseUrl;
List searchHandlers = Context.getService(RestService.class).getAllSearchHandlers();
searchHandlerDocs = fillSearchHandlers(searchHandlers, baseUrl);
- tags = new HashMap();
}
public String BuildJSON() {
@@ -89,10 +97,10 @@ public String BuildJSON() {
log.info("Initiating Swagger specification creation");
toggleLogs(RestConstants.SWAGGER_LOGS_OFF);
try {
- createApiDefinition();
+ initSwagger();
addPaths();
- addDefinitions();
- addSubclassOperations();
+ addDefaultDefinitions();
+ // addSubclassOperations(); //FIXME uncomment after fixing the method
}
catch (Exception e) {
log.error("Error while creating Swagger specification", e);
@@ -105,10 +113,18 @@ public String BuildJSON() {
return createJSON();
}
- private void addDefinitions() {
- Definitions definitions = new Definitions();
- definitions.setDefinitions(definitionMap);
- swaggerSpecification.setDefinitions(definitions);
+ private void addDefaultDefinitions() {
+ // schema of the default response
+ // received from fetchAll and search operations
+ swagger.addDefinition("FetchAll", new ModelImpl()
+ .property("results", new ArrayProperty()
+ .items(new ObjectProperty()
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty())
+ .property("links", new ArrayProperty()
+ .items(new ObjectProperty()
+ .property("rel", new StringProperty().example("self"))
+ .property("uri", new StringProperty(StringProperty.Format.URI)))))));
}
private void toggleLogs(boolean targetState) {
@@ -152,34 +168,27 @@ public void write(int b) {
}
}
- private void createApiDefinition() {
- Info info = new Info();
- // basic info
- info.setVersion(OpenmrsConstants.OPENMRS_VERSION_SHORT);
- info.setTitle("OpenMRS API Docs");
- info.setDescription("OpenMRS RESTful API specification");
- // contact
- info.setContact(new Contact("OpenMRS", "http://openmrs.org"));
- // license
- info.setLicense(new License("MPL-2.0 w/ HD", "http://openmrs.org/license"));
- // detailed versions
- info.setVersions(new Versions(OpenmrsConstants.OPENMRS_VERSION, getModuleVersions()));
- swaggerSpecification.setInfo(info);
- // security definitions
- SecurityDefinitions sd = new SecurityDefinitions();
- sd.setBasicAuth(new SecurityScheme("basic", "HTTP basic access authentication using OpenMRS username and password"));
- swaggerSpecification.setSecurityDefinitions(sd);
- List produces = new ArrayList();
- produces.add("application/json");
- produces.add("application/xml");
- List consumes = new ArrayList();
- consumes.add("application/json");
- // TODO: figure out how to post XML using Swagger UI
- //consumes.add("application/xml");
- swaggerSpecification.setHost(getBaseUrl());
- swaggerSpecification.setBasePath("/" + RestConstants.VERSION_1);
- swaggerSpecification.setProduces(produces);
- swaggerSpecification.setConsumes(consumes);
+ private void initSwagger() {
+ final Info info = new Info()
+ .version(OpenmrsConstants.OPENMRS_VERSION_SHORT)
+ .title("OpenMRS API Docs")
+ .description("OpenMRS RESTful API specification")
+ .contact(new Contact().url("http://openmrs.org"))
+ .license(new License().name("MPL-2.0 w/ HD").url("http://openmrs.org/license"));
+
+ this.swagger
+ .info(info)
+ .scheme(Scheme.HTTP)
+ .securityDefinition("basic_auth", new BasicAuthDefinition())
+ .security(new SecurityRequirement().requirement("basic_auth"))
+ .consumes("application/json")
+ .produces("application/json");
+
+ String host = baseUrl.split("/")[0];
+ String basePath = baseUrl.substring(baseUrl.indexOf("/")) + "/v1";
+ this.swagger
+ .host(host)
+ .basePath(basePath);
}
private List getModuleVersions() {
@@ -379,50 +388,6 @@ private Boolean isSubclass(DelegatingResourceHandler> resourceHandler) {
});
}
- private void addResourceTag(String tagString) {
- if (!tags.containsKey(tagString)) {
- Tag tag = new Tag();
- tag.setName(tagString);
- tags.put(tagString, tag);
- }
- }
-
- private ResourceRepresentation getGETRepresentation(DelegatingResourceHandler> resourceHandler) {
- ResourceRepresentation getRepresentation = null;
- try {
- // first try the full representation
- getRepresentation = new ResourceRepresentation("GET", resourceHandler
- .getRepresentationDescription(Representation.FULL).getProperties().keySet());
- return getRepresentation;
- }
- catch (Exception e) {
- // don't panic
- }
- try {
- // next try the default representation
- getRepresentation = new ResourceRepresentation("GET", resourceHandler
- .getRepresentationDescription(Representation.DEFAULT).getProperties().keySet());
- return getRepresentation;
- }
- catch (Exception e) {
- // don't panic
- }
- return getRepresentation;
- }
-
- private ResourceRepresentation getPOSTCreateRepresentation(DelegatingResourceHandler> resourceHandler) {
- ResourceRepresentation postCreateRepresentation = null;
- try {
- DelegatingResourceDescription description = resourceHandler.getCreatableProperties();
- List properties = getPOSTProperties(description);
- postCreateRepresentation = new ResourceRepresentation("POST create", properties);
- }
- catch (Exception e) {
- // don't panic
- }
- return postCreateRepresentation;
- }
-
private SimpleObject buildPOSTUpdateSimpleObject(DelegatingResourceHandler> resourceHandler) {
SimpleObject simpleObject = new SimpleObject();
@@ -433,252 +398,163 @@ private SimpleObject buildPOSTUpdateSimpleObject(DelegatingResourceHandler> re
return simpleObject;
}
- private ResourceRepresentation getPOSTUpdateRepresentation(DelegatingResourceHandler> resourceHandler) {
- ResourceRepresentation postCreateRepresentation = null;
- try {
- DelegatingResourceDescription description = resourceHandler.getUpdatableProperties();
- List properties = getPOSTProperties(description);
- postCreateRepresentation = new ResourceRepresentation("POST update", properties);
- }
- catch (Exception e) {
- // don't panic
- }
- return postCreateRepresentation;
- }
-
- private Path buildFetchAllPath(Path path, DelegatingResourceHandler> resourceHandler, String resourceName,
- String resourceParentName) {
+ private Path buildFetchAllPath(Path path,
+ DelegatingResourceHandler> resourceHandler, String resourceName, String resourceParentName) {
- ResourceRepresentation getRepresentation = getGETRepresentation(resourceHandler);
-
- if (getRepresentation != null) {
- Operation getOperation = null;
- if (resourceParentName == null) {
- if (testOperationImplemented(OperationEnum.get, resourceHandler)) {
-
- getOperation = createOperation(resourceHandler, "get", resourceName, resourceParentName,
- getRepresentation, OperationEnum.get);
- }
- } else {
- if (testOperationImplemented(OperationEnum.getSubresource, resourceHandler)) {
- getOperation = createOperation(resourceHandler, "get", resourceName, resourceParentName,
- getRepresentation, OperationEnum.getSubresource);
- }
- }
-
- if (getOperation != null) {
- Map operationsMap = path.getOperations();
-
- String tag = resourceParentName == null ? resourceName : resourceParentName;
- tag = tag.replaceAll("/", "_");
- addResourceTag(tag);
+ Operation getOperation = null;
+ if (resourceParentName == null) {
+ if (testOperationImplemented(OperationEnum.get, resourceHandler)) {
- getOperation.setTags(Arrays.asList(tag));
- operationsMap.put("get", getOperation);
- path.setOperations(operationsMap);
+ getOperation = createOperation(resourceHandler, "get", resourceName, null,
+ OperationEnum.get);
+ }
+ } else {
+ if (testOperationImplemented(OperationEnum.getSubresource, resourceHandler)) {
+ getOperation = createOperation(resourceHandler, "get", resourceName, resourceParentName,
+ OperationEnum.getSubresource);
}
}
+ if (getOperation != null) {
+ path.setGet(getOperation);
+ }
+
return path;
}
- private Path buildGetWithUUIDPath(Path path, DelegatingResourceHandler> resourceHandler, String resourceName,
- String resourceParentName) {
+ private Path buildGetWithUUIDPath(Path path,
+ DelegatingResourceHandler> resourceHandler, String resourceName, String resourceParentName) {
- ResourceRepresentation getRepresentation = getGETRepresentation(resourceHandler);
+ Operation getOperation = null;
- if (getRepresentation != null) {
- Operation getOperation = null;
-
- if (testOperationImplemented(OperationEnum.getWithUUID, resourceHandler)) {
- if (resourceParentName == null) {
- getOperation = createOperation(resourceHandler, "get", resourceName, resourceParentName,
- getRepresentation, OperationEnum.getWithUUID);
- } else {
- getOperation = createOperation(resourceHandler, "get", resourceName, resourceParentName,
- getRepresentation, OperationEnum.getSubresourceWithUUID);
- }
- }
-
- if (getOperation != null) {
- Map operationsMap = path.getOperations();
-
- String tag = resourceParentName == null ? resourceName : resourceParentName;
- tag = tag.replaceAll("/", "_");
- addResourceTag(tag);
-
- getOperation.setTags(Arrays.asList(tag));
- operationsMap.put("get", getOperation);
- path.setOperations(operationsMap);
+ if (testOperationImplemented(OperationEnum.getWithUUID, resourceHandler)) {
+ if (resourceParentName == null) {
+ getOperation = createOperation(resourceHandler, "get", resourceName, null,
+ OperationEnum.getWithUUID);
+ } else {
+ getOperation = createOperation(resourceHandler, "get", resourceName, resourceParentName,
+ OperationEnum.getSubresourceWithUUID);
}
}
+ if (getOperation != null) {
+ path.get(getOperation);
+ }
return path;
}
- private Path buildCreatePath(Path path, DelegatingResourceHandler> resourceHandler, String resourceName,
- String resourceParentName) {
+ private Path buildCreatePath(Path path,
+ DelegatingResourceHandler> resourceHandler, String resourceName, String resourceParentName) {
- ResourceRepresentation postCreateRepresentation = getPOSTCreateRepresentation(resourceHandler);
+ Operation postCreateOperation = null;
- if (postCreateRepresentation != null) {
- Operation postCreateOperation = null;
-
- if (resourceParentName == null) {
- if (testOperationImplemented(OperationEnum.postCreate, resourceHandler)) {
- postCreateOperation = createOperation(resourceHandler, "post", resourceName, resourceParentName,
- postCreateRepresentation, OperationEnum.postCreate);
- }
- } else {
- if (testOperationImplemented(OperationEnum.postSubresource, resourceHandler)) {
- postCreateOperation = createOperation(resourceHandler, "post", resourceName, resourceParentName,
- postCreateRepresentation, OperationEnum.postSubresource);
- }
+ if (resourceParentName == null) {
+ if (testOperationImplemented(OperationEnum.postCreate, resourceHandler)) {
+ postCreateOperation = createOperation(resourceHandler, "post", resourceName, null,
+ OperationEnum.postCreate);
}
-
- if (postCreateOperation != null) {
- Map operationsMap = path.getOperations();
-
- String tag = resourceParentName == null ? resourceName : resourceParentName;
- tag = tag.replaceAll("/", "_");
- addResourceTag(tag);
-
- postCreateOperation.setTags(Arrays.asList(tag));
- operationsMap.put("post", postCreateOperation);
- path.setOperations(operationsMap);
+ } else {
+ if (testOperationImplemented(OperationEnum.postSubresource, resourceHandler)) {
+ postCreateOperation = createOperation(resourceHandler, "post", resourceName, resourceParentName,
+ OperationEnum.postSubresource);
}
}
+ if (postCreateOperation != null) {
+ path.post(postCreateOperation);
+ }
return path;
}
- private Path buildUpdatePath(Path path, DelegatingResourceHandler> resourceHandler, String resourceName,
- String resourceParentName) {
+ private Path buildUpdatePath(Path path,
+ DelegatingResourceHandler> resourceHandler, String resourceName, String resourceParentName) {
- ResourceRepresentation postUpdateRepresentation = getPOSTUpdateRepresentation(resourceHandler);
+ Operation postUpdateOperation = null;
- if (postUpdateRepresentation != null) {
- Operation postUpdateOperation = null;
-
- if (resourceParentName == null) {
- if (testOperationImplemented(OperationEnum.postUpdate, resourceHandler)) {
- postUpdateOperation = createOperation(resourceHandler, "post", resourceName, resourceParentName,
- postUpdateRepresentation, OperationEnum.postUpdate);
- }
- } else {
- if (testOperationImplemented(OperationEnum.postUpdateSubresouce, resourceHandler)) {
- postUpdateOperation = createOperation(resourceHandler, "post", resourceName, resourceParentName,
- postUpdateRepresentation, OperationEnum.postUpdateSubresouce);
- }
+ if (resourceParentName == null) {
+ if (testOperationImplemented(OperationEnum.postUpdate, resourceHandler)) {
+ postUpdateOperation = createOperation(resourceHandler, "post", resourceName, resourceParentName,
+ OperationEnum.postUpdate);
}
-
- if (postUpdateOperation != null) {
- Map operationsMap = path.getOperations();
-
- String tag = resourceParentName == null ? resourceName : resourceParentName;
- tag = tag.replaceAll("/", "_");
- addResourceTag(tag);
-
- postUpdateOperation.setTags(Arrays.asList(tag));
- operationsMap.put("post", postUpdateOperation);
- path.setOperations(operationsMap);
+ } else {
+ if (testOperationImplemented(OperationEnum.postUpdateSubresouce, resourceHandler)) {
+ postUpdateOperation = createOperation(resourceHandler, "post", resourceName, resourceParentName,
+ OperationEnum.postUpdateSubresouce);
}
}
+ if (postUpdateOperation != null) {
+ path.post(postUpdateOperation);
+ }
return path;
}
- private Path buildDeletePath(Path path, DelegatingResourceHandler> resourceHandler, String resourceName,
- String resourceParentName) {
+ private Path buildDeletePath(Path path,
+ DelegatingResourceHandler> resourceHandler, String resourceName, String resourceParentName) {
Operation deleteOperation = null;
if (resourceParentName == null) {
if (testOperationImplemented(OperationEnum.delete, resourceHandler)) {
deleteOperation = createOperation(resourceHandler, "delete", resourceName, resourceParentName,
- new ResourceRepresentation("delete", new ArrayList()), OperationEnum.delete);
+ OperationEnum.delete);
}
} else {
if (testOperationImplemented(OperationEnum.deleteSubresource, resourceHandler)) {
deleteOperation = createOperation(resourceHandler, "delete", resourceName, resourceParentName,
- new ResourceRepresentation("delete", new ArrayList()), OperationEnum.deleteSubresource);
+ OperationEnum.deleteSubresource);
}
}
if (deleteOperation != null) {
- Map operationsMap = path.getOperations();
-
- String tag = resourceParentName == null ? resourceName : resourceParentName;
- tag = tag.replaceAll("/", "_");
- addResourceTag(tag);
-
- deleteOperation.setTags(Arrays.asList(tag));
- operationsMap.put("delete", deleteOperation);
- path.setOperations(operationsMap);
+ path.delete(deleteOperation);
}
-
return path;
}
- private Path buildPurgePath(Path path, DelegatingResourceHandler> resourceHandler, String resourceName,
- String resourceParentName) {
+ private Path buildPurgePath(Path path, DelegatingResourceHandler> resourceHandler,
+ String resourceName, String resourceParentName) {
- if (path.getOperations().containsKey("delete")) {
+ if (path.getDelete() != null) {
// just add optional purge parameter
- Operation deleteOperation = path.getOperations().get("delete");
+ Operation deleteOperation = path.getDelete();
deleteOperation.setSummary("Delete or purge resource by uuid");
deleteOperation.setDescription("The resource will be voided/retired unless purge = 'true'");
- Parameter purge = new Parameter();
- purge.setName("purge");
- purge.setIn("query");
- purge.setType("boolean");
-
- List parameterList = deleteOperation.getParameters() == null ? new ArrayList()
- : deleteOperation.getParameters();
- parameterList.add(purge);
-
- deleteOperation.setParameters(parameterList);
+ QueryParameter purgeParam = new QueryParameter().name("purge").type("boolean");
+ deleteOperation.parameter(purgeParam);
} else {
// create standalone purge operation with required
Operation purgeOperation = null;
if (resourceParentName == null) {
if (testOperationImplemented(OperationEnum.purge, resourceHandler)) {
- purgeOperation = createOperation(resourceHandler, "delete", resourceName, resourceParentName,
- new ResourceRepresentation("purge", new ArrayList()), OperationEnum.purge);
+ purgeOperation = createOperation(resourceHandler, "delete", resourceName, null,
+ OperationEnum.purge);
}
} else {
if (testOperationImplemented(OperationEnum.purgeSubresource, resourceHandler)) {
purgeOperation = createOperation(resourceHandler, "delete", resourceName, resourceParentName,
- new ResourceRepresentation("purge", new ArrayList()), OperationEnum.purgeSubresource);
+ OperationEnum.purgeSubresource);
}
}
if (purgeOperation != null) {
- Map operationsMap = path.getOperations();
-
- String tag = resourceParentName == null ? resourceName : resourceParentName;
- tag = tag.replaceAll("/", "_");
- addResourceTag(tag);
-
- purgeOperation.setTags(Arrays.asList(tag));
- operationsMap.put("delete", purgeOperation);
- path.setOperations(operationsMap);
+ path.delete(purgeOperation);
}
}
return path;
}
- private void addIndividualPath(Map pathMap, Path pathCheck, String resourceParentName,
- String resourceName, Path path, String pathSuffix) {
- if (pathCheck != null) {
+ private void addIndividualPath(String resourceParentName, String resourceName, Path path,
+ String pathSuffix) {
+ if (!path.getOperations().isEmpty()) {
if (resourceParentName == null) {
- pathMap.put("/" + resourceName + pathSuffix, path);
+ swagger.path("/" + resourceName + pathSuffix, path);
} else {
- pathMap.put("/" + resourceParentName + "/{parent-uuid}/" + resourceName + pathSuffix, path);
+ swagger.path("/" + resourceParentName + "/{parent-uuid}/" + resourceName + pathSuffix, path);
}
}
}
@@ -705,7 +581,7 @@ private String buildSearchParameterDependencyString(Set depende
}
private void addSearchOperations(DelegatingResourceHandler> resourceHandler, String resourceName,
- String resourceParentName, Path getAllPath, Map pathMap) {
+ String resourceParentName, Path getAllPath) {
if (resourceName == null) {
return;
}
@@ -714,42 +590,47 @@ private void addSearchOperations(DelegatingResourceHandler> resourceHandler, S
boolean wasNew = false;
if (hasSearchHandler || hasDoSearch) {
- // if the path has no operations, add a note that at least one search parameter must be specified
- Operation get;
- if (getAllPath.getOperations().isEmpty() || getAllPath.getOperations().get("get") == null) {
+ Operation operation;
+ // query parameter
+ Parameter q = new QueryParameter().name("q")
+ .description("The search query")
+ .type("string");
+
+ if (getAllPath.getOperations().isEmpty() || getAllPath.getGet() == null) {
// create search-only operation
- get = new Operation();
- get.setName("get");
+ operation = new Operation();
+ operation.tag(resourceParentName == null ? resourceName : resourceParentName);
+ operation.produces("application/json").produces("application/xml");
- get.setSummary("Search for " + resourceName);
- get.setDescription("At least one search parameter must be specified");
+ // if the path has no operations, add a note that at least one search parameter must be specified
+ operation.setSummary("Search for " + resourceName);
+ operation.setDescription("At least one search parameter must be specified");
- // produces
- List produces = new ArrayList();
- produces.add("application/json");
- produces.add("application/xml");
- get.setProduces(produces);
+ // representations query parameter
+ Parameter v = new QueryParameter().name("v")
+ .description("The representation to return (ref, default, full or custom)")
+ .type("string")
+ ._enum(Arrays.asList("ref", "default", "full", "custom"));
- // schema
- Response statusOKResponse = new Response();
- statusOKResponse.setDescription(resourceName + " response");
- Schema schema = new Schema();
+ // This implies that the resource has no custom SearchHandler or doGetAll, but has doSearch implemented
+ // As there is only one query param 'q', mark it as required
+ if (!hasSearchHandler) {
+ q.setRequired(true);
+ }
- // response
- statusOKResponse.setSchema(schema);
- List resourceTags = new ArrayList();
- resourceTags.add(resourceName);
- get.setTags(resourceTags);
- Map responses = new HashMap();
- responses.put("200", statusOKResponse);
- get.setResponses(responses);
+ operation.setParameters(buildPagingParameters());
+ operation.parameter(v).parameter(q);
+ operation.addResponse("200", new Response()
+ .description(resourceName + " response")
+ .schema(new RefProperty("#/definitions/FetchAll")));
- // if path has no existing get operations then it is considered new
+ // since the path has no existing get operations then it is considered new
wasNew = true;
} else {
- get = getAllPath.getOperations().get("get");
- get.setSummary("Fetch all non-retired " + resourceName + " resources or perform search");
- get.setDescription("All search parameters are optional");
+ operation = getAllPath.getGet();
+ operation.setSummary("Fetch all non-retired " + resourceName + " resources or perform search");
+ operation.setDescription("All search parameters are optional");
+ operation.parameter(q);
}
Map parameterMap = new HashMap();
@@ -767,17 +648,15 @@ private void addSearchOperations(DelegatingResourceHandler> resourceHandler, S
for (SearchQuery searchQuery : searchHandler.getSearchConfig().getSearchQueries()) {
// parameters with no dependencies
for (SearchParameter requiredParameter : searchQuery.getRequiredParameters()) {
- Parameter p = new Parameter();
+ Parameter p = new QueryParameter().type("string");
p.setName(requiredParameter.getName());
- p.setIn("query");
parameterMap.put(requiredParameter.getName(), p);
}
// parameters with dependencies
for (SearchParameter optionalParameter : searchQuery.getOptionalParameters()) {
- Parameter p = new Parameter();
+ Parameter p = new QueryParameter().type("string");
p.setName(optionalParameter.getName());
p.setDescription(buildSearchParameterDependencyString(searchQuery.getRequiredParameters()));
- p.setIn("query");
parameterMap.put(optionalParameter.getName(), p);
}
}
@@ -785,42 +664,18 @@ private void addSearchOperations(DelegatingResourceHandler> resourceHandler, S
}
}
- // representations query parameter
- Parameter v = new Parameter();
- v.setName("v");
- v.setDescription("The representation to return (ref, default, full or custom)");
- v.setIn("query");
- v.setType("string");
- parameterMap.put("v", v);
-
- // query parameter
- Parameter q = new Parameter();
- q.setName("q");
- q.setDescription("The search query");
- q.setIn("query");
- q.setType("string");
- if (wasNew && !hasSearchHandler) {
- // This implies that the resource has no custom SearchHandler or doGetAll, but has doSearch implemented
- // As there is only one query param 'q', mark it as required
- q.setRequired(true);
+ for (Parameter p : parameterMap.values()) {
+ operation.parameter(p);
}
-
- parameterMap.put("q", q);
-
- get.setParameters(new ArrayList(parameterMap.values()));
- get.getParameters().addAll(buildPagingParameters());
- get.setOperationId("getAll" + getOperationTitle(resourceHandler, true));
+ operation.setOperationId("getAll" + getOperationTitle(resourceHandler, true));
if (wasNew) {
- getAllPath.getOperations().put("get", get);
- addIndividualPath(pathMap, getAllPath, resourceParentName, resourceName, getAllPath, "");
+ getAllPath.setGet(operation);
}
}
}
private void addPaths() {
- Map pathMap = new HashMap();
-
// get all registered resource handlers
List> resourceHandlers = Context.getService(RestService.class).getResourceHandlers();
sortResourceHandlers(resourceHandlers);
@@ -856,59 +711,55 @@ private void addPaths() {
// set up paths
Path rootPath = new Path();
- rootPath.setOperations(new HashMap());
-
Path uuidPath = new Path();
- uuidPath.setOperations(new HashMap());
/////////////////////////
// GET all //
/////////////////////////
- Path rootPathGetAll = buildFetchAllPath(rootPath, resourceHandler, resourceName, resourceParentName);
- addIndividualPath(pathMap, rootPathGetAll, resourceParentName, resourceName, rootPathGetAll, "");
+ Path rootPathGetAll = buildFetchAllPath(rootPath, resourceHandler, resourceName,
+ resourceParentName);
+ addIndividualPath(resourceParentName, resourceName, rootPathGetAll, "");
/////////////////////////
// GET search //
/////////////////////////
- addSearchOperations(resourceHandler, resourceName, resourceParentName, rootPathGetAll, pathMap);
+ addSearchOperations(resourceHandler, resourceName, resourceParentName, rootPathGetAll);
/////////////////////////
// POST create //
/////////////////////////
- Path rootPathPostCreate = buildCreatePath(rootPathGetAll, resourceHandler, resourceName, resourceParentName);
- addIndividualPath(pathMap, rootPathPostCreate, resourceParentName, resourceName, rootPathPostCreate, "");
+ Path rootPathPostCreate = buildCreatePath(rootPathGetAll, resourceHandler, resourceName,
+ resourceParentName);
+ addIndividualPath(resourceParentName, resourceName, rootPathPostCreate, "");
/////////////////////////
// GET with UUID //
/////////////////////////
- Path uuidPathGetAll = buildGetWithUUIDPath(uuidPath, resourceHandler, resourceName, resourceParentName);
- addIndividualPath(pathMap, uuidPathGetAll, resourceParentName, resourceName, uuidPathGetAll, "/{uuid}");
+ Path uuidPathGetAll = buildGetWithUUIDPath(uuidPath, resourceHandler, resourceName,
+ resourceParentName);
+ addIndividualPath(resourceParentName, resourceName, uuidPathGetAll, "/{uuid}");
/////////////////////////
// POST update //
/////////////////////////
- Path uuidPathPostUpdate = buildUpdatePath(uuidPathGetAll, resourceHandler, resourceName, resourceParentName);
- addIndividualPath(pathMap, uuidPathGetAll, resourceParentName, resourceName, uuidPathPostUpdate, "/{uuid}");
+ Path uuidPathPostUpdate = buildUpdatePath(uuidPathGetAll, resourceHandler, resourceName,
+ resourceParentName);
+ addIndividualPath(resourceParentName, resourceName, uuidPathPostUpdate, "/{uuid}");
/////////////////////////
// DELETE //
/////////////////////////
- Path uuidPathDelete = buildDeletePath(uuidPathPostUpdate, resourceHandler, resourceName, resourceParentName);
+ Path uuidPathDelete = buildDeletePath(uuidPathPostUpdate, resourceHandler, resourceName,
+ resourceParentName);
//addIndividualPath(pathMap, uuidPathDelete, resourceParentName, resourceName, uuidPathDelete, "/{uuid}");
/////////////////////////
// DELETE (purge) //
/////////////////////////
- Path uuidPathPurge = buildPurgePath(uuidPathDelete, resourceHandler, resourceName, resourceParentName);
- addIndividualPath(pathMap, uuidPathPurge, resourceParentName, resourceName, uuidPathPurge, "/{uuid}");
+ Path uuidPathPurge = buildPurgePath(uuidPathDelete, resourceHandler, resourceName,
+ resourceParentName);
+ addIndividualPath(resourceParentName, resourceName, uuidPathPurge, "/{uuid}");
}
-
- Paths paths = new Paths();
- paths.setPaths(pathMap);
- swaggerSpecification.setPaths(paths);
- ArrayList tagList = new ArrayList(tags.values());
- Collections.sort(tagList);
- swaggerSpecification.setTags(tagList);
}
private void addSubclassOperations() {
@@ -922,44 +773,27 @@ private void addSubclassOperations() {
Class> resourceClass = ((DelegatingSubclassHandler, ?>) resourceHandler).getSuperclass();
String resourceName = resourceClass.getSimpleName().toLowerCase();
- if (resourceName == null)
- continue;
-
// 1. add non-optional enum property to model
- Path path = swaggerSpecification.getPaths().getPaths().get("/" + resourceName);
+ Path path = swagger.getPath("/" + resourceName);
if (path == null)
continue;
// FIXME: implement other operations when required
- Operation post = path.getOperations().get("post");
+ Operation post = path.getPost();
if (post == null)
continue;
- Definition definition = swaggerSpecification.getDefinitions().getDefinitions()
- .get(StringUtils.capitalize(resourceName) + "Create");
+ Model definition = swagger.getDefinitions().get(StringUtils.capitalize(resourceName) + "Create");
if (definition == null)
continue;
- Properties properties = definition.getProperties();
- Map props = properties.getProperties();
-
- DefinitionProperty type = props.get("type");
-
- if (type == null) {
- type = new DefinitionProperty();
- properties.addProperty("type", type);
- type.setType("string");
- definition.addRequired("type");
- }
-
- type.addEnumerationItem(((DelegatingSubclassHandler) resourceHandler).getTypeName());
+ Map properties = definition.getProperties();
// 2. merge subclass properties into definition
- for (String prop : resourceHandler.getRepresentationDescription(Representation.FULL).getProperties().keySet()) {
- if (props.get(prop) == null) {
- DefinitionProperty dp = new DefinitionProperty();
- dp.setType("string");
- props.put(prop, dp);
+ for (Map.Entry prop : resourceHandler.getGETModel(Representation.FULL).getProperties()
+ .entrySet()) {
+ if (properties.get(prop.getKey()) == null) {
+ properties.put(prop.getKey(), prop.getValue());
}
}
@@ -967,27 +801,16 @@ private void addSubclassOperations() {
post.setDescription("Certain properties may be required depending on type");
}
}
-
- private static List getPOSTProperties(DelegatingResourceDescription description) {
- List properties = new ArrayList();
- for (Entry property : description.getProperties().entrySet()) {
- if (property.getValue().isRequired()) {
- properties.add("*" + property.getKey() + "*");
- } else {
- properties.add(property.getKey());
- }
- }
- return properties;
- }
-
- private List getParametersListForSearchHandlers(String resourceName, String searchHandlerId, int queryIndex) {
- List parameters = new ArrayList();
+
+ @Deprecated
+ private List getParametersListForSearchHandlers(String resourceName, String searchHandlerId, int queryIndex) {
+ List parameters = new ArrayList();
String resourceURL = getResourceUrl(getBaseUrl(), resourceName);
for (SearchHandlerDoc searchDoc : searchHandlerDocs) {
if (searchDoc.getSearchHandlerId().equals(searchHandlerId) && searchDoc.getResourceURL().equals(resourceURL)) {
SearchQueryDoc queryDoc = searchDoc.getSearchQueriesDoc().get(queryIndex);
for (SearchParameter requiredParameter : queryDoc.getRequiredParameters()) {
- Parameter parameter = new Parameter();
+ org.openmrs.module.webservices.docs.swagger.Parameter parameter = new org.openmrs.module.webservices.docs.swagger.Parameter();
parameter.setName(requiredParameter.getName());
parameter.setIn("query");
parameter.setDescription("");
@@ -995,93 +818,64 @@ private List getParametersListForSearchHandlers(String resourceName,
parameters.add(parameter);
}
for (SearchParameter optionalParameter : queryDoc.getOptionalParameters()) {
- Parameter parameter = new Parameter();
+ org.openmrs.module.webservices.docs.swagger.Parameter parameter = new org.openmrs.module.webservices.docs.swagger.Parameter();
parameter.setName(optionalParameter.getName());
parameter.setIn("query");
parameter.setDescription("");
parameter.setRequired(false);
parameters.add(parameter);
}
-
+
break;
}
}
return parameters;
-
+
}
private String createJSON() {
- String json = "";
- try {
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
- mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true);
- mapper.setSerializationInclusion(Include.NON_NULL);
- mapper.getSerializerProvider().setNullKeySerializer(new NullSerializer());
-
- json = mapper.writeValueAsString(swaggerSpecification);
- }
- catch (Exception exp) {
- exp.printStackTrace();
- }
-
- return json;
+ return Json.pretty(swagger);
}
- private Parameter buildRequiredUUIDParameter(String name, String label) {
- Parameter parameter = new Parameter();
-
- parameter.setName(name);
- parameter.setIn("path");
- parameter.setDescription(label);
- parameter.setRequired(true);
-
- return parameter;
+ private Parameter buildRequiredUUIDParameter(String name, String desc) {
+ return new PathParameter().name(name).description(desc).type("string");
}
private List buildPagingParameters() {
- List pagingParams = new ArrayList();
+ List params = new ArrayList();
+
+ Parameter limit = new QueryParameter().name("limit")
+ .description("The number of results to return").type("integer");
- Parameter limit = new Parameter();
- limit.setName("limit");
- limit.setDescription("The number of results to return");
- limit.setIn("query");
- limit.setType("integer");
- pagingParams.add(limit);
+ Parameter startIndex = new QueryParameter().name("startIndex")
+ .description("The offset at which to start").type("integer");
- Parameter startIndex = new Parameter();
- startIndex.setName("startIndex");
- startIndex.setDescription("The offset at which to start");
- startIndex.setIn("query");
- startIndex.setType("integer");
- pagingParams.add(startIndex);
+ params.add(limit);
+ params.add(startIndex);
- return pagingParams;
+ return params;
}
- private Parameter buildPOSTBodyParameter(String resourceName, String resourceParentName, OperationEnum operationEnum) {
- Parameter parameter = new Parameter();
- Schema bodySchema = new Schema();
-
- parameter.setIn("body");
- parameter.setRequired(true);
- parameter.setSchema(bodySchema);
+ private Parameter buildPOSTBodyParameter(String resourceName, String resourceParentName,
+ OperationEnum operationEnum) {
+ BodyParameter bodyParameter = new BodyParameter();
+ bodyParameter.setRequired(true);
switch (operationEnum) {
case postCreate:
case postSubresource:
- parameter.setName("resource");
- parameter.setDescription("Resource to create");
+ bodyParameter.setName("resource");
+ bodyParameter.setDescription("Resource to create");
break;
case postUpdate:
case postUpdateSubresouce:
- parameter.setName("resource");
- parameter.setDescription("Resource properties to update");
+ bodyParameter.setName("resource");
+ bodyParameter.setDescription("Resource properties to update");
}
- bodySchema.setRef(getSchemaRef(resourceName, resourceParentName, operationEnum));
+ bodyParameter.schema(new RefModel(getSchemaRef(resourceName, resourceParentName, operationEnum)));
- return parameter;
+ return bodyParameter;
}
private String getSchemaName(String resourceName, String resourceParentName, OperationEnum operationEnum) {
@@ -1115,27 +909,18 @@ private String getSchemaName(String resourceName, String resourceParentName, Ope
// get rid of slashes in model names
String[] split = modelRefName.split("\\/");
- String ret = "";
+ StringBuilder ret = new StringBuilder();
for (String s : split) {
- ret += StringUtils.capitalize(s);
+ ret.append(StringUtils.capitalize(s));
}
- return ret;
+ return ret.toString();
}
private String getSchemaRef(String resourceName, String resourceParentName, OperationEnum operationEnum) {
return "#/definitions/" + getSchemaName(resourceName, resourceParentName, operationEnum);
}
- private String getModelTitle(String schemaName) {
- if (schemaName.toLowerCase().endsWith("get")) {
- return schemaName.substring(0, schemaName.length() - 3);
- } else if (schemaName.toLowerCase().endsWith("create") || schemaName.toLowerCase().endsWith("update")) {
- return schemaName.substring(0, schemaName.length() - 6);
- }
- return schemaName;
- }
-
private String getOperationTitle(DelegatingResourceHandler> resourceHandler, Boolean pluralize) {
StringBuilder ret = new StringBuilder();
English inflector = new English();
@@ -1165,267 +950,195 @@ private String getOperationTitle(DelegatingResourceHandler> resourceHandler, B
}
private void createDefinition(OperationEnum operationEnum, String resourceName, String resourceParentName,
- ResourceRepresentation representation) {
+ DelegatingResourceHandler> resourceHandler) {
String definitionName = getSchemaName(resourceName, resourceParentName, operationEnum);
+ Model model = null;
+ Model modelRef = null;
+ Model modelFull = null;
+ //FIXME ex:
+ // java.lang.AbstractMethodError: org.openmrs.module.reportingrest.web.resource.EvaluatedCohort
+ // resourceHandler.getClass().getMethod("getGETModel", Representation.class);
+ if (!resourceHandler.getClass().getName().startsWith("org.openmrs.module.webservices.rest")) {
+ return;
+ }
- Definition definition = new Definition();
- definition.setType("object");
-
- Xml xml = new Xml();
- xml.setName(getModelTitle(getSchemaName(resourceName, resourceParentName, operationEnum).toLowerCase()));
- definition.setXml(xml);
-
- Properties props = new Properties();
- definition.setProperties(props);
-
- Collection properties = representation.getProperties();
-
- for (String property : properties) {
- DefinitionProperty defProp = new DefinitionProperty();
- String propName;
-
- if (property.startsWith("*")) {
- propName = property.replace("*", "");
- definition.addRequired(propName);
- } else {
- propName = property;
- }
-
- defProp.setType("string");
- props.addProperty(propName, defProp);
+ if (definitionName.endsWith("Get")) {
+ model = resourceHandler.getGETModel(Representation.DEFAULT);
+ modelRef = resourceHandler.getGETModel(Representation.REF);
+ modelFull = resourceHandler.getGETModel(Representation.FULL);
+ } else if (definitionName.endsWith("Create")) {
+ model = resourceHandler.getCREATEModel(Representation.DEFAULT);
+ modelFull = resourceHandler.getCREATEModel(Representation.FULL);
+ } else if (definitionName.endsWith("Update")) {
+ model = resourceHandler.getUPDATEModel(Representation.DEFAULT);
}
- definitionMap.put(definitionName, definition);
+ if (model != null) {
+ swagger.addDefinition(definitionName, model);
+ }
+ if (modelRef != null) {
+ swagger.addDefinition(definitionName + "Ref", modelRef);
+ }
+ if (modelFull != null) {
+ swagger.addDefinition(definitionName + "Full", modelFull);
+ }
}
+ /**
+ * @param resourceHandler
+ * @param operationName get, post, delete
+ * @param resourceName
+ * @param resourceParentName
+ * @param representation
+ * @param operationEnum
+ * @return
+ */
private Operation createOperation(DelegatingResourceHandler> resourceHandler, String operationName,
- String resourceName, String resourceParentName, ResourceRepresentation representation,
- OperationEnum operationEnum) {
- Map responses = new HashMap();
-
- Operation operation = new Operation();
- operation.setName(operationName);
- operation.setDescription(null);
+ String resourceName, String resourceParentName, OperationEnum operationEnum) {
- List produces = new ArrayList();
- produces.add("application/json");
- produces.add("application/xml");
- operation.setProduces(produces);
- List parameters = new ArrayList();
-
- operation.setParameters(parameters);
+ Operation operation = new Operation()
+ .tag(resourceParentName == null ? resourceName : resourceParentName)
+ .consumes("application/json").produces("application/json");
// create definition
if (operationName == "post" || operationName == "get") {
- createDefinition(operationEnum, resourceName, resourceParentName, representation);
+ // createDefinition(operationEnum, resourceName, resourceParentName, representation);
+ createDefinition(operationEnum, resourceName, resourceParentName, resourceHandler);
}
+ // create all possible responses
// 200 response (Successful operation)
- Response statusOKResponse = new Response();
- statusOKResponse.setDescription(resourceName + " response");
- Schema responseBodySchema = new Schema();
+ Response response200 = new Response().description(resourceName + " response");
// 201 response (Successfully created)
- Response createdOKResponse = new Response();
- createdOKResponse.setDescription(resourceName + " response");
- createdOKResponse.setSchema(responseBodySchema);
-
+ Response response201 = new Response().description(resourceName + " response");
+
// 204 delete success
- Response deletedOKResponse = new Response();
- deletedOKResponse.setDescription("Delete successful");
+ Response response204 = new Response().description("Delete successful");
// 401 response (User not logged in)
- Response notLoggedInResponse = new Response();
- notLoggedInResponse.setDescription("User not logged in");
+ Response response401 = new Response().description("User not logged in");
// 404 (Object with given uuid doesn't exist)
- Response notFoundResponse = new Response();
- notFoundResponse.setDescription("Resource with given uuid doesn't exist");
+ Response response404 = new Response()
+ .description("Resource with given uuid doesn't exist");
+ // create all possible query params
// representations query parameter
- Parameter v = new Parameter();
- v.setName("v");
- v.setDescription("The representation to return (ref, default, full or custom)");
- v.setIn("query");
- v.setType("string");
-
- // query parameter
- Parameter q = new Parameter();
- q.setName("q");
- q.setDescription("The search query");
- q.setIn("query");
- q.setType("string");
+ Parameter v = new QueryParameter().name("v")
+ .description("The representation to return (ref, default, full or custom)")
+ .type("string")
+ ._enum(Arrays.asList("ref", "default", "full", "custom"));
if (operationEnum == OperationEnum.get) {
operation.setSummary("Fetch all non-retired");
operation.setOperationId("getAll" + getOperationTitle(resourceHandler, true));
- responseBodySchema.setRef(getSchemaRef(resourceName, resourceParentName, OperationEnum.get));
- parameters.add(v);
- parameters.add(q);
- parameters.addAll(buildPagingParameters());
- statusOKResponse.setSchema(responseBodySchema);
- responses.put("200", statusOKResponse);
+ operation.addResponse("200", response200.schema(new RefProperty("#/definitions/FetchAll")));
+ operation.setParameters(buildPagingParameters());
+ operation.parameter(v);
} else if (operationEnum == OperationEnum.getWithUUID) {
operation.setSummary("Fetch by uuid");
operation.setOperationId("get" + getOperationTitle(resourceHandler, false));
- responseBodySchema.setRef(getSchemaRef(resourceName, resourceParentName, OperationEnum.getWithUUID));
- parameters.add(buildRequiredUUIDParameter("uuid", "uuid to filter by"));
- parameters.add(v);
- statusOKResponse.setSchema(responseBodySchema);
- responses.put("200", statusOKResponse);
- responses.put("404", notFoundResponse);
+ operation.parameter(v);
+ operation.parameter(buildRequiredUUIDParameter("uuid", "uuid to filter by"));
+ operation.addResponse("200",
+ response200.schema(new RefProperty(getSchemaRef(resourceName, resourceParentName, OperationEnum.get))));
+ operation.addResponse("404", response404);
} else if (operationEnum == OperationEnum.postCreate) {
operation.setSummary("Create with properties in request");
operation.setOperationId("create" + getOperationTitle(resourceHandler, false));
- responseBodySchema.setRef(getSchemaRef(resourceName, resourceParentName, OperationEnum.get));
- parameters.add(buildPOSTBodyParameter(resourceName, resourceParentName, OperationEnum.postCreate));
- responses.put("201", createdOKResponse);
+ operation.parameter(buildPOSTBodyParameter(resourceName, resourceParentName, OperationEnum.postCreate));
+ operation.addResponse("201", response201);
} else if (operationEnum == OperationEnum.postUpdate) {
operation.setSummary("Edit with given uuid, only modifying properties in request");
operation.setOperationId("update" + getOperationTitle(resourceHandler, false));
- responseBodySchema.setRef(getSchemaRef(resourceName, resourceParentName, OperationEnum.get));
- parameters.add(buildRequiredUUIDParameter("uuid", "uuid of resource to update"));
- parameters.add(buildPOSTBodyParameter(resourceName, resourceParentName, OperationEnum.postUpdate));
- responses.put("201", createdOKResponse);
+ operation.parameter(buildRequiredUUIDParameter("uuid", "uuid of resource to update"));
+ operation.parameter(buildPOSTBodyParameter(resourceName, resourceParentName, OperationEnum.postUpdate));
+ operation.addResponse("201", response201);
} else if (operationEnum == OperationEnum.getSubresource) {
operation.setSummary("Fetch all non-retired " + resourceName + " subresources");
operation.setOperationId("getAll" + getOperationTitle(resourceHandler, true));
- parameters.add(buildRequiredUUIDParameter("parent-uuid", "parent resource uuid"));
- responseBodySchema.setRef(getSchemaRef(resourceName, resourceParentName, OperationEnum.get));
- parameters.add(v);
- parameters.add(q);
- parameters.addAll(buildPagingParameters());
- statusOKResponse.setSchema(responseBodySchema);
- responses.put("200", statusOKResponse);
+ operation.setParameters(buildPagingParameters());
+ operation.parameter(buildRequiredUUIDParameter("parent-uuid", "parent resource uuid"));
+ operation.parameter(v);
+ operation.addResponse("200", response200.schema(new ObjectProperty()
+ .property("results", new ArrayProperty(
+ new RefProperty(getSchemaRef(resourceName, resourceParentName, OperationEnum.get))))));
} else if (operationEnum == OperationEnum.postSubresource) {
operation.setSummary("Create " + resourceName + " subresource with properties in request");
operation.setOperationId("create" + getOperationTitle(resourceHandler, false));
- parameters.add(buildRequiredUUIDParameter("parent-uuid", "parent resource uuid"));
- responseBodySchema.setRef(getSchemaRef(resourceName, resourceParentName, OperationEnum.get));
- parameters.add(buildPOSTBodyParameter(resourceName, resourceParentName, OperationEnum.postSubresource));
- responses.put("201", createdOKResponse);
+ operation.parameter(buildRequiredUUIDParameter("parent-uuid", "parent resource uuid"));
+ operation.parameter(buildPOSTBodyParameter(resourceName, resourceParentName, OperationEnum.postSubresource));
+ operation.addResponse("201",
+ response201.schema(new RefProperty(getSchemaRef(resourceName, resourceParentName, OperationEnum.get))));
} else if (operationEnum == OperationEnum.postUpdateSubresouce) {
- operation.setSummary("Edit " + resourceName
+ operation.setSummary("edit " + resourceName
+ " subresource with given uuid, only modifying properties in request");
operation.setOperationId("update" + getOperationTitle(resourceHandler, false));
- parameters.add(buildRequiredUUIDParameter("parent-uuid", "parent resource uuid"));
- parameters.add(buildRequiredUUIDParameter("uuid", "uuid of resource to update"));
- responseBodySchema.setRef(getSchemaRef(resourceName, resourceParentName, OperationEnum.get));
- parameters.add(buildPOSTBodyParameter(resourceName, resourceParentName, OperationEnum.postUpdateSubresouce));
- responses.put("201", createdOKResponse);
+ operation.parameter(buildRequiredUUIDParameter("parent-uuid", "parent resource uuid"));
+ operation.parameter(buildRequiredUUIDParameter("uuid", "uuid of resource to update"));
+ operation
+ .parameter(buildPOSTBodyParameter(resourceName, resourceParentName, OperationEnum.postUpdateSubresouce));
+ operation.addResponse("201",
+ response201.schema(new RefProperty(getSchemaRef(resourceName, resourceParentName, OperationEnum.get))));
} else if (operationEnum == OperationEnum.getSubresourceWithUUID) {
-
operation.setSummary("Fetch " + resourceName + " subresources by uuid");
operation.setOperationId("get" + getOperationTitle(resourceHandler, false));
- responseBodySchema.setRef(getSchemaRef(resourceName, resourceParentName, OperationEnum.getSubresourceWithUUID));
- parameters.add(buildRequiredUUIDParameter("parent-uuid", "parent resource uuid"));
- parameters.add(buildRequiredUUIDParameter("uuid", "uuid to filter by"));
- parameters.add(v);
- statusOKResponse.setSchema(responseBodySchema);
- responses.put("200", statusOKResponse);
- responses.put("404", notFoundResponse);
+ operation.parameter(buildRequiredUUIDParameter("parent-uuid", "parent resource uuid"));
+ operation.parameter(buildRequiredUUIDParameter("uuid", "uuid to filter by"));
+ operation.parameter(v);
+ operation.addResponse("200", response200.schema(new RefProperty(getSchemaRef(resourceName, resourceParentName,
+ OperationEnum.getSubresourceWithUUID))));
+ operation.addResponse("404", response404);
} else if (operationEnum == OperationEnum.delete) {
operation.setSummary("Delete resource by uuid");
operation.setOperationId("delete" + getOperationTitle(resourceHandler, false));
- statusOKResponse.setDescription("Successful operation");
- parameters.add(buildRequiredUUIDParameter("uuid", "uuid to delete"));
- responses.put("204", deletedOKResponse);
- responses.put("404", notFoundResponse);
+ operation.parameter(buildRequiredUUIDParameter("uuid", "uuid to delete"));
+ operation.response(204, response204);
+ operation.response(404, response404);
} else if (operationEnum == OperationEnum.deleteSubresource) {
-
operation.setSummary("Delete " + resourceName + " subresource by uuid");
operation.setOperationId("delete" + getOperationTitle(resourceHandler, false));
- statusOKResponse.setDescription("Successful operation");
- parameters.add(buildRequiredUUIDParameter("parent-uuid", "parent resource uuid"));
- parameters.add(buildRequiredUUIDParameter("uuid", "uuid to delete"));
- responses.put("204", deletedOKResponse);
- responses.put("404", notFoundResponse);
+ operation.parameter(buildRequiredUUIDParameter("parent-uuid", "parent resource uuid"));
+ operation.parameter(buildRequiredUUIDParameter("uuid", "uuid to delete"));
+ operation.response(204, response204);
+ operation.response(404, response404);
} else if (operationEnum == OperationEnum.purge) {
operation.setSummary("Purge resource by uuid");
operation.setOperationId("purge" + getOperationTitle(resourceHandler, false));
- statusOKResponse.setDescription("Successful operation");
- parameters.add(buildRequiredUUIDParameter("uuid", "uuid to delete"));
- responses.put("204", deletedOKResponse);
+ operation.parameter(buildRequiredUUIDParameter("uuid", "uuid to delete"));
+ operation.response(204, response204);
} else if (operationEnum == OperationEnum.purgeSubresource) {
operation.setSummary("Purge " + resourceName + " subresource by uuid");
operation.setOperationId("purge" + getOperationTitle(resourceHandler, false));
- statusOKResponse.setDescription("Successful operation");
- parameters.add(buildRequiredUUIDParameter("parent-uuid", "parent resource uuid"));
- parameters.add(buildRequiredUUIDParameter("uuid", "uuid to delete"));
- responses.put("204", deletedOKResponse);
+ operation.parameter(buildRequiredUUIDParameter("parent-uuid", "parent resource uuid"));
+ operation.parameter(buildRequiredUUIDParameter("uuid", "uuid to delete"));
+ operation.response(204, response204);
}
- List resourceTags = new ArrayList();
- resourceTags.add(resourceName);
- operation.setTags(resourceTags);
- responses.put("401", notLoggedInResponse);
- operation.setResponses(responses);
-
- return operation;
- }
-
- private Operation createSearchHandlerOperation(String operationName, String resourceName, String searchHandlerId,
- OperationEnum operationEnum, int queryIndex) {
-
- Operation operation = new Operation();
- operation.setName(operationName);
- operation.setDescription(null);
- List produces = new ArrayList();
- produces.add("application/json");
- operation.setProduces(produces);
- operation.setIsSearchHandler("true");
- List parameters = new ArrayList();
-
- parameters = getParametersListForSearchHandlers(resourceName, searchHandlerId, queryIndex);
-
- operation.setParameters(parameters);
-
- Response statusOKResponse = new Response();
- statusOKResponse.setDescription(resourceName + " response");
- Schema schema = new Schema();
-
- schema.setRef("#/definitions/" + resourceName);
-
- statusOKResponse.setSchema(schema);
-
- List resourceTags = new ArrayList();
- resourceTags.add(resourceName);
- operation.setTags(resourceTags);
-
- Map responses = new HashMap();
- responses.put("200", statusOKResponse);
-
- operation.setResponses(responses);
-
- String resourceURL = getResourceUrl(getBaseUrl(), resourceName);
- for (SearchHandlerDoc searchDoc : searchHandlerDocs) {
- if (searchDoc.getSearchHandlerId().equals(searchHandlerId) && searchDoc.getResourceURL().equals(resourceURL)) {
- SearchQueryDoc queryDoc = searchDoc.getSearchQueriesDoc().get(queryIndex);
- operation.setSummary(queryDoc.getDescription());
- }
- }
+ operation.response(401, response401);
return operation;
}
@@ -1447,11 +1160,8 @@ private static List fillSearchHandlers(List sea
}
private String getResourceUrl(String baseUrl, String resourceName) {
-
- String resourceUrl = baseUrl;
-
//Set the root url.
- return resourceUrl + "/v1/" + resourceName;
+ return baseUrl + "/v1/" + resourceName;
}
private boolean hasSearchHandler(String resourceName) {
@@ -1460,7 +1170,6 @@ private boolean hasSearchHandler(String resourceName) {
return true;
}
}
-
return false;
}
@@ -1468,7 +1177,18 @@ public String getBaseUrl() {
return baseUrl;
}
- public SwaggerSpecification getSwaggerSpecification() {
- return swaggerSpecification;
+ public Swagger getSwagger() {
+ return swagger;
+ }
+
+ //FIXME: move to separate util calls
+ // see: https://stackoverflow.com/q/13783295/3647002
+ public static String[] getEnums(Class extends Enum>> e) {
+ return Arrays.toString(e.getEnumConstants())
+ .replaceAll("^.|.$", "").split(", ");
+ }
+
+ public static List getEnumsAsList(Class extends Enum>> e) {
+ return Arrays.asList(getEnums(e));
}
}
diff --git a/omod-common/src/main/java/org/openmrs/module/webservices/docs/swagger/core/property/EnumProperty.java b/omod-common/src/main/java/org/openmrs/module/webservices/docs/swagger/core/property/EnumProperty.java
new file mode 100644
index 000000000..f3b9aefa4
--- /dev/null
+++ b/omod-common/src/main/java/org/openmrs/module/webservices/docs/swagger/core/property/EnumProperty.java
@@ -0,0 +1,20 @@
+/**
+ * This Source Code Form is subject to the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
+ * the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
+ *
+ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
+ * graphic logo is a trademark of OpenMRS Inc.
+ */
+package org.openmrs.module.webservices.docs.swagger.core.property;
+
+import io.swagger.models.properties.StringProperty;
+import org.openmrs.module.webservices.docs.swagger.SwaggerSpecificationCreator;
+
+public class EnumProperty extends StringProperty {
+
+ public EnumProperty(Class extends Enum>> e) {
+ _enum(SwaggerSpecificationCreator.getEnumsAsList(e));
+ }
+}
diff --git a/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/BaseDelegatingResource.java b/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/BaseDelegatingResource.java
index cdbe86592..b0cd78094 100644
--- a/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/BaseDelegatingResource.java
+++ b/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/BaseDelegatingResource.java
@@ -23,6 +23,11 @@
import java.util.Map.Entry;
import java.util.Set;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.ObjectProperty;
+import io.swagger.models.properties.StringProperty;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
@@ -42,6 +47,8 @@
import org.openmrs.module.webservices.rest.web.annotation.SubClassHandler;
import org.openmrs.module.webservices.rest.web.api.RestService;
import org.openmrs.module.webservices.rest.web.representation.CustomRepresentation;
+import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation;
+import org.openmrs.module.webservices.rest.web.representation.FullRepresentation;
import org.openmrs.module.webservices.rest.web.representation.NamedRepresentation;
import org.openmrs.module.webservices.rest.web.representation.RefRepresentation;
import org.openmrs.module.webservices.rest.web.representation.Representation;
@@ -65,6 +72,34 @@ public abstract class BaseDelegatingResource extends BaseDelegatingConverter<
private final Log log = LogFactory.getLog(getClass());
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = new ModelImpl();
+ if (rep instanceof DefaultRepresentation) {
+ model
+ .property("links", new ArrayProperty()
+ .items(new ObjectProperty()
+ .property("rel", new StringProperty().example("self|full"))
+ .property("uri", new StringProperty(StringProperty.Format.URI))));
+
+ } else if (rep instanceof FullRepresentation) {
+ model
+ .property("auditInfo", new StringProperty())
+ .property("links", new ArrayProperty()
+ .items(new ObjectProperty()
+ .property("rel", new StringProperty()).example("self")
+ .property("uri", new StringProperty(StringProperty.Format.URI))));
+
+ } else if (rep instanceof RefRepresentation) {
+ model
+ .property("links", new ArrayProperty()
+ .items(new ObjectProperty()
+ .property("rel", new StringProperty().example("self"))
+ .property("uri", new StringProperty(StringProperty.Format.URI))));
+ }
+ return model;
+ }
+
protected Set propertiesIgnoredWhenUpdating = new HashSet();
/**
@@ -268,6 +303,15 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe
return description;
}
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ ModelImpl model = (ModelImpl) getCREATEModel(rep);
+ for (String property : getPropertiesToExposeAsSubResources()) {
+ model.getProperties().remove(property);
+ }
+ return model;
+ }
+
/**
* Implementations should override this method if they support sub-resources
*
diff --git a/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/BaseDelegatingSubclassHandler.java b/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/BaseDelegatingSubclassHandler.java
index b542ad3f6..786b51f52 100644
--- a/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/BaseDelegatingSubclassHandler.java
+++ b/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/BaseDelegatingSubclassHandler.java
@@ -9,6 +9,7 @@
*/
package org.openmrs.module.webservices.rest.web.resource.impl;
+import io.swagger.models.Model;
import org.openmrs.OpenmrsData;
import org.openmrs.OpenmrsMetadata;
import org.openmrs.api.context.Context;
@@ -21,6 +22,7 @@
import org.openmrs.module.webservices.rest.web.annotation.RepHandler;
import org.openmrs.module.webservices.rest.web.api.RestService;
import org.openmrs.module.webservices.rest.web.representation.RefRepresentation;
+import org.openmrs.module.webservices.rest.web.representation.Representation;
import org.openmrs.module.webservices.rest.web.resource.api.Resource;
import org.openmrs.module.webservices.rest.web.response.ConversionException;
import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException;
@@ -74,7 +76,12 @@ public Class getSubclassHandled() {
public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException {
return getCreatableProperties();
}
-
+
+ @Override
+ public Model getUPDATEModel(Representation rep) {
+ return getCREATEModel(rep);
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object)
*/
diff --git a/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/DelegatingResourceHandler.java b/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/DelegatingResourceHandler.java
index 80b52c481..23aa4f01d 100644
--- a/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/DelegatingResourceHandler.java
+++ b/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/DelegatingResourceHandler.java
@@ -9,6 +9,7 @@
*/
package org.openmrs.module.webservices.rest.web.resource.impl;
+import io.swagger.models.Model;
import org.openmrs.module.webservices.rest.SimpleObject;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.representation.Representation;
@@ -89,4 +90,38 @@ public interface DelegatingResourceHandler extends DelegatingPropertyAccessor
*/
DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException;
+ /**
+ * Returns a {@link Model} object representing GET representation schema for the resource.
+ *
+ * @param rep representation type under which the resource {@link Model} should be fetched. It
+ * can take {@link Representation#DEFAULT}, {@link Representation#REF}, or
+ * {@link Representation#FULL}
+ * @return a {@link Model} object or null in case if such model does not exist or not
+ * documented.
+ */
+ Model getGETModel(Representation rep);
+
+ /**
+ * Returns a {@link Model} object representing CREATE representation schema for the resource.
+ * The returned model object will hold properties (and example values) required to create the
+ * underlying resource.
+ *
+ * @param rep representation type under which the resource {@link Model} should be fetched. It
+ * can take {@link Representation#DEFAULT}, or {@link Representation#FULL}
+ * @return a {@link Model} object or null in case if such model does not exist or not
+ * documented.
+ */
+ Model getCREATEModel(Representation rep);
+
+ /**
+ * Returns a {@link Model} object representing UPDATE representation schema for the resource.
+ * The returned model object will hold properties (and example values) required to update the
+ * underlying resource.
+ *
+ * @param rep representation type under which the resource {@link Model} should be fetched. It
+ * can take {@link Representation#DEFAULT}, or {@link Representation#FULL}
+ * @return a {@link Model} object or null in case if such model does not exist or not
+ * documented.
+ */
+ Model getUPDATEModel(Representation rep);
}
diff --git a/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/MetadataDelegatingCrudResource.java b/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/MetadataDelegatingCrudResource.java
index d31bc89f2..2d072a941 100644
--- a/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/MetadataDelegatingCrudResource.java
+++ b/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/MetadataDelegatingCrudResource.java
@@ -11,6 +11,10 @@
import java.util.Date;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.BooleanProperty;
+import io.swagger.models.properties.StringProperty;
import org.apache.commons.lang.StringUtils;
import org.openmrs.OpenmrsMetadata;
import org.openmrs.api.context.Context;
@@ -34,6 +38,28 @@
*/
public abstract class MetadataDelegatingCrudResource extends DelegatingCrudResource {
+ @Override
+ public Model getGETModel(Representation rep) {
+ ModelImpl model = ((ModelImpl) super.getGETModel(rep))
+ .property("uuid", new StringProperty())
+ .property("display", new StringProperty());
+ if (rep instanceof FullRepresentation) {
+ model
+ .property("name", new StringProperty())
+ .property("description", new StringProperty())
+ .property("retired", new BooleanProperty());
+ }
+ return model;
+ }
+
+ @Override
+ public Model getCREATEModel(Representation rep) {
+ return new ModelImpl()
+ .property("name", new StringProperty())
+ .property("description", new StringProperty())
+ .required("name");
+ }
+
/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingConverter#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation)
*/
diff --git a/omod-common/src/test/java/org/mockingbird/test/rest/resource/AnimalClassResource_1_9.java b/omod-common/src/test/java/org/mockingbird/test/rest/resource/AnimalClassResource_1_9.java
index 6ae7e7a86..603088bf2 100644
--- a/omod-common/src/test/java/org/mockingbird/test/rest/resource/AnimalClassResource_1_9.java
+++ b/omod-common/src/test/java/org/mockingbird/test/rest/resource/AnimalClassResource_1_9.java
@@ -9,6 +9,7 @@
*/
package org.mockingbird.test.rest.resource;
+import io.swagger.models.Model;
import org.mockingbird.test.Animal;
import org.mockingbird.test.AnimalClass;
import org.openmrs.module.webservices.rest.web.RequestContext;
@@ -31,7 +32,12 @@ public class AnimalClassResource_1_9 extends DelegatingSubResource beforeCounts;
public Map getRowCounts() throws Exception {
@@ -99,10 +141,10 @@ public void checkOperationIdsSet() throws Exception {
SwaggerSpecificationCreator ssc = new SwaggerSpecificationCreator("/v1/");
ssc.BuildJSON();
- SwaggerSpecification spec = ssc.getSwaggerSpecification();
+ Swagger spec = ssc.getSwagger();
- for (Path p : spec.getPaths().getPaths().values()) {
- for (Operation o : p.getOperations().values()) {
+ for (Path p : spec.getPaths().values()) {
+ for (Operation o : p.getOperations()) {
Assert.assertFalse("Ensure each operation has a unique ID", operationIds.contains(o.getOperationId()));
operationIds.add(o.getOperationId());
}
@@ -112,18 +154,14 @@ public void checkOperationIdsSet() throws Exception {
// makes sure that every GET operation has the "v" parameter
@Test
public void checkRepresentationParamExists() throws Exception {
- List operationIds = new ArrayList();
-
SwaggerSpecificationCreator ssc = new SwaggerSpecificationCreator("/v1/");
ssc.BuildJSON();
- SwaggerSpecification spec = ssc.getSwaggerSpecification();
+ Swagger spec = ssc.getSwagger();
- for (Path p : spec.getPaths().getPaths().values()) {
- for (Operation o : p.getOperations().values()) {
- if (o.getName().equals("get")) {
- Assert.assertTrue("Ensure each GET operation has the 'v' query parameter",
- operationHasRepresentationParam(o));
- }
+ for (Path p : spec.getPaths().values()) {
+ if (p.getGet() != null) {
+ Assert.assertTrue("Ensure each GET operation has the 'v' query parameter",
+ operationHasRepresentationParam(p.getGet()));
}
}
}
@@ -145,10 +183,10 @@ private boolean operationHasRepresentationParam(Operation o) {
public void checkPagingParamsExist() throws Exception {
SwaggerSpecificationCreator ssc = new SwaggerSpecificationCreator("/v1/");
ssc.BuildJSON();
- SwaggerSpecification spec = ssc.getSwaggerSpecification();
+ Swagger spec = ssc.getSwagger();
- for (Path p : spec.getPaths().getPaths().values()) {
- for (Operation o : p.getOperations().values()) {
+ for (Path p : spec.getPaths().values()) {
+ for (Operation o : p.getOperations()) {
if (o.getOperationId().matches("^getAll[A-Z].*")) {
Assert.assertTrue("Ensure each operation that supports paging has both paging parameters",
operationHasPagingParams(o));