Ryunos
08/22/2023, 2:14 PMinternal fun Route.projectV1Routes(projectService: ProjectService) {
get("/projects/hierarchies") {
call.respondNullable(projectService.findProjectHierarchies().map { it.toHierarchyDtoV1() })
}
}
projectService.findProjectHierarchies()
returns an object with the type List<ProjectHierarchy>
When I try to call that endpoint, I get an error like this one:
2023-08-22 16:10:26.599 [eventLoopGroupProxy-6-1] ERROR Application - Unhandled: GET - /api/v1/projects/hierarchies
kotlinx.serialization.SerializationException: Class 'ArrayList' is not registered for polymorphic serialization in the scope of 'List'.
Mark the base class as 'sealed' or register the serializer explicitly.
It seems weird to me that this is not natively implemented because it seems very basic. I may have missed one import but I can’t figure out how to fix this error.
my build.gradle.kts:
dependencies {
implementation(project(":modules:app-server:domain" ))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
implementation("io.ktor:ktor-server-core:2.2.4")
implementation("io.ktor:ktor-server-netty:2.2.4")
implementation("io.ktor:ktor-server-content-negotiation:2.2.4")
implementation("io.ktor:ktor-serialization-kotlinx-json:2.2.4")
implementation("ch.qos.logback:logback-classic:1.4.7")
testImplementation("io.ktor:ktor-server-test-host:2.2.4")
}
Thank you for your helpRyunos
08/22/2023, 2:33 PM