Merging OpenAPI Schemas in Micronaut

Merging your own schemas into the generated OpenAPI specification is pretty straightforward. With OpenAPI integrated into your application, all you need to do is to add the system property micronaut.openapi.additional.files build.gradle tasks.withType(GroovyCompile) { ... groovyOptions.forkOptions.jvmArgs.add("-Dmicronaut.openapi.additional.files=${project.projectDir}/src/main/resources/swagger".toString()) ... } Specifying the location of the additional schema files. In this case I have it set to src/main/resources/swagger. It is worth noting what information is taken from additional files: Optional.ofNullable(from.getTags()).ifPresent(tags -> tags.forEach(to::addTagsItem)); Optional.ofNullable(from.getServers()).ifPresent(servers -> servers.

Micronaut application reloading

Since micronaut has a quick startup time the easiest way to reload an application after making changes is to have automatic restart setup. The first step in order to achieve this is to have this configuration in your application.yml micronaut: io: watch: paths: src/main restart: true On its own micronaut.io.watch.paths results in a FileChangedEvent being fired every time a file on the specified path(s) is changed. An event listener can be added if you want to do something on file changes.

Micronaut i18n using MessageSource

To implement i18n in micronaut you need to have a bean that is a subclass of ResourceBundleMessageSource. This can be done by using a factory to create the bean: @Factory class AppConfig { @Bean MessageSource messageSource() { new ResourceBundleMessageSource('com.example.Messages') } } Or just having a @Singleton annotated class @Singleton class AppBundle extends ResourceBundleMessageSource { AppBundle() { super('com.example.Messages') } } In both cases we pass the baseName of our bundle. After this you create your locale specific property files Messages.

Micronaut profile based configuration properties

Micronaut allows environment specific configuration in the same manner as Spring Boot. It searches for your application.yml, application.properties, application.json or application.groovy file. So for your production environment you could define application-prod.yml: micronaut: application: name: hello-service hello: message: This is prod The configuration properties can be accessed using the @Value annotation in controllers and services. @Value('${hello.message}') private String message When you run the jar you can specify the environment using the micronaut.

Micronaut OpenAPI integration

The Micronaut 1.2.10 documentation does an excellent job of explaining how to add OpenAPI integration to your app. However, I failed to generate the OpenAPI views when using swagger-groovy feature to generate my project: mn create-app micronaut-openapi-app --features swagger-groovy --lang=groovy After some digging around I found out you need to use a later version of the micronaut-openapi library to get things working. compileOnly "io.micronaut.configuration:micronaut-openapi:1.3.4" When using the swagger-groovy feature, the generated project ships with version 1.

Grails 3 datasource config with HibernateSpec

The default implementation of HibernateSpec in Grails 3.3.x overrides the datasource’s dbCreate value with create-drop. To get around this you simply override the getConfiguration method and set your preferred value for dbCreate. The properties in the map returned by this method take precedence to those in your application.yml Map getConfiguration() { Collections.singletonMap(Settings.SETTING\_DB\_CREATE, "create-drop") // change this } It is also worthwhile to note that your default datasource setup also take precedence over the test environment setup.