From a9088f14ce571ded73ab5cd02738f2b196a02dd0 Mon Sep 17 00:00:00 2001 From: Nicklas Ansman Giertz Date: Sat, 19 Feb 2022 10:48:36 -0500 Subject: [PATCH] Add an extension for accessing the application in a route --- .../kotlin/com/papsign/ktor/openapigen/route/OpenAPIRoute.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/papsign/ktor/openapigen/route/OpenAPIRoute.kt b/src/main/kotlin/com/papsign/ktor/openapigen/route/OpenAPIRoute.kt index 7dbe3502a..21d916351 100644 --- a/src/main/kotlin/com/papsign/ktor/openapigen/route/OpenAPIRoute.kt +++ b/src/main/kotlin/com/papsign/ktor/openapigen/route/OpenAPIRoute.kt @@ -9,7 +9,6 @@ import com.papsign.ktor.openapigen.modules.CachingModuleProvider import com.papsign.ktor.openapigen.modules.OpenAPIModule import com.papsign.ktor.openapigen.modules.ofType import com.papsign.ktor.openapigen.modules.openapi.HandlerModule -import com.papsign.ktor.openapigen.modules.registerModule import com.papsign.ktor.openapigen.openAPIGen import com.papsign.ktor.openapigen.parameters.handlers.ParameterHandler import com.papsign.ktor.openapigen.parameters.util.buildParameterHandler @@ -43,7 +42,7 @@ abstract class OpenAPIRoute>(val ktorRoute: Route, val provi val parameterHandler = buildParameterHandler

(paramsType) provider.registerModule(parameterHandler, ParameterHandler::class.createType(listOf(KTypeProjection(KVariance.INVARIANT, paramsType)))) - val apiGen = ktorRoute.application.openAPIGen + val apiGen = application.openAPIGen provider.ofType().forEach { it.configure(apiGen, provider) } @@ -108,3 +107,5 @@ abstract class OpenAPIRoute>(val ktorRoute: Route, val provi } } } + +val OpenAPIRoute<*>.application get() = ktorRoute.application \ No newline at end of file