Is there anything I am missing? Had the code that worked locally, when deployed I get
ReferenceError: SwaggerUIBundle is not defined
After I cleared my browsing data I get the same error locally as well. Below are the configurations:
build.gradle
implementation("io.swagger.core.v3:swagger-core:2.0.9")
implementation("org.webjars:swagger-ui:3.24.3")
implementation("io.github.classgraph:classgraph:4.8.34")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.10.1")
App.kt
fun main() {
val app = Javalin.create { config ->
config.enableCorsForAllOrigins()
config.showJavalinBanner = false
config.enableWebjars()
config.registerPlugin(getConfiguredOpenApiPlugin())
}
configureApp(app, Config)
app.start(7000)
}
fun getConfiguredOpenApiPlugin() = OpenApiPlugin(
OpenApiOptions(
Info().apply {
version("1.0")
description("Polaris API")
}
).apply {
activateAnnotationScanningFor("search")
path("/swagger-docs")
swagger(SwaggerOptions("/swagger").title("Polaris Swagger Documentation"))
}
)
Endpoint.kt annotations
@OpenApi(
description = "Description",
path = "/get/something",
method = HttpMethod.GET
)
override fun handleEndpoint(ctx: Context) {
// Code here
}
For reference, Javalin documentation: https://javalin.io/plugins/openapi
Also, I'll attach all errors from the browser console. It's looking for 3.22.2
files when I set the 3.24.3
swagger-ui version in the build.gradle.
The script from “http://localhost:7000/webjars/swagger-ui/3.22.2/swagger-ui-bundle.js” was loaded even though its MIME type (“text/plain”) is not a valid JavaScript MIME type.
The script from “http://localhost:7000/webjars/swagger-ui/3.22.2/swagger-ui-standalone-preset.js” was loaded even though its MIME type (“text/plain”) is not a valid JavaScript MIME type.
Loading failed for the <script> with source “http://localhost:7000/webjars/swagger-ui/3.22.2/swagger-ui-bundle.js”.
The script from “http://localhost:7000/webjars/swagger-ui/3.22.2/swagger-ui-standalone-preset.js” was loaded even though its MIME type (“text/plain”) is not a valid JavaScript MIME type.
Loading failed for the <script> with source “http://localhost:7000/webjars/swagger-ui/3.22.2/swagger-ui-standalone-preset.js”.
ReferenceError: SwaggerUIBundle is not defined