fix: Allow for injectable ObjectMapper to resolve serialization issues for Java 8 date type
This commit is contained in:
@ -13,14 +13,19 @@ import io.ktor.routing.route
|
||||
/**
|
||||
* Provides an out-of-the-box route to return the generated [OpenApiSpec]
|
||||
* @param oas spec that is returned
|
||||
* @param om provider for Jackson
|
||||
*/
|
||||
fun Routing.openApi(oas: OpenApiSpec) {
|
||||
val om = ObjectMapper()
|
||||
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
.enable(SerializationFeature.INDENT_OUTPUT)
|
||||
fun Routing.openApi(
|
||||
oas: OpenApiSpec,
|
||||
om: ObjectMapper = objectMapper
|
||||
) {
|
||||
route("/openapi.json") {
|
||||
get {
|
||||
call.respondText { om.writeValueAsString(oas) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val objectMapper = ObjectMapper()
|
||||
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
.enable(SerializationFeature.INDENT_OUTPUT)
|
||||
|
Reference in New Issue
Block a user