de.lancom.openapi.jackson.Parser.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openapi-parser Show documentation
Show all versions of openapi-parser Show documentation
This open-source project provides an OpenAPI 3.0 Parser implemented in Kotlin, utilizing immutable data classes
package de.lancom.openapi.jackson
import com.fasterxml.jackson.databind.JsonNode
import de.lancom.openapi.entity.Entity
import de.lancom.openapi.field.Field
interface Parser {
fun parseJsonString(json: String): E {
return parseWrapper(Wrapper.parseJsonString(json))
}
fun parseJsonNode(jsonNode: JsonNode): E {
return parseWrapper(Wrapper(jsonNode))
}
fun parseEntity(wrapper: Wrapper): Field {
return wrapper.getSingle {
Field(parseWrapper(wrapper))
}
}
fun parseEntityOpt(wrapper: Wrapper): Field {
return wrapper.getNullOrElse {
parseEntity(wrapper)
}
}
fun parseWrapper(wrapper: Wrapper): E
}