Skip to content

Commit

Permalink
fix: add different sort delimiter cause of spring bug
Browse files Browse the repository at this point in the history
  • Loading branch information
alarv committed Jul 24, 2024
1 parent 144c955 commit a2551b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/main/kotlin/org/jaqpot/api/service/util/SortUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import org.springframework.data.domain.Sort.Order

class SortUtil {
companion object {
private const val SORT_DELIMITER = "|" // Delimiter for sorting parameters

fun parseSortParameters(sortParams: List<String>?): List<Order> {
if (sortParams.isNullOrEmpty()) {
return listOf()
}

return sortParams
.map { sortParam: String ->
val parts = sortParam.split(",".toRegex()).dropLastWhile { it.isEmpty() }
val parts = sortParam.split(SORT_DELIMITER).dropLastWhile { it.isEmpty() }
.toTypedArray()
if (parts.size == 2) {
return@map Order(Sort.Direction.fromString(parts[1]), parts[0])
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ paths:
type: array
items:
type: string
example: [ "field1,asc", "field2,desc" ]
example: [ "field1|asc", "field2|desc" ]
responses:
'200':
description: Paginated list of models
Expand Down Expand Up @@ -128,7 +128,7 @@ paths:
type: array
items:
type: string
example: [ "field1,asc", "field2,desc" ]
example: [ "field1|asc", "field2|desc" ]
responses:
'200':
description: Paginated list of models
Expand Down Expand Up @@ -180,7 +180,7 @@ paths:
type: array
items:
type: string
example: [ "field1,asc", "field2,desc" ]
example: [ "field1|asc", "field2|desc" ]
responses:
'200':
description: Paginated list of shared models
Expand Down Expand Up @@ -492,7 +492,7 @@ paths:
type: array
items:
type: string
example: [ "field1,asc", "field2,desc" ]
example: [ "field1|asc", "field2|desc" ]
responses:
'200':
description: Successful Response
Expand Down Expand Up @@ -764,7 +764,7 @@ paths:
type: array
items:
type: string
example: [ "field1,asc", "field2,desc" ]
example: [ "field1|asc", "field2|desc" ]
responses:
"200":
description: "Models retrieved successfully"
Expand Down

0 comments on commit a2551b8

Please sign in to comment.