Skip to content

ReDocPlugin will display my local static openapi.yaml file but SwaggerPlugin will not (and it produces an error in the DevTools console) #254

@dstricks

Description

@dstricks

I'm using Kotlin 2.0.0, OpenJDK 17, and Javalin 6.7.0 on Ubuntu 22.04. I have a static openapi.yaml file which is being served up locally. I've successfully gotten the ReDocPlugin to render/display the spec properly, however the SwaggerPlugin does not.

Here is the relevant code snippet:

            config.staticFiles.add("/static")

            config.registerPlugin(SwaggerPlugin(Consumer<SwaggerConfiguration> { swaggerConfiguration: SwaggerConfiguration ->
                swaggerConfiguration.documentationPath = "/openapi.yaml"
            }))

            config.registerPlugin(ReDocPlugin(Consumer<ReDocConfiguration> { reDocConfiguration: ReDocConfiguration ->
                reDocConfiguration.documentationPath = "/openapi.yaml"
            }))

The Swagger page displays a "Could not render TopBar, see the console" title along with "No API definition provided." in the center of the screen. Look at the console output of Edge DevTools, I see the following:

TypeError: Cannot read properties of undefined (reading 'url')                                        swagger-ui-bundle.js:2  
    at TopBar.render (swagger-ui-standalone-preset.js:2:166191)
    at jj (swagger-ui-bundle.js:2:402213)
    at hj (swagger-ui-bundle.js:2:402012)
    at No (swagger-ui-bundle.js:2:445076)
    at Uk (swagger-ui-bundle.js:2:433307)
    at Tk (swagger-ui-bundle.js:2:433235)
    at Ik (swagger-ui-bundle.js:2:433098)
    at Nk (swagger-ui-bundle.js:2:429931)
    at Gk (swagger-ui-bundle.js:2:428484)
    at J (swagger-ui-bundle.js:2:510257)

TypeError: Cannot read properties of undefined (reading 'url')                            swagger-ui-standalone-preset.js:2  
    at TopBar.render (swagger-ui-standalone-preset.js:2:166191)
    at jj (swagger-ui-bundle.js:2:402213)
    at hj (swagger-ui-bundle.js:2:402012)
    at No (swagger-ui-bundle.js:2:445076)
    at Uk (swagger-ui-bundle.js:2:433307)
    at Tk (swagger-ui-bundle.js:2:433235)
    at Ik (swagger-ui-bundle.js:2:433098)
    at Nk (swagger-ui-bundle.js:2:429931)
    at Gk (swagger-ui-bundle.js:2:428484)
    at J (swagger-ui-bundle.js:2:510257) {componentStack: '\n    at TopBar (http://localhost:5005/webjars/swag…

I've tried lots of different ideas to get the Swagger to display—simplifying the openapi.yaml spec, trying to load the spec at the "default" location, reverting back to an earlier Javalin version, trying out different browsers, trying to figure out the actual JavaScript issue, etc.—but no luck resolving.

Any ideas or suggestions for how to proceed?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions