Spring Boot 3 MVC Kotlin Sample
This is a very simple Spring Boot 3 (gradle) project in kotlin that is using
-
openapi-processor-spring to generate java interfaces for the api defined in an openapi.yaml file
-
openapi-processor-gradle plugin to run the spring processor
The purpose of the sample is to show the setup of the gradle plugin and the processors and how easy it is to use it in a kotlin project.
The sample contains a build.gradle.kts
build file.
OpenAPI & processor configuration
the src/api
folder contains an OpenAPI description and the processor configuration file mapping.yaml
.
The mapping.yaml
includes a couple of type & annotation mappings which modify the generated code.
other source files
src/main
contains the spring boot application class and other classes that are used in the mapping.yaml
type & annotation mappings.
kotlin & generated files
Interesting here is that the mapping.yaml
uses type mappings with kotlin classes.
After generating the interface/model class from the OpenAPI by running the processor there are generated java files that reference the kotlin classes.
A kotlin controller implementation then implements the generated java interface.
And it just works, there is no compilation order problem… :-)