Trying to do the swagger OAuth configuration in the latest version of Micronaut, as per the micronuat documentation https://micronaut-projects.github.io/micronaut-openapi/latest/guide/index.html#enableendpoints
swagger-ui.oauth2RedirectUrl
swagger-ui.oauth2.clientId
swagger-ui.oauth2.clientSecret
swagger-ui.oauth2.realm
swagger-ui.oauth2.appName
swagger-ui.oauth2.scopeSeparator
swagger-ui.oauth2.scopes
swagger-ui.oauth2.additionalQueryStringParams
swagger-ui.oauth2.useBasicAuthenticationWithAccessCodeGrant
swagger-ui.oauth2.usePkceWithAuthorizationCodeGrant
When setting any of those properties, Micronaut will generate not only a swagger-ui/index.html file, but also a swagger-ui/oauth2-redirect.html one
I can see it has created the file oauth2-redirect.html with below code
tasks.withType(JavaCompile).all {
options.forkOptions.jvmArgs << '-Dmicronaut.openapi.views.spec=swagger-ui.enabled=true,swagger-ui.theme=flattop,swagger-ui.oauth2RedirectUrl=http://localhost:8080/swagger-ui/oauth2-redirect.html,swagger-ui.oauth2.clientId=myClientId,swagger-ui.oauth2.scopes=openid,swagger-ui.oauth2.usePkceWithAuthorizationCodeGrant=true'
}
For the oauth2.clientId, oauth2RedirectUrl and oauth2.clientSecret these values differs for each environment PROD, TEST, DEV, UAT. By setting the value like above code it is hard to configure for each enviroment. Is there any better way to do this?
In my project it was solved by creating different property files for each env and steering the compilation with parameters
and then you build it like this
Although I'd like to know how to do this post compilation because in my case it forces creation of separate docker images where I'd like to have one and mount those properties afterwards.