Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RESTWS-957: Fix Swagger errors displayed on the openmrs swagger api docs page #76

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import java.util.Map;
import java.util.Optional;

import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.*;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.openmrs.PersonName;
Expand Down Expand Up @@ -127,6 +130,56 @@ public DelegatingResourceDescription getCreatableProperties() throws ResourceDoe
return description;
}

@Override
public Model getGETModel(Representation rep) {
ModelImpl model = (ModelImpl) super.getGETModel(rep);
if (rep instanceof RefRepresentation || rep instanceof DefaultRepresentation) {
model.property("uuid", new StringProperty()).property("queue", new RefProperty("#/definitions/QueueGetRef"))
.property("display", new StringProperty())
.property("status", new RefProperty("#/definitions/ConceptGetRef"))
.property("priority", new RefProperty("#/definitions/ConceptGetRef"))
.property("priorityComment", new StringProperty())
.property("patient", new RefProperty("#/definitions/PatientGetRef"))
.property("visit", new RefProperty("#/definitions/VisitGetRef"))
.property("sortWeight", new DoubleProperty()).property("startedAt", new DateProperty())
.property("endedAt", new DateProperty())
.property("locationWaitingFor", new RefProperty("#/definitions/LocationGetRef"))
.property("queueComingFrom", new RefProperty("#/definitions/QueueGetRef"))
.property("providerWaitingFor", new RefProperty("#/definitions/ProviderGetRef"));
} else if (rep instanceof FullRepresentation) {
model.property("uuid", new StringProperty()).property("queue", new RefProperty("#/definitions/QueueGetRef"))
.property("display", new StringProperty())
.property("status", new RefProperty("#/definitions/ConceptGetRef"))
.property("priority", new RefProperty("#/definitions/ConceptGetRef"))
.property("priorityComment", new StringProperty())
.property("patient", new RefProperty("#/definitions/PatientGetRef"))
.property("visit", new RefProperty("#/definitions/VisitGetRef"))
.property("sortWeight", new DoubleProperty()).property("startedAt", new DateProperty())
.property("endedAt", new DateProperty())
.property("locationWaitingFor", new RefProperty("#/definitions/LocationGetRef"))
.property("queueComingFrom", new RefProperty("#/definitions/QueueGetRef"))
.property("providerWaitingFor", new RefProperty("#/definitions/ProviderGetRef"))
.property("voided", new BooleanProperty()).property("voidedReason", new StringProperty())
.property("auditInfo", new StringProperty())
.property("previousQueueEntry", new RefProperty("#/definitions/QueueGetRef"));
}
return model;
}

@Override
public Model getCREATEModel(Representation rep) {
return new ModelImpl().property("queue", new RefProperty("#/definitions/QueueCreate"))
.property("status", new RefProperty("#/definitions/ConceptCreate"))
.property("priority", new RefProperty("#/definitions/ConceptCreate"))
.property("priorityComment", new StringProperty())
.property("patient", new RefProperty("#/definitions/PatientCreate"))
.property("visit", new RefProperty("#/definitions/VisitCreate")).property("sortWeight", new DoubleProperty())
.property("startedAt", new DateProperty())
.property("locationWaitingFor", new RefProperty("#/definitions/LocationCreate"))
.property("queueComingFrom", new RefProperty("#/definitions/QueueCreate"))
.property("providerWaitingFor", new RefProperty("#/definitions/ProviderCreate"));
}

@Override
public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException {
DelegatingResourceDescription description = new DelegatingResourceDescription();
Expand All @@ -141,6 +194,16 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe
return description;
}

@Override
public Model getUPDATEModel(Representation rep) {
return new ModelImpl().property("status", new RefProperty("#/definitions/ConceptCreate"))
.property("priority", new RefProperty("#/definitions/ConceptCreate"))
.property("priorityComment", new StringProperty()).property("sortWeight", new DoubleProperty())
.property("startedAt", new DateProperty()).property("endedAt", new DateProperty())
.property("locationWaitingFor", new RefProperty("#/definitions/LocationCreate"))
.property("providerWaitingFor", new RefProperty("#/definitions/ProviderCreate"));
}

@Override
public DelegatingResourceDescription getRepresentationDescription(Representation representation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import java.util.Collections;
import java.util.Optional;

import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.*;
import org.openmrs.api.context.Context;
import org.openmrs.module.queue.api.QueueServicesWrapper;
import org.openmrs.module.queue.api.search.QueueEntrySearchCriteria;
Expand Down Expand Up @@ -116,6 +119,18 @@ public DelegatingResourceDescription getCreatableProperties() throws ResourceDoe
return description;
}

@Override
public Model getCREATEModel(Representation rep) {
return new ModelImpl().property("priorityComment", new StringProperty()).property("sortWeight", new DoubleProperty())
.property("startedAt", new DateProperty())
.property("patient", new RefProperty("#/definitions/PatientCreate"))
.property("priority", new RefProperty("#/definitions/ConceptCreate"))
.property("locationWaitingFor", new RefProperty("#/definitions/LocationCreate"))
.property("queueComingFrom", new RefProperty("#/definitions/QueueCreate"))
.property("status", new RefProperty("#/definitions/ConceptCreate"))
.property("providerWaitingFor", new RefProperty("#/definitions/ProviderCreate"));
}

@Override
public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException {
DelegatingResourceDescription description = new DelegatingResourceDescription();
Expand All @@ -125,6 +140,12 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe
return description;
}

@Override
public Model getUPDATEModel(Representation rep) {
return new ModelImpl().property("priorityComment", new StringProperty()).property("sortWeight", new DoubleProperty())
.property("endedAt", new DateProperty());
}

@Override
public DelegatingResourceDescription getRepresentationDescription(Representation representation) {
DelegatingResourceDescription resourceDescription = new DelegatingResourceDescription();
Expand Down Expand Up @@ -177,6 +198,36 @@ private void addSharedResourceDescriptionProperties(DelegatingResourceDescriptio
resourceDescription.addProperty("endedAt");
}

@Override
public Model getGETModel(Representation rep) {
ModelImpl model = (ModelImpl) super.getGETModel(rep);
if (rep instanceof RefRepresentation || rep instanceof DefaultRepresentation) {
model.property("uuid", new StringProperty()).property("display", new StringProperty())
.property("sortWeight", new DoubleProperty()).property("startedAt", new DateProperty())
.property("endedAt", new DateProperty())
.property("status", new RefProperty("#/definitions/ConceptGetRef"))
.property("priority", new RefProperty("#/definitions/ConceptGetRef"))
.property("priorityComment", new StringProperty())
.property("patient", new RefProperty("#/definitions/PatientGetRef"))
.property("locationWaitingFor", new RefProperty("#/definitions/LocationGetRef"))
.property("queueComingFrom", new RefProperty("#/definitions/QueueGetRef"))
.property("providerWaitingFor", new RefProperty("#/definitions/ProviderGetRef"));
} else if (rep instanceof FullRepresentation) {
model.property("uuid", new StringProperty()).property("display", new StringProperty())
.property("sortWeight", new DoubleProperty()).property("startedAt", new DateProperty())
.property("endedAt", new DateProperty())
.property("status", new RefProperty("#/definitions/ConceptGetFull"))
.property("priority", new RefProperty("#/definitions/ConceptGetFull"))
.property("priorityComment", new StringProperty()).property("voided", new BooleanProperty())
.property("voidedReason", new StringProperty()).property("auditInfo", new StringProperty())
.property("patient", new RefProperty("#/definitions/PatientGetRef"))
.property("locationWaitingFor", new RefProperty("#/definitions/LocationGetFull"))
.property("queueComingFrom", new RefProperty("#/definitions/QueueGetFull"))
.property("providerWaitingFor", new RefProperty("#/definitions/ProviderGetFull"));
}
return model;
}

@PropertyGetter("display")
public String getDisplay(QueueEntry queueEntry) {
//Display patient name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
import java.util.Map;
import java.util.Optional;

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.api.context.Context;
import org.openmrs.module.queue.api.QueueServicesWrapper;
import org.openmrs.module.queue.api.search.QueueSearchCriteria;
Expand Down Expand Up @@ -152,6 +156,51 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe
return this.getCreatableProperties();
}

@Override
public Model getGETModel(Representation rep) {
ModelImpl model = (ModelImpl) super.getGETModel(rep);
if (rep instanceof RefRepresentation) {
model.property("uuid", new StringProperty().example("uuid")).property("display", new StringProperty())
.property("name", new StringProperty()).property("description", new StringProperty());
}
if (rep instanceof DefaultRepresentation) {
model.property("uuid", new StringProperty().example("uuid")).property("display", new StringProperty())
.property("name", new StringProperty()).property("description", new StringProperty())
.property("location", new RefProperty("#/definitions/LocationGet"))
.property("service", new RefProperty("#/definitions/ConceptGet"))
.property("priorityConceptSet", new RefProperty("#/definitions/ConceptGet"))
.property("statusConceptSet", new RefProperty("#/definitions/ConceptGet"))
.property("allowedPriorities", new RefProperty("#/definitions/ConceptGet"))
.property("allowedStatuses", new RefProperty("#/definitions/ConceptGet"));
}
if (rep instanceof FullRepresentation) {
model.property("uuid", new StringProperty().example("uuid")).property("display", new StringProperty())
.property("name", new StringProperty()).property("description", new StringProperty())
.property("location", new RefProperty("#/definitions/LocationGet"))
.property("service", new RefProperty("#/definitions/ConceptGet"))
.property("priorityConceptSet", new RefProperty("#/definitions/ConceptGet"))
.property("statusConceptSet", new RefProperty("#/definitions/ConceptGet"))
.property("allowedPriorities", new RefProperty("#/definitions/ConceptGet"))
.property("allowedStatuses", new RefProperty("#/definitions/ConceptGet"))
.property("auditInfo", new StringProperty());
}
return model;
}

@Override
public Model getCREATEModel(Representation rep) {
return new ModelImpl().property("name", new StringProperty()).property("description", new StringProperty())
.property("location", new RefProperty("#/definitions/LocationCreate"))
.property("service", new RefProperty("#/definitions/ConceptCreate"))
.property("priorityConceptSet", new RefProperty("#/definitions/ConceptCreate"))
.property("statusConceptSet", new RefProperty("#/definitions/ConceptCreate"));
}

@Override
public Model getUPDATEModel(Representation rep) {
return getCREATEModel(rep);
}

@Override
@SuppressWarnings("unchecked")
protected PageableResult doSearch(RequestContext requestContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
import java.util.Map;
import java.util.Optional;

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.api.context.Context;
import org.openmrs.module.queue.api.QueueServicesWrapper;
import org.openmrs.module.queue.api.search.QueueRoomSearchCriteria;
Expand Down Expand Up @@ -142,6 +146,38 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe
return this.getCreatableProperties();
}

@Override
public Model getGETModel(Representation rep) {
ModelImpl model = (ModelImpl) super.getGETModel(rep);
if (rep instanceof DefaultRepresentation) {
model.property("uuid", new StringProperty()).property("display", new StringProperty())
.property("name", new StringProperty()).property("description", new StringProperty())
.property("queue", new RefProperty("#/definitions/QueueGet"));
}
if (rep instanceof FullRepresentation) {
model.property("queue", new RefProperty("#/definitions/QueueGetFull"))
.property("auditInfo", new StringProperty()).property("queue", new StringProperty());
}

if (rep instanceof RefRepresentation) {
model.property("uuid", new StringProperty()).property("display", new StringProperty())
.property("name", new StringProperty()).property("description", new StringProperty())
.property("queue", new RefProperty("#/definitions/QueueGetRef"));
}
return model;
}

@Override
public Model getCREATEModel(Representation rep) {
return new ModelImpl().property("name", new StringProperty()).property("description", new StringProperty())
.property("queue", new RefProperty("#/definitions/QueueCreate"));
}

@Override
public Model getUPDATEModel(Representation rep) {
return getCREATEModel(rep);
}

@PropertyGetter("display")
public String getDisplay(QueueRoom queueRoom) {
return queueRoom.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
import java.util.Map;
import java.util.Optional;

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.api.context.Context;
import org.openmrs.module.queue.api.QueueServicesWrapper;
import org.openmrs.module.queue.api.search.RoomProviderMapSearchCriteria;
Expand Down Expand Up @@ -141,4 +145,36 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe
return this.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("queueRoom", new StringProperty()).property("provider",
new RefProperty("#/definitions/ProviderGetRef"));
}
if (rep instanceof FullRepresentation) {
model.property("provider", new RefProperty("#/definitions/ProviderGet"));
}
return model;
}

@Override
public Model getCREATEModel(Representation rep) {
ModelImpl model = new ModelImpl().property("provider", new StringProperty().example("uuid")).property("queueRoom",
new StringProperty().example("uuid"));
if (rep instanceof FullRepresentation) {
model.property("provider", new RefProperty("#/definitions/ProviderCreate"));
}
return model;
}

@Override
public Model getUPDATEModel(Representation rep) {
ModelImpl model = new ModelImpl().property("provider", new StringProperty().example("uuid")).property("queueRoom",
new StringProperty().example("uuid"));
if (rep instanceof FullRepresentation) {
model.property("provider", new RefProperty("#/definitions/ProviderCreate"));
}
return model;
}
}
17 changes: 17 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<version>1.5.0</version>
<dependencies>
<!-- Needed because of maven 3.9.0 backward compatibility issue,
See : https://github.com/revelc/impsort-maven-plugin/issues/64 -->
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.5.1</version>
</dependency>
</dependencies>
Comment on lines +312 to +320
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes here are also changes we should make to the archetype for modules.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noted!, will make a commit to the sdk for it

<configuration>
<groups>javax, java, *</groups>
<removeUnused>true</removeUnused>
Expand All @@ -321,6 +330,14 @@
</execution>
</executions>
</plugin>
<!-- Pour contourner un bug à la génération par Spring-boot 2.4.x :
Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources) on project application-etude: Input length = 1 -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est en français pourquoi? Et aussi, pourquoi la référence à Spring Boot?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pâte stackoverflow, permettez-moi de mettre à jour cela. 😄

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
</plugin>

</plugins>
</pluginManagement>
</build>
Expand Down
Loading