-
Notifications
You must be signed in to change notification settings - Fork 43
Setup
Wicpar edited this page Dec 3, 2019
·
3 revisions
To setup the library in the ktor context, a few initial informations must be registered.
install(OpenAPIGen) {
// basic info
info {
version = "0.0.1"
title = "Test API"
description = "The Test API"
contact {
name = "Support"
email = "[email protected]"
}
}
// describe the server, add as many as you want
server("http://localhost:8080/") {
description = "Test server"
}
//optional
schemaNamer = {
//rename DTOs from java type name to generator compatible form
val regex = Regex("[A-Za-z0-9_.]+")
it.toString().replace(regex) { it.value.split(".").last() }.replace(Regex(">|<|, "), "_")
}
}
// Content negociation is required
install(ContentNegotiation) {
jackson()
}
Enable routing in an Application
or Routing
context
apiRouting {
// declare routes here as you would in ktor, with specified types
}