question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tipsycommented, Sep 1, 2019

@TobiasWalle I will try to have a look at this one myself 😃

0reactions
tipsycommented, Sep 5, 2019

You’re very welcome. I’ll ping this thread when the new version is out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Authentication - Swagger
OpenAPI uses the term security scheme for authentication and authorization schemes. OpenAPI 3.0 lets you describe APIs protected using the following ...
Read more >
OpenAPI Specification — Swagger Authentication - Medium
The OpenAPI Specification (OAS) defines a standard, language-agnostic interface to RESTful APIs which allows both humans and computers to ...
Read more >
7 Adding Authentication and Authorization - Designing APIs ...
Authentication is about proving you are, who you say, you are — which could be through a username and password. While authorization is...
Read more >
Configure JWT Authentication for OpenAPI - Baeldung
In this tutorial, we learned how to configure JWT authentication to our OpenAPIs. Swagger-UI provides a tool to document and test the REST...
Read more >
Security with OpenAPI - Cloud-Native AppDev
Authentication that uses a token generated from logging into another server · Format: Authorization: Bearer <TOKEN> · Can be part of an oAuth...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found