-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
59 lines (53 loc) · 1.68 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 {
id("build-jvm")
alias(libs.plugins.openapi.generator)
}
sourceSets {
main {
java.srcDir(layout.buildDirectory.dir("generate-resources/main/src/main/kotlin"))
}
}
/**
* Настраиваем генерацию здесь
*/
openApiGenerate {
val openapiGroup = "${rootProject.group}.api.v1"
generatorName.set("kotlin") // Это и есть активный генератор
packageName.set(openapiGroup)
apiPackage.set("$openapiGroup.api")
modelPackage.set("$openapiGroup.models")
invokerPackage.set("$openapiGroup.invoker")
// inputSpec.set("$specDir/specs-ad-v1.yaml")
inputSpec.set(rootProject.ext["spec-v1"] as String)
/**
* Здесь указываем, что нам нужны только модели, все остальное не нужно
* 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"
)
)
}
dependencies {
implementation(kotlin("stdlib"))
implementation(libs.jackson.kotlin)
implementation(libs.jackson.datatype)
testImplementation(kotlin("test-junit"))
}
tasks {
compileKotlin {
dependsOn(openApiGenerate)
}
}