From 48cc2b955206eca90a0ef7d4a7c52f96182bfbe2 Mon Sep 17 00:00:00 2001 From: Florian M Date: Wed, 18 May 2022 13:30:36 +0200 Subject: [PATCH] Fix swagger list-of-string type annotation (#6217) --- app/controllers/DataSetController.scala | 22 ++++++------------- .../annotation/AnnotationUploadService.scala | 5 +---- .../WKRemoteTracingStoreClient.scala | 1 - .../util/swaggerhelpers/ListOfString.scala | 4 ++++ 4 files changed, 12 insertions(+), 20 deletions(-) create mode 100644 util/src/main/scala/com/scalableminds/util/swaggerhelpers/ListOfString.scala diff --git a/app/controllers/DataSetController.scala b/app/controllers/DataSetController.scala index 89ff457505a..6075e7483e5 100755 --- a/app/controllers/DataSetController.scala +++ b/app/controllers/DataSetController.scala @@ -6,28 +6,20 @@ import com.scalableminds.util.geometry.Vec3Int import com.scalableminds.util.mvc.Filter import com.scalableminds.util.tools.DefaultConverters._ import com.scalableminds.util.tools.{Fox, JsonHelper, Math} -import io.swagger.annotations.{ - Api, - ApiImplicitParam, - ApiImplicitParams, - ApiOperation, - ApiParam, - ApiResponse, - ApiResponses -} +import io.swagger.annotations._ +import javax.inject.Inject +import models.analytics.{AnalyticsService, ChangeDatasetSettingsEvent, OpenDatasetEvent} import models.binary._ +import models.organization.OrganizationDAO import models.team.TeamDAO import models.user.{User, UserDAO, UserService} +import oxalis.mail.{MailchimpClient, MailchimpTag} import oxalis.security.{URLSharing, WkEnv} import play.api.i18n.{Messages, MessagesProvider} import play.api.libs.functional.syntax._ import play.api.libs.json._ -import utils.ObjectId -import javax.inject.Inject -import models.analytics.{AnalyticsService, ChangeDatasetSettingsEvent, OpenDatasetEvent} -import models.organization.OrganizationDAO -import oxalis.mail.{MailchimpClient, MailchimpTag} import play.api.mvc.{Action, AnyContent} +import utils.ObjectId import scala.concurrent.duration._ import scala.concurrent.{ExecutionContext, Future} @@ -330,7 +322,7 @@ Expects: Array( new ApiImplicitParam(name = "datasetUpdateTeamsInformation", required = true, - dataType = "List[String]", + dataType = "com.scalableminds.util.swaggerhelpers.ListOfString", paramType = "body"))) def updateTeams(@ApiParam(value = "The url-safe name of the organization owning the dataset", example = "sample_organization") organizationName: String, diff --git a/app/models/annotation/AnnotationUploadService.scala b/app/models/annotation/AnnotationUploadService.scala index 84f5bb44a59..90f16e81a66 100644 --- a/app/models/annotation/AnnotationUploadService.scala +++ b/app/models/annotation/AnnotationUploadService.scala @@ -15,15 +15,12 @@ import net.liftweb.util.Helpers.tryo import oxalis.files.TempFileService import play.api.i18n.MessagesProvider -import scala.concurrent.ExecutionContext - case class UploadedVolumeLayer(tracing: VolumeTracing, dataZipLocation: String, name: Option[String]) { def getDataZipFrom(otherFiles: Map[String, File]): Option[File] = otherFiles.get(dataZipLocation) } -class AnnotationUploadService @Inject()(tempFileService: TempFileService)(implicit ec: ExecutionContext) - extends LazyLogging { +class AnnotationUploadService @Inject()(tempFileService: TempFileService) extends LazyLogging { private def extractFromNml(file: File, name: String, overwritingDataSetName: Option[String], isTaskUpload: Boolean)( implicit m: MessagesProvider): NmlParseResult = diff --git a/app/models/annotation/WKRemoteTracingStoreClient.scala b/app/models/annotation/WKRemoteTracingStoreClient.scala index debea369190..3e6ef631f87 100644 --- a/app/models/annotation/WKRemoteTracingStoreClient.scala +++ b/app/models/annotation/WKRemoteTracingStoreClient.scala @@ -9,7 +9,6 @@ import com.scalableminds.util.tools.Fox.bool2Fox import com.scalableminds.util.tools.JsonHelper.{boxFormat, optionFormat} import com.scalableminds.webknossos.datastore.SkeletonTracing.{SkeletonTracing, SkeletonTracings} import com.scalableminds.webknossos.datastore.VolumeTracing.{VolumeTracing, VolumeTracings} -import com.scalableminds.webknossos.datastore.models.datasource.DataSourceLike import com.scalableminds.webknossos.datastore.rpc.RPC import com.scalableminds.webknossos.tracingstore.tracings.TracingSelector import com.scalableminds.webknossos.tracingstore.tracings.volume.ResolutionRestrictions diff --git a/util/src/main/scala/com/scalableminds/util/swaggerhelpers/ListOfString.scala b/util/src/main/scala/com/scalableminds/util/swaggerhelpers/ListOfString.scala new file mode 100644 index 00000000000..aac574d38a6 --- /dev/null +++ b/util/src/main/scala/com/scalableminds/util/swaggerhelpers/ListOfString.scala @@ -0,0 +1,4 @@ +package com.scalableminds.util.swaggerhelpers + +// Use in swagger annotations for List[String] body type +abstract class ListOfString extends java.util.List[String]