Hi, I’ve a question regarding `swagger-ui` and `ro...
# http4k
d
Hi, I’ve a question regarding
swagger-ui
and
routes
. I’ve a code similar to following:
Copy code
routes(
            "/swagger-ui" bind swaggerUiWebJar {
                url = "spec"
                pageTitle = "Cat Shelter"
                displayOperationId = true
                requestSnippetsEnabled = true
            }
        )
when I call my service in a browser with
<http://localhost:8000/swagger-ui>
I end up in an empty page. I can see swagger-ui by adding a trailing
/
. How can I easily change this behaviour back, so that I can call it again without trailing slash?
a
On a nested path, the blank page is a known issue; it has to do with relative assets being loaded. I'm working on a solution. In the meantime, there are some workarounds: 1. Use
swaggerUiLite
2. Bind the UI to the root path
d
Exactly, it's a blank page. The more I think about it, the more I like your suggestion about mapping it to the root path. We have this "swagger-ui" only for being similar to the spring applications. Thanks for triggering to question this approach 😊
a
Binding to the root path makes the API so much more effortless to consume, so it has my strong recommendation. But as redoc support is being added soon, it will be impossible to have both UI's on the same root path, so I would ideally find a solution.
Following up. This issue will be fixed in the next release: tentatively v4.41.4.0
d
Nice, but anyways I changed all my services to use root path - which I like 🙂 Thanks for this idea