У меня есть чванство и следующий файл build.gradle
buildscript {
ext {
springBootVersion = '2.1.8.RELEASE'
}
repositories {
maven {
url "https://mavenrepo.schwab.com/nexus/content/groups/public"
}
maven {
url "https://mavenrepo.schwab.com/nexus/content/repositories/releases/"
}
}
dependencies {
classpath("io.swagger:swagger-codegen:2.4.7")
classpath "io.spring.gradle:dependency-management-plugin:1.0.8.RELEASE"
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7"
}
}
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
repositories {
maven {
url "https://mavenrepo.schwab.com/nexus/content/groups/public"
}
}
import io.swagger.codegen.DefaultGenerator
import io.swagger.codegen.config.CodegenConfigurator
def swaggerInput = "${rootDir}/api/POMOrchestrator.v1.json"
def swaggerOutputDir = file('application/')
task generateApi {
inputs.file(swaggerInput)
outputs.dir(swaggerOutputDir)
doLast {
def config = new CodegenConfigurator()
config.setInputSpec(swaggerInput)
config.setOutputDir(swaggerOutputDir.path)
config.setIgnoreFileOverride(swaggerOutputDir.path)
config.setLang('spring')
config.setAdditionalProperties([
'invokerPackage': 'com.schwab.brokerage.party.onborading',
'modelPackage' : 'com.schwab.brokerage.party.onborading.models.swagger',
'apiPackage' : 'com.schwab.brokerage.party.onborading.api.inbound.rest.controller',
'dateLibrary' : 'java8',
'useTags' : 'true', // Use tags for the naming
'interfaceOnly' : 'true' // Generating the Controller API interface and the models only
])
config.setImportMappings([
'hello': 'com.schwab.cat.onbording.model.Hello'
])
new DefaultGenerator().opts(config.toClientOptInput()).generate()
}
}
clean.doFirst {
delete(swaggerOutputDir)
}
configurations {
swagger
}
sourceSets {
swagger {
compileClasspath = configurations.swaggerCompile
java {
srcDir file("${project.buildDir.path}/swagger/src/main/java")
}
}
main {
compileClasspath += swagger.output
runtimeClasspath += swagger.output
}
test {
compileClasspath += swagger.output
runtimeClasspath += swagger.output
}
}
compileSwaggerJava.dependsOn generateApi
classes.dependsOn swaggerClasses
compileJava.dependsOn compileSwaggerJava
ext {
springBootVersion = '2.1.8.RELEASE'
swaggerVersion = '2.7.0'
springCloudServicesVersion = '2.1.2.RELEASE'
springCloudVersion = 'Greenwich.RC1'
cucumberVersion = '2.3.1'
jackson_version = '2.4.2'
jersey_version = '1.18'
jodatime_version = '2.3'
junit_version = '4.8.1'
}
dependencies {
swaggerCompile "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
swaggerCompile 'io.swagger:swagger-annotations:1.5.16'
swaggerCompile 'com.squareup.okhttp:okhttp:2.7.5'
swaggerCompile 'com.squareup.okhttp:logging-interceptor:2.7.5'
swaggerCompile 'com.google.code.gson:gson:2.8.1'
compile sourceSets.swagger.output
compile "com.sun.jersey:jersey-client:$jersey_version"
compile "com.sun.jersey.contribs:jersey-multipart:$jersey_version"
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5"
compile "joda-time:joda-time:$jodatime_version"
compile 'io.swagger:swagger-codegen:2.2.3'
testCompile "junit:junit:$junit_version"
runtime 'com.squareup.okhttp:okhttp:2.7.5'
runtime 'com.squareup.okhttp:logging-interceptor:2.7.5'
runtime 'com.google.code.gson:gson:2.8.1'
}
Он отлично справляется с созданием моделей, только у них нет аннотаций ломбока, и для моих целей было бы действительно полезно быть возможность добавить @Data и @Builder вверху. Есть ли способ указать генератору кода добавить их (возможно, параметр)?