main.io.github.smiley4.ktorswaggerui.data.SchemaConfigData.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.data
import io.github.smiley4.schemakenerator.core.connectSubTypes
import io.github.smiley4.schemakenerator.core.handleNameAnnotation
import io.github.smiley4.schemakenerator.reflection.collectSubTypes
import io.github.smiley4.schemakenerator.reflection.processReflection
import io.github.smiley4.schemakenerator.swagger.compileReferencingRoot
import io.github.smiley4.schemakenerator.swagger.data.CompiledSwaggerSchema
import io.github.smiley4.schemakenerator.swagger.data.TitleType
import io.github.smiley4.schemakenerator.swagger.generateSwaggerSchema
import io.github.smiley4.schemakenerator.swagger.handleCoreAnnotations
import io.github.smiley4.schemakenerator.swagger.withAutoTitle
import kotlin.reflect.KType
/**
* Common configuration for schemas.
*/
data class SchemaConfigData(
val schemas: Map,
val generator: (type: KType) -> CompiledSwaggerSchema,
val overwrite: Map,
val securitySchemas: List
) {
companion object {
val DEFAULT = SchemaConfigData(
schemas = emptyMap(),
generator = { type ->
type
.collectSubTypes()
.processReflection()
.connectSubTypes()
.handleNameAnnotation()
.generateSwaggerSchema()
.handleCoreAnnotations()
.withAutoTitle(TitleType.SIMPLE)
.compileReferencingRoot()
},
overwrite = emptyMap(),
securitySchemas = emptyList()
)
}
}