2

Micronaut is the parent application context of Grails 4. We are trying to use some Micronauts features on our Grails 4 application. In particular, we are trying to use Micronaut Swagger/OpenAPI documentation generator feature.

We included the following dependencies:

    annotationProcessor "io.micronaut.configuration:micronaut-openapi:1.4.0"
    compile "io.swagger.core.v3:swagger-annotations:2.1.1"
    compileOnly "io.micronaut.configuration:micronaut-openapi:1.4.0"

We included the following jvmArgs:

tasks.withType(GroovyCompile) {
    configure(groovyOptions) {
        forkOptions.jvmArgs = ['-Xmx1024m', '-Dmicronaut.openapi.views.spec=rapidoc.enabled=true,swagger-ui.enabled=true,swagger-ui.theme=flattop']
    }
}

And finally included an annotation at the Application:


@CompileStatic
@OpenAPIDefinition(
        info = @Info(
                title = "TODO",
                version = "1.0",
                description = "TODO",
                license = @License(name = "TODO", url = "TODO"),
                contact = @Contact(url = "TODO", name = "TODO", email = "TODO")
        )
)
class Application extends GrailsAutoConfiguration {
    static void main(String[] args) {
        GrailsApp.run(Application, args)
    }
}

Doing that, it successfully generates the OpenAPI YAML file at /build/classes/groovy/main/META-INF/swagger, and the Rapidoc and Swagger-UI views at /build/classes/groovy/main/META-INF/swagger/views.

Now we are trying to configure views to the generated files.

We tried to include at UrlMappings.groovy:

        "/swagger"(view:'META-INF/swagger/')
        "/swagger-ui"(view:'META-INF/swagger/views/swagger-ui/')
        "/rapidoc"(view:'META-INF/swagger/views/rapidoc/')

But it does not work. It throws the following exception:

javax.servlet.ServletException: Could not resolve view with name 'META-INF/swagger/views/swagger-ui/' in servlet with name 'grailsDispatcherServlet

Please advise! Tks!

Chocksmith
  • 1,188
  • 2
  • 12
  • 40

0 Answers0