I have a below project structure
Project product and API gateway share the common project as common. Since in the parent project settings.Gradle I have included the project as below
rootProject.name = 'src'
include 'common', 'fetebird-apigateway', 'fete-bird-product'
In the API gateway build.gradle I have included the below dependency
dependencies {
annotationProcessor("io.micronaut.openapi:micronaut-openapi:2.1.1")
implementation("io.swagger.core.v3:swagger-annotations")
implementation project(':common')
}
In the product build.gradle I have include the below dependency
dependencies {
annotationProcessor("io.micronaut.openapi:micronaut-openapi:2.1.1")
implementation("io.swagger.core.v3:swagger-annotations")
implementation project(':common')
}
When I run the command $ gradle build
I can see the view is generated
Swagger expose end point
micronaut:
application:
name: feteBirdProduct
server:
port: 8083
router:
versioning:
enabled: true
static-resources:
swagger:
paths: classpath:META-INF/swagger
mapping: /swagger/**
swagger-ui:
paths: classpath:META-INF/swagger/views/swagger-ui
mapping: /swagger-ui/**
But when I access the URL
http://localhost:8084/swagger-ui/index.html
I can see the below message and I don't have any security enable
{"message":"Page Not Found","_links":{"self":{"href":"/swagger-ui/index.html","templated":false}}}
While debugging io.micronaut.web.router.resource.StaticResourceResolver
. The public URL findResource(String name)
return null in the BuiltinClassLoader.java
Not sure if you did, but you might need to expose the generated API docs as static resources with a YML config such as the following stated in the Micronaut OpenAPI docs):
Then you should be able to access them using a route such as:
http://localhost:8080/swagger/views/swagger-ui/index.html
.In case you enable the security module, you might need to specify security rules for that URL using "intercept URL map", otherwise you might not be able to reach it: