Skip to content

Commit e47142d

Browse files
committed
RESTWS-958: Ensure the REST Module Api Docs are upgraded to use Swagger 2.2.23
1 parent 14701fd commit e47142d

File tree

123 files changed

+3927
-4435
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+3927
-4435
lines changed

omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/CareSettingResource1_10.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@
99
*/
1010
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_10;
1111

12+
import java.util.Arrays;
1213
import java.util.Iterator;
1314
import java.util.List;
1415
import java.util.regex.Pattern;
1516

16-
import io.swagger.models.Model;
17-
import io.swagger.models.ModelImpl;
17+
import io.swagger.v3.oas.models.media.Schema;
1818
import org.openmrs.CareSetting;
1919
import org.openmrs.api.context.Context;
20-
import org.openmrs.module.webservices.docs.swagger.core.property.EnumProperty;
2120
import org.openmrs.module.webservices.rest.web.RequestContext;
2221
import org.openmrs.module.webservices.rest.web.RestConstants;
2322
import org.openmrs.module.webservices.rest.web.annotation.Resource;
@@ -71,13 +70,16 @@ public DelegatingResourceDescription getCreatableProperties() {
7170
}
7271

7372
@Override
74-
public Model getGETModel(Representation rep) {
75-
ModelImpl model = (ModelImpl) super.getGETModel(rep);
76-
if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
77-
model
78-
.property("careSettingType", new EnumProperty(CareSetting.CareSettingType.class));
73+
@SuppressWarnings("unchecked")
74+
public Schema<?> getGETSchema(Representation rep) {
75+
Schema<?> schema = super.getGETSchema(rep);
76+
if (schema != null && (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation)) {
77+
schema
78+
.addProperty("careSettingType", new Schema<CareSetting.CareSettingType>()
79+
.type("string")
80+
._enum(Arrays.asList(CareSetting.CareSettingType.values())));
7981
}
80-
return model;
82+
return schema;
8183
}
8284

8385
/**

omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/DrugReferenceMapResource1_10.java

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
*/
1010
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_10;
1111

12+
import io.swagger.v3.oas.models.media.ObjectSchema;
13+
import io.swagger.v3.oas.models.media.Schema;
14+
import io.swagger.v3.oas.models.media.StringSchema;
15+
import org.openmrs.ConceptMapType;
16+
import org.openmrs.ConceptReferenceTerm;
17+
import org.openmrs.Drug;
1218
import org.openmrs.DrugReferenceMap;
1319
import org.openmrs.api.context.Context;
1420
import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter;
@@ -24,11 +30,6 @@
2430
import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException;
2531
import org.openmrs.module.webservices.rest.web.response.ResponseException;
2632

27-
import io.swagger.models.Model;
28-
import io.swagger.models.ModelImpl;
29-
import io.swagger.models.properties.RefProperty;
30-
import io.swagger.models.properties.StringProperty;
31-
3233
import org.openmrs.module.webservices.rest.web.RequestContext;
3334
import org.openmrs.module.webservices.rest.web.RestConstants;
3435

@@ -117,27 +118,36 @@ public DelegatingResourceDescription getCreatableProperties() {
117118
description.addProperty("drug");
118119
return description;
119120
}
120-
121-
public Model getGETModel(Representation rep) {
122-
ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
123-
if (rep instanceof DefaultRepresentation) {
124-
modelImpl.property("display", new StringProperty()).property("uuid", new StringProperty())
125-
.property("drug", new RefProperty("#/definitions/DrugGetRef"))
126-
.property("conceptReferenceTerm", new RefProperty("#/definitions/ConceptreferencetermGetRef"))
127-
.property("conceptMapType", new RefProperty("#/definitions/ConceptmaptypeGetRef"));
128-
} else if (rep instanceof FullRepresentation) {
129-
modelImpl.property("display", new StringProperty()).property("uuid", new StringProperty())
130-
.property("auditInfo", new StringProperty()).property("drug", new RefProperty("#/definitions/DrugGet"))
131-
.property("conceptReferenceTerm", new RefProperty("#/definitions/ConceptreferencetermGet"))
132-
.property("conceptMapType", new RefProperty("#/definitions/ConceptmaptypeGet"));
121+
122+
@Override
123+
public Schema<?> getGETSchema(Representation rep) {
124+
Schema<?> schema = super.getGETSchema(rep);
125+
if (schema != null) {
126+
schema
127+
.addProperty("display", new StringSchema())
128+
.addProperty("uuid", new StringSchema());
129+
130+
if (rep instanceof DefaultRepresentation) {
131+
schema
132+
.addProperty("drug", new Schema<Drug>().$ref("#/components/schemas/DrugGetRef"))
133+
.addProperty("conceptReferenceTerm", new Schema<ConceptReferenceTerm>().$ref("#/components/schemas/ConceptreferencetermGetRef"))
134+
.addProperty("conceptMapType", new Schema<ConceptMapType>().$ref("#/components/schemas/ConceptmaptypeGetRef"));
135+
} else if (rep instanceof FullRepresentation) {
136+
schema
137+
.addProperty("auditInfo", new StringSchema())
138+
.addProperty("drug", new Schema<Drug>().$ref("#/components/schemas/DrugGet"))
139+
.addProperty("conceptReferenceTerm", new Schema<ConceptReferenceTerm>().$ref("#/components/schemas/ConceptreferencetermGet"))
140+
.addProperty("conceptMapType", new Schema<ConceptMapType>().$ref("#/components/schemas/ConceptmaptypeGet"));
141+
}
133142
}
134-
return modelImpl;
143+
return schema;
135144
}
136-
145+
137146
@Override
138-
public Model getCREATEModel(Representation rep) {
139-
return new ModelImpl().property("conceptReferenceTerm", new StringProperty().example("uuid"))
140-
.property("conceptMapType", new StringProperty().example("uuid"))
141-
.property("drug", new StringProperty().example("uuid"));
147+
public Schema<?> getCREATESchema(Representation rep) {
148+
return new ObjectSchema()
149+
.addProperty("conceptReferenceTerm", new StringSchema().example("uuid"))
150+
.addProperty("conceptMapType", new StringSchema().example("uuid"))
151+
.addProperty("drug", new StringSchema().example("uuid"));
142152
}
143153
}

omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/DrugResource1_10.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
*/
1010
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_10;
1111

12+
import io.swagger.v3.oas.models.media.ObjectSchema;
13+
import io.swagger.v3.oas.models.media.Schema;
1214
import org.openmrs.Drug;
15+
import org.openmrs.DrugReferenceMap;
1316
import org.openmrs.module.webservices.rest.web.RestConstants;
1417
import org.openmrs.module.webservices.rest.web.annotation.Resource;
1518
import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation;
@@ -18,10 +21,6 @@
1821
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription;
1922
import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.DrugResource1_8;
2023

21-
import io.swagger.models.Model;
22-
import io.swagger.models.ModelImpl;
23-
import io.swagger.models.properties.RefProperty;
24-
2524
/**
2625
* {@link org.openmrs.module.webservices.rest.web.annotation.Resource} for {@link org.openmrs.Drug},
2726
* supporting standard CRUD operations
@@ -59,22 +58,23 @@ public DelegatingResourceDescription getCreatableProperties() {
5958

6059
return description;
6160
}
62-
63-
public Model getGETModel(Representation rep) {
64-
ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
65-
if (rep instanceof DefaultRepresentation) {
66-
modelImpl
67-
.property("drugReferenceMaps", new RefProperty("#/definitions/DrugreferencemapGetRef"));
68-
} else if (rep instanceof FullRepresentation) {
69-
modelImpl
70-
.property("drugReferenceMaps", new RefProperty("#/definitions/DrugreferencemapGet"));
61+
62+
@Override
63+
public Schema<?> getGETSchema(Representation rep) {
64+
Schema<?> schema = super.getGETSchema(rep);
65+
if (schema != null) {
66+
if (rep instanceof DefaultRepresentation) {
67+
schema.addProperty("drugReferenceMaps", new Schema<DrugReferenceMap>().$ref("#/components/schemas/DrugreferencemapGetRef"));
68+
} else if (rep instanceof FullRepresentation) {
69+
schema.addProperty("drugReferenceMaps", new Schema<DrugReferenceMap>().$ref("#/components/schemas/DrugreferencemapGet"));
70+
}
7171
}
72-
return modelImpl;
72+
return schema;
7373
}
74-
74+
7575
@Override
76-
public Model getCREATEModel(Representation rep) {
77-
return new ModelImpl()
78-
.property("drugReferenceMaps", new RefProperty("#/definitions/DrugreferencemapCreate"));
76+
public Schema<?> getCREATESchema(Representation rep) {
77+
return new ObjectSchema()
78+
.addProperty("drugReferenceMaps", new Schema<DrugReferenceMap>().$ref("#/components/schemas/DrugreferencemapCreate"));
7979
}
8080
}

omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderResource1_10.java

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@
99
*/
1010
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_10;
1111

12-
import io.swagger.models.Model;
13-
import io.swagger.models.ModelImpl;
14-
import io.swagger.models.properties.DateProperty;
15-
import io.swagger.models.properties.RefProperty;
16-
import io.swagger.models.properties.StringProperty;
12+
import io.swagger.v3.oas.models.media.DateTimeSchema;
13+
import io.swagger.v3.oas.models.media.ObjectSchema;
14+
import io.swagger.v3.oas.models.media.Schema;
15+
import io.swagger.v3.oas.models.media.StringSchema;
1716
import org.apache.commons.lang.StringUtils;
1817
import org.openmrs.CareSetting;
18+
import org.openmrs.Concept;
19+
import org.openmrs.Encounter;
1920
import org.openmrs.Order;
2021
import org.openmrs.OrderType;
2122
import org.openmrs.Patient;
23+
import org.openmrs.User;
2224
import org.openmrs.api.context.Context;
23-
import org.openmrs.module.webservices.docs.swagger.core.property.EnumProperty;
2425
import org.openmrs.module.webservices.rest.web.ConversionUtil;
2526
import org.openmrs.module.webservices.rest.web.RequestContext;
2627
import org.openmrs.module.webservices.rest.web.RestConstants;
@@ -31,7 +32,6 @@
3132
import org.openmrs.module.webservices.rest.web.representation.Representation;
3233
import org.openmrs.module.webservices.rest.web.resource.api.PageableResult;
3334
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription;
34-
import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult;
3535
import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging;
3636
import org.openmrs.module.webservices.rest.web.response.InvalidSearchException;
3737
import org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException;
@@ -41,6 +41,7 @@
4141
import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8;
4242

4343
import java.util.ArrayList;
44+
import java.util.Arrays;
4445
import java.util.Collections;
4546
import java.util.Comparator;
4647
import java.util.Date;
@@ -116,41 +117,40 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
116117
}
117118

118119
@Override
119-
public Model getCREATEModel(Representation rep) {
120-
ModelImpl model = new ModelImpl()
121-
.property("encounter", new StringProperty().example("uuid"))
122-
.property("orderType", new StringProperty().example("uuid"))
123-
.property("action", new EnumProperty(Order.Action.class))
124-
.property("accessionNumber", new StringProperty())
125-
.property("dateActivated", new DateProperty())
126-
.property("scheduledDate", new DateProperty())
127-
.property("patient", new StringProperty().example("uuid"))
128-
.property("concept", new StringProperty().example("uuid"))
129-
.property("careSetting", new StringProperty().example("uuid"))
130-
.property("dateStopped", new DateProperty())
131-
.property("autoExpireDate", new DateProperty())
132-
.property("orderer", new StringProperty().example("uuid"))
133-
.property("previousOrder", new StringProperty().example("uuid"))
134-
.property("urgency", new EnumProperty(Order.Urgency.class))
135-
.property("orderReason", new StringProperty().example("uuid"))
136-
.property("orderReasonNonCoded", new StringProperty())
137-
.property("instructions", new StringProperty())
138-
.property("commentToFulfiller", new StringProperty())
139-
140-
.required("orderType").required("patient").required("concept");
120+
public Schema<?> getCREATESchema(Representation rep) {
121+
Schema<?> schema = new ObjectSchema()
122+
.addProperty("encounter", new StringSchema().example("uuid"))
123+
.addProperty("orderType", new StringSchema().example("uuid"))
124+
.addProperty("action", new Schema<Order.Action>()._enum(Arrays.asList(Order.Action.values())))
125+
.addProperty("accessionNumber", new StringSchema())
126+
.addProperty("dateActivated", new DateTimeSchema())
127+
.addProperty("scheduledDate", new DateTimeSchema())
128+
.addProperty("patient", new StringSchema().example("uuid"))
129+
.addProperty("concept", new StringSchema().example("uuid"))
130+
.addProperty("careSetting", new StringSchema().example("uuid"))
131+
.addProperty("dateStopped", new DateTimeSchema())
132+
.addProperty("autoExpireDate", new DateTimeSchema())
133+
.addProperty("orderer", new StringSchema().example("uuid"))
134+
.addProperty("previousOrder", new StringSchema().example("uuid"))
135+
.addProperty("urgency", new Schema<Order.Urgency>()._enum(Arrays.asList(Order.Urgency.values())))
136+
.addProperty("orderReason", new StringSchema().example("uuid"))
137+
.addProperty("orderReasonNonCoded", new StringSchema())
138+
.addProperty("instructions", new StringSchema())
139+
.addProperty("commentToFulfiller", new StringSchema());
140+
schema.setRequired(Arrays.asList("orderType", "patient", "concept"));
141141
if (rep instanceof FullRepresentation) {
142-
model
143-
.property("encounter", new RefProperty("#/definitions/EncounterCreate"))
144-
.property("patient", new RefProperty("#/definitions/PatientCreate"))
145-
.property("concept", new RefProperty("#/definitions/ConceptCreate"))
146-
.property("orderer", new RefProperty("#/definitions/UserCreate"))
147-
.property("previousOrder", new RefProperty("#/definitions/OrderCreate"))
148-
.property("orderReason", new RefProperty("#/definitions/ConceptCreate"))
149-
.property("orderReasonNonCoded", new StringProperty())
150-
.property("instructions", new StringProperty())
151-
.property("commentToFulfiller", new StringProperty());
142+
schema
143+
.addProperty("encounter", new Schema<Encounter>().$ref("#/components/schemas/EncounterCreate"))
144+
.addProperty("patient", new Schema<Patient>().$ref("#/components/schemas/PatientCreate"))
145+
.addProperty("concept", new Schema<Concept>().$ref("#/components/schemas/ConceptCreate"))
146+
.addProperty("orderer", new Schema<User>().$ref("#/components/schemas/UserCreate"))
147+
.addProperty("previousOrder", new Schema<Order>().$ref("#/components/schemas/OrderCreate"))
148+
.addProperty("orderReason", new Schema<Concept>().$ref("#/components/schemas/ConceptCreate"))
149+
.addProperty("orderReasonNonCoded", new StringSchema())
150+
.addProperty("instructions", new StringSchema())
151+
.addProperty("commentToFulfiller", new StringSchema());
152152
}
153-
return model;
153+
return schema;
154154
}
155155

156156
/**

omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderTypeResource1_10.java

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99
*/
1010
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_10;
1111

12+
import java.util.Collections;
1213
import java.util.Iterator;
1314
import java.util.List;
1415
import java.util.regex.Pattern;
1516

16-
import io.swagger.models.Model;
17-
import io.swagger.models.ModelImpl;
18-
import io.swagger.models.properties.ArrayProperty;
19-
import io.swagger.models.properties.RefProperty;
20-
import io.swagger.models.properties.StringProperty;
17+
import io.swagger.v3.oas.models.media.ArraySchema;
18+
import io.swagger.v3.oas.models.media.ObjectSchema;
19+
import io.swagger.v3.oas.models.media.Schema;
20+
import io.swagger.v3.oas.models.media.StringSchema;
21+
import org.openmrs.ConceptClass;
2122
import org.openmrs.OrderType;
2223
import org.openmrs.api.context.Context;
2324
import org.openmrs.module.webservices.rest.web.RequestContext;
@@ -153,31 +154,36 @@ public DelegatingResourceDescription getCreatableProperties() {
153154
}
154155

155156
@Override
156-
public Model getGETModel(Representation rep) {
157-
ModelImpl model = (ModelImpl) super.getGETModel(rep);
157+
public Schema<?> getGETSchema(Representation rep) {
158+
Schema<?> schema = super.getGETSchema(rep);
158159
if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
159-
model
160-
.property("javaClassName", new StringProperty());
160+
schema
161+
.addProperty("javaClassName", new StringSchema());
161162
}
162163
if (rep instanceof DefaultRepresentation) {
163-
model
164-
.property("conceptClasses", new ArrayProperty(new RefProperty("#/definitions/ConceptclassGetRef")))
165-
.property("parent", new RefProperty("#/definitions/OrdertypeGetRef"));
164+
schema
165+
.addProperty("conceptClasses", new ArraySchema().items(new Schema<ConceptClass>().$ref("#/components/schemas/ConceptclassGetRef")))
166+
.addProperty("parent", new Schema<OrderType>().$ref("#/components/schemas/OrdertypeGetRef"));
166167
} else if (rep instanceof FullRepresentation) {
167-
model
168-
.property("conceptClasses", new ArrayProperty(new RefProperty("#/definitions/ConceptclassGet")))
169-
.property("parent", new RefProperty("#/definitions/OrdertypeGet"));
168+
schema
169+
.addProperty("conceptClasses", new ArraySchema().items(new Schema<ConceptClass>().$ref("#/components/schemas/ConceptclassGetFull")))
170+
.addProperty("parent", new Schema<OrderType>().$ref("#/components/schemas/OrdertypeGetFull"));
170171
}
171-
return model;
172+
return schema;
172173
}
173174

174175
@Override
175-
public Model getCREATEModel(Representation rep) {
176-
return ((ModelImpl) super.getCREATEModel(rep))
177-
.property("javaClassName", new StringProperty())
178-
.property("parent", new StringProperty().example("uuid")) //FIXME type
179-
.property("conceptClasses", new ArrayProperty(new StringProperty().example("uuid")))
180-
181-
.required("javaClassName");
176+
public Schema<?> getCREATESchema(Representation rep) {
177+
Schema<?> schema = super.getCREATESchema(rep);
178+
if (schema instanceof ObjectSchema) {
179+
ObjectSchema objectSchema = (ObjectSchema) schema;
180+
objectSchema
181+
.addProperty("javaClassName", new StringSchema())
182+
.addProperty("parent", new StringSchema().example("uuid"))
183+
.addProperty("conceptClasses", new ArraySchema().items(new StringSchema().example("uuid")));
184+
185+
objectSchema.setRequired(Collections.singletonList("javaClassName"));
186+
}
187+
return schema;
182188
}
183189
}

0 commit comments

Comments
 (0)