-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
59 lines (53 loc) · 1.73 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
plugins {
kotlin("jvm")
id("org.openapi.generator")
}
dependencies {
val jacksonVersion: String by project
implementation(kotlin("stdlib"))
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion")
testImplementation(kotlin("test-junit"))
}
sourceSets {
main {
java.srcDir("$buildDir/generate-resources/main/src/main/kotlin")
}
}
/**
* Настраиваем генерацию здесь
*/
openApiGenerate {
val openapiGroup = "$group.api.v1"
generatorName.set("kotlin") // Это и есть активный генератор
packageName.set(openapiGroup)
apiPackage.set("$openapiGroup.api")
modelPackage.set("$openapiGroup.models")
invokerPackage.set("$openapiGroup.invoker")
inputSpec.set("$rootDir/specs/specs-ad-v1.yaml")
/**
* Здесь указываем, что нам нужны только модели, все остальное не нужно
* https://openapi-generator.tech/docs/globals
*/
globalProperties.apply {
put("models", "")
put("modelDocs", "false")
}
/**
* Настройка дополнительных параметров из документации по генератору
* https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/kotlin.md
*/
configOptions.set(
mapOf(
"dateLibrary" to "string",
"enumPropertyNaming" to "UPPERCASE",
"serializationLibrary" to "jackson",
"collectionType" to "list"
)
)
}
tasks {
compileKotlin {
dependsOn(openApiGenerate)
}
}