OpenApi and Auth
See original GitHub issueHi
I have tried the new OpenApi plugin. And Without security enabled it works wonderful
But when I turn on security and add .roles(setOf(ApiRole.MYMASTER))
It only works for the path for json ("/swagger-docs"
in the examples)
both swagger and redoc gets unautorized as an answer.
Am i missing somethin or is it a bug ? I am using Kotlin if that makes any difference.
I also have another question If I use
val javalin = Javalin.create{
val openApiOptions = OpenApiOptions(Info().version("1.0").description("My Application"))
.path("/swagger-docs")
.swagger(SwaggerOptions("/swagger").title("My Swagger Documentation"))
.reDoc(ReDocOptions("/redoc").title("My ReDoc Documentation"))
.roles(setOf(ApiRole.MYMASTER))
.defaultDocumentation { documentation -> documentation.json<InternalServerErrorResponse>("500") }
val plugin = OpenApiPlugin(openApiOptions)
it.registerPlugin(plugin)
}
it works But if I do
val javalin = Javalin.create()
val openApiOptions = OpenApiOptions(Info().version("1.0").description("My Application"))
.path("/swagger-docs")
.swagger(SwaggerOptions("/swagger").title("My Swagger Documentation"))
.reDoc(ReDocOptions("/redoc").title("My ReDoc Documentation"))
.defaultDocumentation { documentation -> documentation.json<InternalServerErrorResponse>("500") }
javalin.apply {
config.accessManager(Auth::accessManager)
config.registerPlugin(OpenApiPlugin(openApiOptions))
}
It compiles but none of the openapi paths gives anything but not found. Is there anything obvious that I am missing ? I now have all my config except the plugin in the apply section. Since I have the need to reconfigure on the fly. I would prefer to have the plugin there as well to keep it in one place.
The problem when auth is enabled is my biggest hurdle the other i can live with.
Thanks in advance for any hints. And a big thank you for Javalin and for this wonderful addon for swagger/redoc.
Edit: Formatting added by @tipsy
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (6 by maintainers)
Top GitHub Comments
@TobiasWalle I will try to have a look at this one myself 😃
You’re very welcome. I’ll ping this thread when the new version is out.