I am using openapi generator in my Spring Boot java application. I am also using gradle as a build tool. It is generating the interfaces and the models. But, I am getting some errors in the generated models. Following are the error:
And also my enums are not mapping correctly from the openapi (yaml) file.
This is my current gradle settings for openapi generator:
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.1'
id 'io.spring.dependency-management' version '1.1.6'
id 'org.sonarqube' version '5.1.0.4882'
id 'jacoco'
id 'com.adarshr.test-logger' version '4.0.0'
id 'com.diffplug.spotless' version '7.0.0.BETA1'
id 'org.openapi.generator' version '7.7.0'
}
sourceSets {
main {
java {
srcDirs += 'build/generated/src/main/java'
}
}
}
openApiGenerate {
generatorName = 'spring'
inputSpec = file('src/main/resources/api-spec/api.yaml').absolutePath
outputDir = file('build/generated').absolutePath
apiPackage = 'com.volkswagen.multitenancy.api'
modelPackage = 'com.volkswagen.multitenancy.model'
invokerPackage = 'com.volkswagen.multitenancy.invoker'
// modelNameSuffix = 'Dto'
configOptions = [
interfaceOnly: 'true',
useOptional: 'false',
// dateLibrary: 'java8',
implementationPackage: '',
skipDefaultInterface: 'true',
useTags: 'true',
]
}
tasks.named('compileJava') {
dependsOn 'openApiGenerate'
}
I already spent a lot of time to fix. After downgrading openapi generator version to 6.5.0 the validation error was gone but the enum mapping problem still exists. Do you face anything similar? Any suggestions please.