Skip to content

Commit

Permalink
Merge pull request #125 from ansman/feature/expose-application
Browse files Browse the repository at this point in the history
Add an extension for accessing the application in a route
  • Loading branch information
Wicpar authored Feb 27, 2022
2 parents 4b8dd27 + a9088f1 commit 8362daf
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 8362daf

Please sign in to comment.