Skip to content

Commit 3d11e76

Browse files
committed
RESTWS-958: Ensure the module's rest is updated to use swagger 3.0
1 parent 5f0124c commit 3d11e76

3 files changed

Lines changed: 44 additions & 20 deletions

File tree

omod/pom.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,28 @@
106106
<version>${webservices.restVersion}</version>
107107
<scope>provided</scope>
108108
<type>test-jar</type>
109+
<exclusions>
110+
<exclusion>
111+
<groupId>com.fasterxml.jackson.core</groupId>
112+
<artifactId>jackson-annotations</artifactId>
113+
</exclusion>
114+
<exclusion>
115+
<groupId>com.fasterxml.jackson.core</groupId>
116+
<artifactId>jackson-databind</artifactId>
117+
</exclusion>
118+
<exclusion>
119+
<groupId>com.fasterxml.jackson.dataformat</groupId>
120+
<artifactId>jackson-dataformat-yaml</artifactId>
121+
</exclusion>
122+
<exclusion>
123+
<groupId>com.fasterxml.jackson.core</groupId>
124+
<artifactId>jackson-core</artifactId>
125+
</exclusion>
126+
<exclusion>
127+
<groupId>com.fasterxml.jackson.datatype</groupId>
128+
<artifactId>jackson-datatype-jsr310</artifactId>
129+
</exclusion>
130+
</exclusions>
109131
</dependency>
110132

111133
<dependency>

omod/src/main/java/org/openmrs/module/attachments/rest/AttachmentResource.java

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
import java.util.List;
1212
import java.util.stream.Collectors;
1313

14-
import io.swagger.models.Model;
15-
import io.swagger.models.ModelImpl;
16-
import io.swagger.models.properties.DateProperty;
17-
import io.swagger.models.properties.StringProperty;
14+
import io.swagger.v3.oas.models.media.DateTimeSchema;
15+
import io.swagger.v3.oas.models.media.ObjectSchema;
16+
import io.swagger.v3.oas.models.media.Schema;
17+
import io.swagger.v3.oas.models.media.StringSchema;
18+
import io.swagger.v3.oas.models.media.UUIDSchema;
1819
import org.apache.commons.codec.binary.Base64;
1920
import org.apache.commons.collections.CollectionUtils;
2021
import org.apache.commons.lang3.BooleanUtils;
@@ -37,7 +38,6 @@
3738
import org.openmrs.module.attachments.ComplexObsSaver;
3839
import org.openmrs.module.attachments.obs.Attachment;
3940
import org.openmrs.module.attachments.obs.ValueComplex;
40-
import org.openmrs.module.webservices.docs.swagger.core.property.EnumProperty;
4141
import org.openmrs.module.webservices.rest.web.ConversionUtil;
4242
import org.openmrs.module.webservices.rest.web.RequestContext;
4343
import org.openmrs.module.webservices.rest.web.RestConstants;
@@ -216,17 +216,18 @@ public DelegatingResourceDescription getCreatableProperties() {
216216
}
217217

218218
@Override
219-
public Model getCREATEModel(Representation rep) {
220-
return new ModelImpl().property("comment", new StringProperty()).property("dateTime", new DateProperty())
221-
.property("filename", new StringProperty()).property("bytesMimeType", new StringProperty())
222-
223-
.property("bytesContentFamily", new EnumProperty(AttachmentsConstants.ContentFamily.class))
224-
.property("complexData", new StringProperty(StringProperty.Format.URI));
219+
public Schema<?> getCREATESchema(Representation rep) {
220+
return new ObjectSchema().addProperty("comment", new StringSchema()).addProperty("dateTime", new DateTimeSchema())
221+
.addProperty("filename", new StringSchema()).addProperty("bytesMimeType", new StringSchema())
222+
.addProperty("bytesContentFamily",
223+
new Schema<AttachmentsConstants.ContentFamily>()
224+
._enum(Arrays.asList(AttachmentsConstants.ContentFamily.values())))
225+
.addProperty("complexData", new Schema<String>().format("uri"));
225226
}
226227

227228
@Override
228-
public Model getUPDATEModel(Representation rep) {
229-
return getCREATEModel(rep);
229+
public Schema<?> getUPDATESchema(Representation rep) {
230+
return getCREATESchema(rep);
230231
}
231232

232233
@Override
@@ -243,12 +244,13 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
243244
}
244245

245246
@Override
246-
public Model getGETModel(Representation rep) {
247-
ModelImpl model = (ModelImpl) super.getGETModel(rep);
248-
return model.property("uuid", new StringProperty()).property("dateTime", new DateProperty())
249-
.property("filename", new StringProperty()).property("comment", new StringProperty())
250-
.property("bytesMimeType", new StringProperty())
251-
.property("bytesContentFamily", new EnumProperty(AttachmentsConstants.ContentFamily.class));
247+
public Schema<?> getGETSchema(Representation rep) {
248+
Schema<?> model = super.getGETSchema(rep);
249+
return model.addProperty("uuid", new UUIDSchema()).addProperty("dateTime", new DateTimeSchema())
250+
.addProperty("filename", new StringSchema()).addProperty("comment", new StringSchema())
251+
.addProperty("bytesMimeType", new StringSchema())
252+
.addProperty("bytesContentFamily", new Schema<AttachmentsConstants.ContentFamily>()
253+
._enum(Arrays.asList(AttachmentsConstants.ContentFamily.values())));
252254
}
253255

254256
/**

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
<properties>
3838
<openMRSVersion>2.2.0</openMRSVersion>
39-
<webservices.restVersion>2.33.0</webservices.restVersion>
39+
<webservices.restVersion>2.46.0-SNAPSHOT</webservices.restVersion>
4040
<serialization.xstreamVersion>0.2.8</serialization.xstreamVersion>
4141
<javaxVersion>3.0.1</javaxVersion>
4242
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

0 commit comments

Comments
 (0)