explicit decoupled serialization (#65)
This commit is contained in:
@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [1.2.3] - June 3rd, 2021
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Updates showing/explaining serializer agnostic approach
|
||||||
|
|
||||||
## [1.2.2] - May 23rd, 2021
|
## [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
|
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
|
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 🤠
|
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
|
## Examples
|
||||||
|
|
||||||
The full source code can be found in the `kompendium-playground` module. Here is a simple get endpoint example
|
The full source code can be found in the `kompendium-playground` module. Here is a simple get endpoint example
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Kompendium
|
# Kompendium
|
||||||
project.version=1.2.2
|
project.version=1.2.3
|
||||||
# Kotlin
|
# Kotlin
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
# Gradle
|
# 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" }
|
webjars-swagger-ui = { group = "org.webjars", name = "swagger-ui", version.ref = "swagger-ui" }
|
||||||
|
|
||||||
[bundles]
|
[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" ]
|
ktorAuth = [ "ktor-auth-lib", "ktor-auth-jwt" ]
|
||||||
logging = [ "slf4j", "logback-classic", "logback-core" ]
|
logging = [ "slf4j", "logback-classic", "logback-core" ]
|
||||||
|
@ -11,6 +11,7 @@ dependencies {
|
|||||||
implementation(libs.bundles.ktorAuth)
|
implementation(libs.bundles.ktorAuth)
|
||||||
implementation(projects.kompendiumCore)
|
implementation(projects.kompendiumCore)
|
||||||
|
|
||||||
|
testImplementation(libs.ktor.jackson)
|
||||||
testImplementation("org.jetbrains.kotlin:kotlin-test")
|
testImplementation("org.jetbrains.kotlin:kotlin-test")
|
||||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
|
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
|
||||||
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.0")
|
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.0")
|
||||||
|
@ -10,6 +10,7 @@ dependencies {
|
|||||||
implementation(libs.bundles.ktor)
|
implementation(libs.bundles.ktor)
|
||||||
testImplementation("org.jetbrains.kotlin:kotlin-test")
|
testImplementation("org.jetbrains.kotlin:kotlin-test")
|
||||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
|
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
|
||||||
|
testImplementation(libs.ktor.jackson)
|
||||||
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.0")
|
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.0")
|
||||||
testImplementation("io.ktor:ktor-server-test-host:1.5.3")
|
testImplementation("io.ktor:ktor-server-test-host:1.5.3")
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
|
kotlin("plugin.serialization") version "1.5.0"
|
||||||
application
|
application
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11,6 +12,7 @@ dependencies {
|
|||||||
implementation(projects.kompendiumSwaggerUi)
|
implementation(projects.kompendiumSwaggerUi)
|
||||||
|
|
||||||
implementation(libs.bundles.ktor)
|
implementation(libs.bundles.ktor)
|
||||||
|
implementation(libs.ktor.jackson)
|
||||||
implementation(libs.bundles.ktorAuth)
|
implementation(libs.bundles.ktorAuth)
|
||||||
implementation(libs.bundles.logging)
|
implementation(libs.bundles.logging)
|
||||||
|
|
||||||
|
@ -91,46 +91,46 @@ fun Application.mainModule() {
|
|||||||
openApi(oas)
|
openApi(oas)
|
||||||
redoc(oas)
|
redoc(oas)
|
||||||
swaggerUI()
|
swaggerUI()
|
||||||
// route("/potato/spud") {
|
route("/potato/spud") {
|
||||||
// notarizedGet(testGetWithExamples) {
|
notarizedGet(testGetWithExamples) {
|
||||||
// call.respond(HttpStatusCode.OK)
|
call.respond(HttpStatusCode.OK)
|
||||||
// }
|
}
|
||||||
// notarizedPost(testPostWithExamples) {
|
notarizedPost(testPostWithExamples) {
|
||||||
// call.respond(HttpStatusCode.Created, ExampleResponse("hey"))
|
call.respond(HttpStatusCode.Created, ExampleResponse("hey"))
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
route("/test") {
|
route("/test") {
|
||||||
route("/{id}") {
|
route("/{id}") {
|
||||||
notarizedGet(testIdGetInfo) {
|
notarizedGet(testIdGetInfo) {
|
||||||
call.respondText("get by id")
|
call.respondText("get by id")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// route("/single") {
|
route("/single") {
|
||||||
// notarizedGet(testSingleGetInfo) {
|
notarizedGet(testSingleGetInfo) {
|
||||||
// call.respondText("get single")
|
call.respondText("get single")
|
||||||
// }
|
}
|
||||||
// notarizedPost(testSinglePostInfo) {
|
notarizedPost(testSinglePostInfo) {
|
||||||
// call.respondText("test post")
|
call.respondText("test post")
|
||||||
// }
|
}
|
||||||
// notarizedPut(testSinglePutInfo) {
|
notarizedPut(testSinglePutInfo) {
|
||||||
// call.respondText { "hey" }
|
call.respondText { "hey" }
|
||||||
// }
|
}
|
||||||
// notarizedDelete(testSingleDeleteInfo) {
|
notarizedDelete(testSingleDeleteInfo) {
|
||||||
// call.respondText { "heya" }
|
call.respondText { "heya" }
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// authenticate("basic") {
|
authenticate("basic") {
|
||||||
// route("/authenticated/single") {
|
route("/authenticated/single") {
|
||||||
// notarizedGet(testAuthenticatedSingleGetInfo) {
|
notarizedGet(testAuthenticatedSingleGetInfo) {
|
||||||
// call.respond(HttpStatusCode.OK)
|
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