Skip to content

Commit

Permalink
adds swagger definition to DataSetController#isValidNewName (#5954)
Browse files Browse the repository at this point in the history
* adds swagger definition to DataSetController#isValidNewName
* formart
* format
* rename
  • Loading branch information
normanrz authored Jan 12, 2022
1 parent db4d937 commit 4908b5d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version = "1.5.1"
maxColumn = 120
rewrite.rules = [RedundantBraces, RedundantParens, SortModifiers]
rewrite.redundantBraces.stringInterpolation = false
Expand Down
16 changes: 10 additions & 6 deletions app/controllers/DataSetController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,19 @@ class DataSetController @Inject()(userService: UserService,
Future.successful(JsonBadRequest(Messages("dataSet.type.invalid", typ)))
}

@ApiOperation(hidden = true, value = "")
def isValidNewName(organizationName: String, dataSetName: String): Action[AnyContent] = sil.SecuredAction.async {
implicit request =>
@ApiOperation(value = "Check whether a new dataset name is valid", nickname = "newDatasetNameIsValid")
@ApiResponses(
Array(new ApiResponse(code = 200, message = "Name is valid. Empty message."),
new ApiResponse(code = 400, message = badRequestLabel)))
def isValidNewName(@ApiParam(value = "The url-safe name of the organization owning the dataset",
example = "sample_organization") organizationName: String,
@ApiParam(value = "The name of the dataset") dataSetName: String): Action[AnyContent] =
sil.SecuredAction.async { implicit request =>
for {
_ <- bool2Fox(dataSetService.isProperDataSetName(dataSetName)) ?~> "dataSet.name.invalid"
_ <- dataSetService
.assertNewDataSetName(dataSetName, request.identity._organization) ?~> "dataSet.name.alreadyTaken"
_ <- dataSetService.assertNewDataSetName(dataSetName, request.identity._organization) ?~> "dataSet.name.alreadyTaken"
} yield Ok
}
}

@ApiOperation(hidden = true, value = "")
def getOrganizationForDataSet(dataSetName: String): Action[AnyContent] = sil.UserAwareAction.async {
Expand Down

0 comments on commit 4908b5d

Please sign in to comment.