From 7adf1167217e25932dbaf324673801a21c83fbfe Mon Sep 17 00:00:00 2001 From: kashiuno Date: Thu, 2 Jan 2025 14:29:38 +0300 Subject: [PATCH] Add openapi kotlin generator to project --- build.gradle.kts | 27 ++++++++++++++++++- .../openapi-contract.yaml | 0 2 files changed, 26 insertions(+), 1 deletion(-) rename src/main/{kotlin/com/kashiuno => resources}/openapi-contract.yaml (100%) diff --git a/build.gradle.kts b/build.gradle.kts index 19a8205..b16e297 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,21 +1,46 @@ plugins { kotlin("jvm") version "2.0.21" + id("org.openapi.generator") version "7.10.0" } group = "com.kashiuno" -version = "1.0-SNAPSHOT" +version = "1.0.0" + +val generatedSourcesDir = "$buildDir/generated/openapi" repositories { mavenCentral() } dependencies { + compileOnly("com.squareup.okhttp3:okhttp:4.12.0") + compileOnly("com.squareup.moshi:moshi-kotlin:1.15.2") testImplementation(kotlin("test")) } tasks.test { useJUnitPlatform() } + kotlin { jvmToolchain(17) +} + +tasks.openApiGenerate { + generatorName.set("kotlin") + inputSpec.set("$rootDir/src/main/resources/openapi-contract.yaml") + outputDir.set(generatedSourcesDir) + packageName.set("com.kashiuno") +} + +sourceSets { + getByName("main") { + kotlin { + srcDir("$generatedSourcesDir/src/main/kotlin") + } + } +} + +tasks.compileKotlin { + dependsOn(tasks.openApiGenerate) } \ No newline at end of file diff --git a/src/main/kotlin/com/kashiuno/openapi-contract.yaml b/src/main/resources/openapi-contract.yaml similarity index 100% rename from src/main/kotlin/com/kashiuno/openapi-contract.yaml rename to src/main/resources/openapi-contract.yaml