'Mapped the Yaml configuration to Micronaut swagger open API security configuration

I have the below YAML configuration for OAuth

OAuth:
  authorizationUrl: https://localhost:5001/connect/authorize
  tokenUrl: https://localhost:5001/connect/token
  scopes:
    - name: openid
      description: open id scope
    - name: profile
      description: profile scope
    - email: profile
      description: profile scope

And a record class for mapping something like below

@ConfigurationProperties("OAuth")
public record OAuthConfiguration(
        String authorizationUrl,
        String tokenUrl,
        List<SelectOptionModel> scopes
) {}

Now in the main method of micronaiut application I need to mapped the record value, not sure how can I achieve this

@SecurityScheme(name = "openid",
        type = SecuritySchemeType.OAUTH2,
        scheme = "bearer",
        bearerFormat = "jwt",
        flows = @OAuthFlows(
                authorizationCode = @OAuthFlow(
                        authorizationUrl = "", // This should be replace from record property 
                        tokenUrl = "", // This should be replace from record property 
                        scopes = {@OAuthScope(name = "openid", description = "OpenID"), // This should be replace from record property 
                                @OAuthScope(name = "profile", description = "profile"), // This should be replace from record property 
                                @OAuthScope(name = "email", description = "email") // This should be replace from record property 
                        }
                )
        )
)
public class ApiGateway {

    public static void main(String[] args) {
        Micronaut.run(ApiGateway.class, args);
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source