Skip to content

Commit

Permalink
RESTWS-958: Ensure the module's rest is updated to use swagger 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mherman22 committed Nov 14, 2024
1 parent 5f0124c commit 3d11e76
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 20 deletions.
22 changes: 22 additions & 0 deletions omod/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,28 @@
<version>${webservices.restVersion}</version>
<scope>provided</scope>
<type>test-jar</type>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
import java.util.List;
import java.util.stream.Collectors;

import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.DateProperty;
import io.swagger.models.properties.StringProperty;
import io.swagger.v3.oas.models.media.DateTimeSchema;
import io.swagger.v3.oas.models.media.ObjectSchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.StringSchema;
import io.swagger.v3.oas.models.media.UUIDSchema;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
Expand All @@ -37,7 +38,6 @@
import org.openmrs.module.attachments.ComplexObsSaver;
import org.openmrs.module.attachments.obs.Attachment;
import org.openmrs.module.attachments.obs.ValueComplex;
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.RestConstants;
Expand Down Expand Up @@ -216,17 +216,18 @@ public DelegatingResourceDescription getCreatableProperties() {
}

@Override
public Model getCREATEModel(Representation rep) {
return new ModelImpl().property("comment", new StringProperty()).property("dateTime", new DateProperty())
.property("filename", new StringProperty()).property("bytesMimeType", new StringProperty())

.property("bytesContentFamily", new EnumProperty(AttachmentsConstants.ContentFamily.class))
.property("complexData", new StringProperty(StringProperty.Format.URI));
public Schema<?> getCREATESchema(Representation rep) {
return new ObjectSchema().addProperty("comment", new StringSchema()).addProperty("dateTime", new DateTimeSchema())
.addProperty("filename", new StringSchema()).addProperty("bytesMimeType", new StringSchema())
.addProperty("bytesContentFamily",
new Schema<AttachmentsConstants.ContentFamily>()
._enum(Arrays.asList(AttachmentsConstants.ContentFamily.values())))
.addProperty("complexData", new Schema<String>().format("uri"));
}

@Override
public Model getUPDATEModel(Representation rep) {
return getCREATEModel(rep);
public Schema<?> getUPDATESchema(Representation rep) {
return getCREATESchema(rep);
}

@Override
Expand All @@ -243,12 +244,13 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
}

@Override
public Model getGETModel(Representation rep) {
ModelImpl model = (ModelImpl) super.getGETModel(rep);
return model.property("uuid", new StringProperty()).property("dateTime", new DateProperty())
.property("filename", new StringProperty()).property("comment", new StringProperty())
.property("bytesMimeType", new StringProperty())
.property("bytesContentFamily", new EnumProperty(AttachmentsConstants.ContentFamily.class));
public Schema<?> getGETSchema(Representation rep) {
Schema<?> model = super.getGETSchema(rep);
return model.addProperty("uuid", new UUIDSchema()).addProperty("dateTime", new DateTimeSchema())
.addProperty("filename", new StringSchema()).addProperty("comment", new StringSchema())
.addProperty("bytesMimeType", new StringSchema())
.addProperty("bytesContentFamily", new Schema<AttachmentsConstants.ContentFamily>()
._enum(Arrays.asList(AttachmentsConstants.ContentFamily.values())));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<properties>
<openMRSVersion>2.2.0</openMRSVersion>
<webservices.restVersion>2.33.0</webservices.restVersion>
<webservices.restVersion>2.46.0-SNAPSHOT</webservices.restVersion>
<serialization.xstreamVersion>0.2.8</serialization.xstreamVersion>
<javaxVersion>3.0.1</javaxVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down

0 comments on commit 3d11e76

Please sign in to comment.