diff --git a/kotlin-asyncapi-ktor/src/main/kotlin/com/asyncapi/kotlinasyncapi/ktor/AsyncApiModule.kt b/kotlin-asyncapi-ktor/src/main/kotlin/com/asyncapi/kotlinasyncapi/ktor/AsyncApiModule.kt index 2ddd5e26..c6aed034 100644 --- a/kotlin-asyncapi-ktor/src/main/kotlin/com/asyncapi/kotlinasyncapi/ktor/AsyncApiModule.kt +++ b/kotlin-asyncapi-ktor/src/main/kotlin/com/asyncapi/kotlinasyncapi/ktor/AsyncApiModule.kt @@ -23,6 +23,7 @@ import com.asyncapi.kotlinasyncapi.context.service.AsyncApiSerializer import com.asyncapi.kotlinasyncapi.context.service.AsyncApiService import com.asyncapi.kotlinasyncapi.context.service.DefaultAsyncApiSerializer import com.asyncapi.kotlinasyncapi.context.service.DefaultAsyncApiService +import com.asyncapi.kotlinasyncapi.model.AsyncApi class AsyncApiModule( environment: ApplicationEnvironment, @@ -69,8 +70,19 @@ class AsyncApiModule( ) } - private val asyncApiAnnotationExtension = - annotationProvider.asyncApi?.let { AsyncApiExtension.from(order = -1, it) } + private val asyncApiAnnotationExtension: AsyncApiExtension = + object : AsyncApiExtension { + override val order: Int = -1 + private var delegate: AsyncApiExtension? = null + + override fun extend(asyncApi: AsyncApi): AsyncApi { + val annotated = annotationProvider.asyncApi ?: return asyncApi + val extension = delegate ?: AsyncApiExtension.from(order = order, resource = annotated).also { + delegate = it + } + return extension.extend(asyncApi) + } + } private val scriptResourceProvider = runCatching {