Following the documentation over here - https://micronaut-projects.github.io/micronaut-openapi/1.3.4/guide/index.html
I configured my build.gradle
to include compile time tasks for swagger yaml generation as follows-
tasks.withType(JavaCompile){
options.encoding = "UTF-8"
options.compilerArgs.add('-parameters')
options.fork = true
options.forkOptions.jvmArgs << '-Dmicronaut.openapi.views.spec=rapidoc.enabled=true,swagger-ui.enabled=true,swagger-ui.theme=flattop'
}
This is how my application.yaml
looks like-
micronaut:
server:
port: 9090
cors:
enabled: true
router:
static-resources:
swagger:
paths: classpath:META-INF/swagger
mapping: /swagger/**
redoc:
paths: classpath:META-INF/swagger/views/redoc
mapping: /redoc/**
rapidoc:
paths: classpath:META-INF/swagger/views/rapidoc
mapping: /rapidoc/**
swagger-ui:
paths: classpath:META-INF/swagger/views/swagger-ui
mapping: /swagger-ui/**
Like the doc said, I also annotated by Application.java
as shown below-
package com.api.backend;
import io.micronaut.runtime.Micronaut;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
@OpenAPIDefinition(
info = @Info(
title = "API Backend",
version = "0.0",
description = "API backend"
)
)
public class Application {
public static void main(String[] args) {
Micronaut.run(Application.class);
}
}
After doing all this, when I try to open http://localhost:9090/swagger/api-backend-0.0.yaml
it opens the generated open API spec yaml. However, if I try opening http://localhost:9090/swagger-ui/
, I get a 404
.
Can anyone help me figure out the problem or suggest an alternative?
The configs looks ok , swagger-ui should be available in browser at http://localhost:8080/swagger-ui