Javalin: exposing swagger-ui webjar for use with SwaggerRenderer

Created on 5 Sep 2018  路  2Comments  路  Source: tipsy/javalin

Describe your question

First, a bit of context: on #254, one of the comments by @tipsy suggests using a simple

get("/my-docs", SwaggerRenderer("exampleApiSpec.yaml"))

To expose Swagger documentation from a yaml file - which I will generate manually at this time.

This, initially, outputs a page on my-docs telling me to add a dependency on swagger-ui's webjar (that is, compile 'org.webjars:swagger-ui:3.17.6'). After doing this, accessing /my-docs on a browser shows me a blank web page. Its source is there, it's a short-ish html that is in SwaggerRenderer.kt, but it seems like it cannot find the resources from the Webjar on the server.

So, at this point, I'm stumped. According to #309, Webjars should be enabled automatically, but I'm missing something.

How do I expose swagger-ui's Webjar?

QUESTION

All 2 comments

Hi @fmobus, I reverted #309 in 061e641b23272dab0a857ebadccb6ddb2fd27e9a, it was one of the last changes before releasing 2.0.0. I've updated the issues you linked to in order to reflect this. To enable swagger you'll have to do:

val app = Javalin.create().apply {
    enableWebJars()
    get("/my-docs", SwaggerRenderer("exampleApiSpec.yaml"))
}.start(0)

That worked! Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davioooh picture davioooh  路  3Comments

wellingtoncosta picture wellingtoncosta  路  5Comments

MFernstrom picture MFernstrom  路  3Comments

JosefEvAlloc picture JosefEvAlloc  路  5Comments

mikexliu picture mikexliu  路  3Comments