Skip to content

Commit

Permalink
Improve operation sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias Düsterhöft committed Aug 27, 2018
1 parent d2371c8 commit 3cc0e0b
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ internal object OpenApi20Generator {
private fun groupByPath(resources: List<ResourceModel>): Map<String, List<ResourceModel>> {
return resources.sortedWith(
// by first path segment, then path length, then path
comparing<ResourceModel, String> { it.request.path.split("/").firstOrNull().orEmpty() }
comparing<ResourceModel, String> { it.request.path.split("/").firstOrNull { s -> s.isNotEmpty() }.orEmpty() }
.thenComparing(comparingInt<ResourceModel> { it.request.path.count { c -> c == '/' } })
.thenComparing(comparing<ResourceModel, String> { it.request.path }))
.groupBy { it.request.path }
Expand Down

0 comments on commit 3cc0e0b

Please sign in to comment.