Skip to content

Commit cb19d5e

Browse files
committed
RESTWS-958: Ensure the module's rest is updated to use swagger 3.0
1 parent 551e63f commit cb19d5e

File tree

3 files changed

+44
-20
lines changed

3 files changed

+44
-20
lines changed

omod/pom.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,28 @@
9494
<version>${webservices.restVersion}</version>
9595
<scope>provided</scope>
9696
<type>test-jar</type>
97+
<exclusions>
98+
<exclusion>
99+
<groupId>com.fasterxml.jackson.core</groupId>
100+
<artifactId>jackson-annotations</artifactId>
101+
</exclusion>
102+
<exclusion>
103+
<groupId>com.fasterxml.jackson.core</groupId>
104+
<artifactId>jackson-databind</artifactId>
105+
</exclusion>
106+
<exclusion>
107+
<groupId>com.fasterxml.jackson.dataformat</groupId>
108+
<artifactId>jackson-dataformat-yaml</artifactId>
109+
</exclusion>
110+
<exclusion>
111+
<groupId>com.fasterxml.jackson.core</groupId>
112+
<artifactId>jackson-core</artifactId>
113+
</exclusion>
114+
<exclusion>
115+
<groupId>com.fasterxml.jackson.datatype</groupId>
116+
<artifactId>jackson-datatype-jsr310</artifactId>
117+
</exclusion>
118+
</exclusions>
97119
</dependency>
98120

99121
<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
@@ -10,10 +10,11 @@
1010
import java.util.Arrays;
1111
import java.util.List;
1212

13-
import io.swagger.models.Model;
14-
import io.swagger.models.ModelImpl;
15-
import io.swagger.models.properties.DateProperty;
16-
import io.swagger.models.properties.StringProperty;
13+
import io.swagger.v3.oas.models.media.DateTimeSchema;
14+
import io.swagger.v3.oas.models.media.ObjectSchema;
15+
import io.swagger.v3.oas.models.media.Schema;
16+
import io.swagger.v3.oas.models.media.StringSchema;
17+
import io.swagger.v3.oas.models.media.UUIDSchema;
1718
import org.apache.commons.codec.binary.Base64;
1819
import org.apache.commons.lang3.BooleanUtils;
1920
import org.apache.commons.lang3.StringUtils;
@@ -31,7 +32,6 @@
3132
import org.openmrs.module.attachments.ComplexObsSaver;
3233
import org.openmrs.module.attachments.obs.Attachment;
3334
import org.openmrs.module.attachments.obs.ValueComplex;
34-
import org.openmrs.module.webservices.docs.swagger.core.property.EnumProperty;
3535
import org.openmrs.module.webservices.rest.web.ConversionUtil;
3636
import org.openmrs.module.webservices.rest.web.RequestContext;
3737
import org.openmrs.module.webservices.rest.web.RestConstants;
@@ -191,17 +191,18 @@ public DelegatingResourceDescription getCreatableProperties() {
191191
}
192192

193193
@Override
194-
public Model getCREATEModel(Representation rep) {
195-
return new ModelImpl().property("comment", new StringProperty()).property("dateTime", new DateProperty())
196-
.property("filename", new StringProperty()).property("bytesMimeType", new StringProperty())
197-
198-
.property("bytesContentFamily", new EnumProperty(AttachmentsConstants.ContentFamily.class))
199-
.property("complexData", new StringProperty(StringProperty.Format.URI));
194+
public Schema<?> getCREATESchema(Representation rep) {
195+
return new ObjectSchema().addProperty("comment", new StringSchema()).addProperty("dateTime", new DateTimeSchema())
196+
.addProperty("filename", new StringSchema()).addProperty("bytesMimeType", new StringSchema())
197+
.addProperty("bytesContentFamily",
198+
new Schema<AttachmentsConstants.ContentFamily>()
199+
._enum(Arrays.asList(AttachmentsConstants.ContentFamily.values())))
200+
.addProperty("complexData", new Schema<String>().format("uri"));
200201
}
201202

202203
@Override
203-
public Model getUPDATEModel(Representation rep) {
204-
return getCREATEModel(rep);
204+
public Schema<?> getUPDATESchema(Representation rep) {
205+
return getCREATESchema(rep);
205206
}
206207

207208
@Override
@@ -218,12 +219,13 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
218219
}
219220

220221
@Override
221-
public Model getGETModel(Representation rep) {
222-
ModelImpl model = (ModelImpl) super.getGETModel(rep);
223-
return model.property("uuid", new StringProperty()).property("dateTime", new DateProperty())
224-
.property("filename", new StringProperty()).property("comment", new StringProperty())
225-
.property("bytesMimeType", new StringProperty())
226-
.property("bytesContentFamily", new EnumProperty(AttachmentsConstants.ContentFamily.class));
222+
public Schema<?> getGETSchema(Representation rep) {
223+
Schema<?> model = super.getGETSchema(rep);
224+
return model.addProperty("uuid", new UUIDSchema()).addProperty("dateTime", new DateTimeSchema())
225+
.addProperty("filename", new StringSchema()).addProperty("comment", new StringSchema())
226+
.addProperty("bytesMimeType", new StringSchema())
227+
.addProperty("bytesContentFamily", new Schema<AttachmentsConstants.ContentFamily>()
228+
._enum(Arrays.asList(AttachmentsConstants.ContentFamily.values())));
227229
}
228230

229231
/**

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)