main.io.github.smiley4.ktorswaggerui.routing.ApiSpec.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ktor-swagger-ui Show documentation
Show all versions of ktor-swagger-ui Show documentation
Ktor plugin to document routes and provide a Swagger-UI
package io.github.smiley4.ktorswaggerui.routing
import io.github.smiley4.ktorswaggerui.data.SwaggerUIData
object ApiSpec {
var swaggerUiConfig: SwaggerUIData = SwaggerUIData.DEFAULT
private val apiSpecs = mutableMapOf()
fun setAll(specs: Map) {
apiSpecs.clear()
apiSpecs.putAll(specs)
}
fun set(name: String, spec: String) {
apiSpecs[name] = spec
}
fun get(name: String): String {
return apiSpecs[name] ?: throw NoSuchElementException("No api-spec with name '$name' registered.")
}
fun getAll(): Map {
return apiSpecs
}
}