Skip to content

Commit

Permalink
fix: routes not added to spec with roothost-path
Browse files Browse the repository at this point in the history
  • Loading branch information
SMILEY4 committed Jun 21, 2024
1 parent 425236e commit e432631
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import io.gitlab.arturbosch.detekt.Detekt
object Meta {
const val groupId = "io.github.smiley4"
const val artifactId = "ktor-swagger-ui"
const val version = "2.10.0"
const val version = "2.10.1"
const val name = "Ktor Swagger-UI"
const val description = "Ktor plugin to document routes and provide Swagger UI"
const val licenseName = "The Apache License, Version 2.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,23 @@ class PathsBuilder(
fun build(routes: Collection<RouteMeta>): Paths =
Paths().also {
routes.forEach { route ->
val existingPath = it[route.path]
val fullPath = fullPath(route);
val existingPath = it[fullPath]
if (existingPath != null) {
addToExistingPath(existingPath, route)
} else {
addAsNewPath(it, route)
addAsNewPath(it, route, fullPath)
}
}
}

private fun addAsNewPath(paths: Paths, route: RouteMeta) {
private fun fullPath(route: RouteMeta): String {
val rootPath = ControllerUtils.appConfig?.let { ControllerUtils.getRootPath(it) } ?: ""
paths.addPathItem("$rootPath${route.path}", pathBuilder.build(route))
return "$rootPath${route.path}"
}

private fun addAsNewPath(paths: Paths, route: RouteMeta, fullPath: String) {
paths.addPathItem(fullPath, pathBuilder.build(route))
}

private fun addToExistingPath(existing: PathItem, route: RouteMeta) {
Expand Down

0 comments on commit e432631

Please sign in to comment.