Openapi-generator with Lombok
Directory structure
- templates
- JavaSpring
- beanValidation.mustache
- model.mustache
- pojo.mustache
- JavaSpring
Gradle configuration: build.gradle
plugins {
// Openapi generator
id 'org.openapi.generator' version '6.0.0'
// Spotless for formatting
id "com.diffplug.spotless" version "6.10.0"
}
openApiGenerate {
generatorName = "spring"
//https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/spring.md
configOptions = [
interfaceOnly : "true",
skipDefaultInterface: "true",
delegatePattern : "true",
openApiNullable : "false",
jackson : "false"
]
typeMappings = [
// We want to use Instant
OffsetDateTime: "Instant"
]
importMappings = [
"java.time.OffsetDateTime": "java.time.Instant",
]
apiPackage = "my.domain.api"
modelPackage = "my.domain.dto"
templateDir = "$rootDir/templates/JavaSpring"
library = "spring-cloud"
inputSpec = "$rootDir/api/openapi.json".toString()
outputDir = "$buildDir/generated-source".toString()
}
task generate(type: GradleBuild) {
tasks = [
'openApiGenerate',
'spotlessApply'
]
}