main.io.github.smiley4.schemakenerator.jackson.steps.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of schema-kenerator-jackson Show documentation
Show all versions of schema-kenerator-jackson Show documentation
Kotlin library for automatically generating various schemas - adds support for Jackson
The newest version!
package io.github.smiley4.schemakenerator.jackson
import io.github.smiley4.schemakenerator.core.data.BaseTypeData
import io.github.smiley4.schemakenerator.core.data.Bundle
import io.github.smiley4.schemakenerator.jackson.steps.JacksonIgnorePropertiesStep
import io.github.smiley4.schemakenerator.jackson.steps.JacksonIgnoreStep
import io.github.smiley4.schemakenerator.jackson.steps.JacksonIgnoreTypeStep
import io.github.smiley4.schemakenerator.jackson.steps.JacksonPropertyStep
import io.github.smiley4.schemakenerator.jackson.steps.JacksonSubTypeStep
import kotlin.reflect.KType
/**
* Handles the jackson "JsonSubTypes"-annotation.
* See [JacksonSubTypeStep] for more info.
*/
fun KType.collectJacksonSubTypes(typeProcessing: (type: KType) -> Bundle, maxRecursionDepth: Int = 10): Bundle {
return JacksonSubTypeStep(
typeProcessing = typeProcessing,
maxRecursionDepth = maxRecursionDepth
).process(this)
}
/**
* Handles the jackson annotations "JsonIgnore", "JsonIgnoreType", "JsonIgnoreProperties", "JsonProperty".
* See [JacksonIgnoreStep], [JacksonIgnoreTypeStep], [JacksonIgnorePropertiesStep], [JacksonPropertyStep] for more info.
*/
fun Bundle.handleJacksonAnnotations(): Bundle {
return this
.let { JacksonIgnoreStep().process(this) }
.let { JacksonIgnoreTypeStep().process(this) }
.let { JacksonIgnorePropertiesStep().process(this) }
.let { JacksonPropertyStep().process(this) }
}