explicit decoupled serialization (#65)
This commit is contained in:
@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## [1.2.3] - June 3rd, 2021
|
||||
|
||||
### Added
|
||||
|
||||
- Updates showing/explaining serializer agnostic approach
|
||||
|
||||
## [1.2.2] - May 23rd, 2021
|
||||
|
||||
This is just to get my repo back to normal now that I have confirmed sonatype publish is happening
|
||||
|
10
README.md
10
README.md
@ -102,6 +102,16 @@ Out of the box, Kompendium has support for sealed classes. At runtime, it will b
|
||||
and build a spec that takes `anyOf` the implementations. This is currently a weak point of the entire library, and
|
||||
suggestions on better implementations are welcome 🤠
|
||||
|
||||
### Serialization
|
||||
|
||||
Kompendium is serialization agnostic, meaning that there is no serializer library included out of the box. This grants
|
||||
developer flexibility, at the cost of some potential extra legwork. The example in the playground shows Jackson working
|
||||
pretty much out of the box, but more explicit serializers like Moshi and Kotlinx Serialization will require registering
|
||||
custom serializers in order to encode the api spec payload.
|
||||
|
||||
This overhead is annoying, and will hopefully be reduced in the future. Should you have ideas on how to tackle this
|
||||
issue, please head on over to the discussion on this topic [here](https://github.com/bkbnio/kompendium/discussions/64)
|
||||
|
||||
## Examples
|
||||
|
||||
The full source code can be found in the `kompendium-playground` module. Here is a simple get endpoint example
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Kompendium
|
||||
project.version=1.2.2
|
||||
project.version=1.2.3
|
||||
# Kotlin
|
||||
kotlin.code.style=official
|
||||
# Gradle
|
||||
|
@ -24,6 +24,6 @@ logback-core = { group = "ch.qos.logback", name = "logback-core", version.ref =
|
||||
webjars-swagger-ui = { group = "org.webjars", name = "swagger-ui", version.ref = "swagger-ui" }
|
||||
|
||||
[bundles]
|
||||
ktor = [ "ktor-server-core", "ktor-server-netty", "ktor-jackson", "ktor-html-builder" ]
|
||||
ktor = [ "ktor-server-core", "ktor-server-netty", "ktor-html-builder" ]
|
||||
ktorAuth = [ "ktor-auth-lib", "ktor-auth-jwt" ]
|
||||
logging = [ "slf4j", "logback-classic", "logback-core" ]
|
||||
|
@ -11,6 +11,7 @@ dependencies {
|
||||
implementation(libs.bundles.ktorAuth)
|
||||
implementation(projects.kompendiumCore)
|
||||
|
||||
testImplementation(libs.ktor.jackson)
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
|
||||
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.0")
|
||||
|
@ -10,6 +10,7 @@ dependencies {
|
||||
implementation(libs.bundles.ktor)
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
|
||||
testImplementation(libs.ktor.jackson)
|
||||
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.0")
|
||||
testImplementation("io.ktor:ktor-server-test-host:1.5.3")
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
plugins {
|
||||
kotlin("plugin.serialization") version "1.5.0"
|
||||
application
|
||||
}
|
||||
|
||||
@ -11,6 +12,7 @@ dependencies {
|
||||
implementation(projects.kompendiumSwaggerUi)
|
||||
|
||||
implementation(libs.bundles.ktor)
|
||||
implementation(libs.ktor.jackson)
|
||||
implementation(libs.bundles.ktorAuth)
|
||||
implementation(libs.bundles.logging)
|
||||
|
||||
|
@ -91,46 +91,46 @@ fun Application.mainModule() {
|
||||
openApi(oas)
|
||||
redoc(oas)
|
||||
swaggerUI()
|
||||
// route("/potato/spud") {
|
||||
// notarizedGet(testGetWithExamples) {
|
||||
// call.respond(HttpStatusCode.OK)
|
||||
// }
|
||||
// notarizedPost(testPostWithExamples) {
|
||||
// call.respond(HttpStatusCode.Created, ExampleResponse("hey"))
|
||||
// }
|
||||
// }
|
||||
route("/potato/spud") {
|
||||
notarizedGet(testGetWithExamples) {
|
||||
call.respond(HttpStatusCode.OK)
|
||||
}
|
||||
notarizedPost(testPostWithExamples) {
|
||||
call.respond(HttpStatusCode.Created, ExampleResponse("hey"))
|
||||
}
|
||||
}
|
||||
route("/test") {
|
||||
route("/{id}") {
|
||||
notarizedGet(testIdGetInfo) {
|
||||
call.respondText("get by id")
|
||||
}
|
||||
}
|
||||
// route("/single") {
|
||||
// notarizedGet(testSingleGetInfo) {
|
||||
// call.respondText("get single")
|
||||
// }
|
||||
// notarizedPost(testSinglePostInfo) {
|
||||
// call.respondText("test post")
|
||||
// }
|
||||
// notarizedPut(testSinglePutInfo) {
|
||||
// call.respondText { "hey" }
|
||||
// }
|
||||
// notarizedDelete(testSingleDeleteInfo) {
|
||||
// call.respondText { "heya" }
|
||||
// }
|
||||
// }
|
||||
// authenticate("basic") {
|
||||
// route("/authenticated/single") {
|
||||
// notarizedGet(testAuthenticatedSingleGetInfo) {
|
||||
// call.respond(HttpStatusCode.OK)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
route("/single") {
|
||||
notarizedGet(testSingleGetInfo) {
|
||||
call.respondText("get single")
|
||||
}
|
||||
notarizedPost(testSinglePostInfo) {
|
||||
call.respondText("test post")
|
||||
}
|
||||
notarizedPut(testSinglePutInfo) {
|
||||
call.respondText { "hey" }
|
||||
}
|
||||
notarizedDelete(testSingleDeleteInfo) {
|
||||
call.respondText { "heya" }
|
||||
}
|
||||
}
|
||||
authenticate("basic") {
|
||||
route("/authenticated/single") {
|
||||
notarizedGet(testAuthenticatedSingleGetInfo) {
|
||||
call.respond(HttpStatusCode.OK)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
route("/error") {
|
||||
notarizedGet(testSingleGetInfoWithThrowable) {
|
||||
error("bad things just happened")
|
||||
}
|
||||
}
|
||||
// route("/error") {
|
||||
// notarizedGet(testSingleGetInfoWithThrowable) {
|
||||
// error("bad things just happened")
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user