Skip to content

Commit

Permalink
Add an extension for accessing the application in a route
Browse files Browse the repository at this point in the history
  • Loading branch information
ansman committed Feb 19, 2022
1 parent 4b8dd27 commit a9088f1
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -43,7 +42,7 @@ abstract class OpenAPIRoute<T : OpenAPIRoute<T>>(val ktorRoute: Route, val provi
val parameterHandler = buildParameterHandler<P>(paramsType)
provider.registerModule(parameterHandler, ParameterHandler::class.createType(listOf(KTypeProjection(KVariance.INVARIANT, paramsType))))

val apiGen = ktorRoute.application.openAPIGen
val apiGen = application.openAPIGen
provider.ofType<HandlerModule>().forEach {
it.configure(apiGen, provider)
}
Expand Down Expand Up @@ -108,3 +107,5 @@ abstract class OpenAPIRoute<T : OpenAPIRoute<T>>(val ktorRoute: Route, val provi
}
}
}

val OpenAPIRoute<*>.application get() = ktorRoute.application

0 comments on commit a9088f1

Please sign in to comment.