How to use @Resource instead of @Location for ktor routing

I am trying to migrate some code which uses the @Location annotation from the Locations plugin (a deprecated plugin in ktor since release 1.6) to @Resource from the Resources plugin.

The setup as described here works, but I am running into trouble when I try to refactor some code that uses route.location(someRandomLocation) { }, where someRandomLocation represented a resource (possibly nested in a class hierarchy), so for example something like this:

@Location(path:"/index")
class A {
    
   @Location(path: "/files") 
           class B(val file : File) {
               

So in this case someRandomLocation would be a KClass<A.B> but it could also only go up to /index.
Firstly, I replaced @Location with @Resource. However when I try to replace a code snippet like

resource.location(location) {
      method(Get) {
            handle(location) { location ->
                    ...
            }
      }
}

with

resource.resource(serializer = ?) {
      method(HttpMethod.Get) {
            handle(location) { location ->
                    ...
            }
      }
}

I need to define a serializer for that location first. I am not sure of how to define this serializer. Furthermore, I need to define a serializer that works for class hierarchies like A.B but also other more nested classes (also in other files etc which is why I used the generic location in the first place). Is there a way to do this in a way with minimal rewriting or do I need to annotate all my classes with @Serializable for example? Could someone who has experience with changing from Locations to Resources offer some insight please.