Изменить URL Swagger по умолчанию в ктор - PullRequest
0 голосов
/ 22 апреля 2019

Я настроил Swagger для сервера ktor, но я понятия не имею, как изменить базовый URL с http: //localhost:8080/apidocs/index.html?url=./openapi.json на .... / swaggerЛюбая помощь приветствуется.

внутренний забавный запуск (порт: Int, wait: Boolean = true): ApplicationEngine {println ("Запуск по порту $port") val server = embeddedServer (Netty, port) {

    install(SwaggerSupport) {
        forwardRoot = true
        val information = Information(
        version = "0.1", title = "sample api implemented in ktor", description = "This is a sample which combines [ktor](https://github.com/Kotlin/ktor) with [swaggerUi](https://swagger.io/). You find the sources on [github](https://github.com/nielsfalk/ktor-swagger)")

        swagger = Swagger().apply {
            info = information
            definitions["uri"] = "/swagger"

        }
        openApi = OpenApi().apply {
            info = information

        }
    }

}
return server.start(wait = wait)

}

/ ** * Запускает приложение и обрабатывает аргументы, переданные [main].* / class Launcher: CliktCommand (name = "ktor-sample-swagger") {сопутствующий объект {private const val defaultPort = 8080}

private val port: Int by option("-p", "--port", help = "The port that this server should be started on. Defaults to $defaultPort.").int().

default (defaultPort)

override fun run() {
    run(port)
}

}

fun main (args: Array ) = Launcher (). Main (args)

...