Is it possible to create 'helper functions' to ins...
# getting-started
r
Is it possible to create 'helper functions' to instantiate annotations from 3rd-party libraries? I'm using SpringDoc to define OpenAPI metadata, and would like to remove visual clutter. e.g., something like this; this doesn't work because `Annotation class cannot be instantiated`:
Copy code
fun apiResponseOf(code: Int, kclass: KClass<*>) = ApiResponse(responseCode = code.toString(), content = arrayOf(Content(schema = Schema(kclass))))

@Operation(summary = "List all Foos")
@ApiResponses(
    apiResponseOf(200, FooResponse::class)
)
Instead of:
Copy code
@Operation(summary = "List all Foos")
@ApiResponses(
    ApiResponse(responseCode = "200", content = [Content(schema = Schema(implementation = FooResponse::class))])
)
y
r
Neat, thanks.