Feature/swagger UI (#34)

This commit is contained in:
dpnolte
2021-04-23 14:44:26 +02:00
committed by GitHub
parent d0767aa74e
commit ea09aa72e2
16 changed files with 199 additions and 40 deletions

View File

@ -0,0 +1,39 @@
plugins {
`java-library`
`maven-publish`
}
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation(libs.bundles.ktor)
api(libs.ktor.webjars)
implementation(libs.webjars.swagger.ui)
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.0")
testImplementation("io.ktor:ktor-server-test-host:1.5.3")
}
java {
withSourcesJar()
}
publishing {
repositories {
maven {
name = "GithubPackages"
url = uri("https://maven.pkg.github.com/lg-backbone/kompendium")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
publications {
create<MavenPublication>("kompendium") {
from(components["kotlin"])
artifact(tasks.sourcesJar)
}
}
}

View File

@ -0,0 +1,12 @@
package org.leafygreens.kompendium.swagger
import io.ktor.application.call
import io.ktor.response.respondRedirect
import io.ktor.routing.Routing
import io.ktor.routing.get
fun Routing.swaggerUI(openApiJsonUrl: String = "/openapi.json") {
get("/swagger-ui") {
call.respondRedirect("/webjars/swagger-ui/index.html?url=$openApiJsonUrl", true)
}
}