diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache index 29415aefe4f..2760de821a8 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache @@ -2,8 +2,8 @@ ## Requires -* Kotlin 1.1.2 -* Gradle 3.3 +* Kotlin 1.3.20 +* Gradle 4.9 ## Build diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache index 7d02942c6db..a60661d1f97 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache @@ -1,13 +1,13 @@ group '{{groupId}}' version '{{artifactVersion}}' -task wrapper(type: Wrapper) { - gradleVersion = '3.3' +wrapper { + gradleVersion = '4.9' distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" } buildscript { - ext.kotlin_version = '1.1.2' + ext.kotlin_version = '1.3.20' repositories { mavenCentral() @@ -23,11 +23,16 @@ repositories { mavenCentral() } +test { + useJUnitPlatform() +} + dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" + compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "com.squareup.moshi:moshi-kotlin:1.5.0" compile "com.squareup.moshi:moshi-adapters:1.5.0" compile "com.squareup.okhttp3:okhttp:3.8.0" compile "org.threeten:threetenbp:1.3.6" - testCompile "io.kotlintest:kotlintest:2.0.2" + testImplementation "io.kotlintest:kotlintest-runner-junit5:3.1.0" } diff --git a/samples/client/petstore/kotlin-string/README.md b/samples/client/petstore/kotlin-string/README.md index b9ab400b15e..811f25ab974 100644 --- a/samples/client/petstore/kotlin-string/README.md +++ b/samples/client/petstore/kotlin-string/README.md @@ -2,8 +2,8 @@ ## Requires -* Kotlin 1.1.2 -* Gradle 3.3 +* Kotlin 1.3.20 +* Gradle 4.9 ## Build diff --git a/samples/client/petstore/kotlin-string/build.gradle b/samples/client/petstore/kotlin-string/build.gradle index 8668dab3a7e..669d940ce32 100644 --- a/samples/client/petstore/kotlin-string/build.gradle +++ b/samples/client/petstore/kotlin-string/build.gradle @@ -1,13 +1,13 @@ group 'org.openapitools' version '1.0.0' -task wrapper(type: Wrapper) { - gradleVersion = '3.3' +wrapper { + gradleVersion = '4.9' distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" } buildscript { - ext.kotlin_version = '1.1.2' + ext.kotlin_version = '1.3.20' repositories { mavenCentral() @@ -23,11 +23,16 @@ repositories { mavenCentral() } +test { + useJUnitPlatform() +} + dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" + compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "com.squareup.moshi:moshi-kotlin:1.5.0" compile "com.squareup.moshi:moshi-adapters:1.5.0" compile "com.squareup.okhttp3:okhttp:3.8.0" compile "org.threeten:threetenbp:1.3.6" - testCompile "io.kotlintest:kotlintest:2.0.2" + testImplementation "io.kotlintest:kotlintest-runner-junit5:3.1.0" } diff --git a/samples/client/petstore/kotlin-string/src/test/kotlin/org/openapitools/client/PetApiTest.kt b/samples/client/petstore/kotlin-string/src/test/kotlin/org/openapitools/client/PetApiTest.kt new file mode 100644 index 00000000000..ad28e4cf8ea --- /dev/null +++ b/samples/client/petstore/kotlin-string/src/test/kotlin/org/openapitools/client/PetApiTest.kt @@ -0,0 +1,101 @@ +package org.openapitools.client + +import io.kotlintest.shouldBe +import io.kotlintest.matchers.numerics.shouldBeGreaterThan +import io.kotlintest.specs.ShouldSpec +import org.openapitools.client.apis.PetApi +import org.openapitools.client.models.Category +import org.openapitools.client.models.Pet +import org.openapitools.client.models.Tag + +class PetApiTest : ShouldSpec() { + init { + + should("add a pet") { + val petId:Long = 10006 + val pet = Pet( + id = petId, + name = "kotlin client test", + photoUrls = arrayOf("http://test_kotlin_unit_test.com"), + category = Category(petId, "test kotlin category"), + tags = arrayOf(Tag(petId, "test kotlin tag")) + ) + + val api = PetApi() + api.addPet(pet) + + } + + should("get pet by id") { + val petId: Long = 10006 + val api = PetApi() + val result = api.getPetById(petId) + + result.id shouldBe (petId) + result.name shouldBe ("kotlin client test") + result.photoUrls[0] shouldBe ("http://test_kotlin_unit_test.com") + result.category!!.id shouldBe (petId) + result.category!!.name shouldBe ("test kotlin category") + result.tags!![0].id shouldBe (petId) + result.tags!![0].name shouldBe ("test kotlin tag") + + } + + should("find pet by status") { + val api = PetApi() + val result = api.findPetsByStatus(arrayOf("available")) + + result.size.shouldBeGreaterThan(0) + + for(onePet in result) { + onePet.status.shouldBe(Pet.Status.available) + } + + val result2 = api.findPetsByStatus(arrayOf("unknown_and_incorrect_status")) + + result2.size.shouldBe(0) + + } + + should("update a pet") { + val petId:Long = 10007 + val pet = Pet( + id = petId, + name = "kotlin client updatePet", + status = Pet.Status.pending, + photoUrls = arrayOf("http://test_kotlin_unit_test.com") + ) + + val api = PetApi() + api.updatePet(pet) + + // verify updated Pet + val result = api.getPetById(petId) + result.id shouldBe (petId) + result.name shouldBe ("kotlin client updatePet") + result.status shouldBe (Pet.Status.pending) + + } + + //TODO the test fail cause client doesn't support other JSON contentType/Accept + /* + should("update a pet with form") { + val petId:Long = 10007 + val name = "kotlin client updatePet with Form" + val status = "pending" + + val api = PetApi() + api.updatePetWithForm(petId, name, status) + + // verify updated Pet + val result = api.getPetById(petId) + result.id shouldBe (petId) + result.name shouldBe ("kotlin client updatePet with Form") + result.status shouldBe (Pet.Status.pending) + + } + */ + + } + +} diff --git a/samples/client/petstore/kotlin-threetenbp/README.md b/samples/client/petstore/kotlin-threetenbp/README.md index b9ab400b15e..811f25ab974 100644 --- a/samples/client/petstore/kotlin-threetenbp/README.md +++ b/samples/client/petstore/kotlin-threetenbp/README.md @@ -2,8 +2,8 @@ ## Requires -* Kotlin 1.1.2 -* Gradle 3.3 +* Kotlin 1.3.20 +* Gradle 4.9 ## Build diff --git a/samples/client/petstore/kotlin-threetenbp/build.gradle b/samples/client/petstore/kotlin-threetenbp/build.gradle index 8668dab3a7e..669d940ce32 100644 --- a/samples/client/petstore/kotlin-threetenbp/build.gradle +++ b/samples/client/petstore/kotlin-threetenbp/build.gradle @@ -1,13 +1,13 @@ group 'org.openapitools' version '1.0.0' -task wrapper(type: Wrapper) { - gradleVersion = '3.3' +wrapper { + gradleVersion = '4.9' distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" } buildscript { - ext.kotlin_version = '1.1.2' + ext.kotlin_version = '1.3.20' repositories { mavenCentral() @@ -23,11 +23,16 @@ repositories { mavenCentral() } +test { + useJUnitPlatform() +} + dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" + compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "com.squareup.moshi:moshi-kotlin:1.5.0" compile "com.squareup.moshi:moshi-adapters:1.5.0" compile "com.squareup.okhttp3:okhttp:3.8.0" compile "org.threeten:threetenbp:1.3.6" - testCompile "io.kotlintest:kotlintest:2.0.2" + testImplementation "io.kotlintest:kotlintest-runner-junit5:3.1.0" } diff --git a/samples/client/petstore/kotlin-threetenbp/src/test/kotlin/org/openapitools/client/PetApiTest.kt b/samples/client/petstore/kotlin-threetenbp/src/test/kotlin/org/openapitools/client/PetApiTest.kt new file mode 100644 index 00000000000..ad28e4cf8ea --- /dev/null +++ b/samples/client/petstore/kotlin-threetenbp/src/test/kotlin/org/openapitools/client/PetApiTest.kt @@ -0,0 +1,101 @@ +package org.openapitools.client + +import io.kotlintest.shouldBe +import io.kotlintest.matchers.numerics.shouldBeGreaterThan +import io.kotlintest.specs.ShouldSpec +import org.openapitools.client.apis.PetApi +import org.openapitools.client.models.Category +import org.openapitools.client.models.Pet +import org.openapitools.client.models.Tag + +class PetApiTest : ShouldSpec() { + init { + + should("add a pet") { + val petId:Long = 10006 + val pet = Pet( + id = petId, + name = "kotlin client test", + photoUrls = arrayOf("http://test_kotlin_unit_test.com"), + category = Category(petId, "test kotlin category"), + tags = arrayOf(Tag(petId, "test kotlin tag")) + ) + + val api = PetApi() + api.addPet(pet) + + } + + should("get pet by id") { + val petId: Long = 10006 + val api = PetApi() + val result = api.getPetById(petId) + + result.id shouldBe (petId) + result.name shouldBe ("kotlin client test") + result.photoUrls[0] shouldBe ("http://test_kotlin_unit_test.com") + result.category!!.id shouldBe (petId) + result.category!!.name shouldBe ("test kotlin category") + result.tags!![0].id shouldBe (petId) + result.tags!![0].name shouldBe ("test kotlin tag") + + } + + should("find pet by status") { + val api = PetApi() + val result = api.findPetsByStatus(arrayOf("available")) + + result.size.shouldBeGreaterThan(0) + + for(onePet in result) { + onePet.status.shouldBe(Pet.Status.available) + } + + val result2 = api.findPetsByStatus(arrayOf("unknown_and_incorrect_status")) + + result2.size.shouldBe(0) + + } + + should("update a pet") { + val petId:Long = 10007 + val pet = Pet( + id = petId, + name = "kotlin client updatePet", + status = Pet.Status.pending, + photoUrls = arrayOf("http://test_kotlin_unit_test.com") + ) + + val api = PetApi() + api.updatePet(pet) + + // verify updated Pet + val result = api.getPetById(petId) + result.id shouldBe (petId) + result.name shouldBe ("kotlin client updatePet") + result.status shouldBe (Pet.Status.pending) + + } + + //TODO the test fail cause client doesn't support other JSON contentType/Accept + /* + should("update a pet with form") { + val petId:Long = 10007 + val name = "kotlin client updatePet with Form" + val status = "pending" + + val api = PetApi() + api.updatePetWithForm(petId, name, status) + + // verify updated Pet + val result = api.getPetById(petId) + result.id shouldBe (petId) + result.name shouldBe ("kotlin client updatePet with Form") + result.status shouldBe (Pet.Status.pending) + + } + */ + + } + +} diff --git a/samples/client/petstore/kotlin/README.md b/samples/client/petstore/kotlin/README.md index b9ab400b15e..811f25ab974 100644 --- a/samples/client/petstore/kotlin/README.md +++ b/samples/client/petstore/kotlin/README.md @@ -2,8 +2,8 @@ ## Requires -* Kotlin 1.1.2 -* Gradle 3.3 +* Kotlin 1.3.20 +* Gradle 4.9 ## Build diff --git a/samples/client/petstore/kotlin/build.gradle b/samples/client/petstore/kotlin/build.gradle index 8668dab3a7e..669d940ce32 100644 --- a/samples/client/petstore/kotlin/build.gradle +++ b/samples/client/petstore/kotlin/build.gradle @@ -1,13 +1,13 @@ group 'org.openapitools' version '1.0.0' -task wrapper(type: Wrapper) { - gradleVersion = '3.3' +wrapper { + gradleVersion = '4.9' distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" } buildscript { - ext.kotlin_version = '1.1.2' + ext.kotlin_version = '1.3.20' repositories { mavenCentral() @@ -23,11 +23,16 @@ repositories { mavenCentral() } +test { + useJUnitPlatform() +} + dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" + compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "com.squareup.moshi:moshi-kotlin:1.5.0" compile "com.squareup.moshi:moshi-adapters:1.5.0" compile "com.squareup.okhttp3:okhttp:3.8.0" compile "org.threeten:threetenbp:1.3.6" - testCompile "io.kotlintest:kotlintest:2.0.2" + testImplementation "io.kotlintest:kotlintest-runner-junit5:3.1.0" } diff --git a/samples/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.jar b/samples/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.jar index f1a1584ef4a..87b738cbd05 100644 Binary files a/samples/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.jar and b/samples/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.properties b/samples/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.properties index 09c0ff530a8..7dc503f149d 100644 --- a/samples/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.properties +++ b/samples/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Mon May 29 15:39:04 EDT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip diff --git a/samples/client/petstore/kotlin/src/test/kotlin/org/openapitools/client/PetApiTest.kt b/samples/client/petstore/kotlin/src/test/kotlin/org/openapitools/client/PetApiTest.kt new file mode 100644 index 00000000000..ad28e4cf8ea --- /dev/null +++ b/samples/client/petstore/kotlin/src/test/kotlin/org/openapitools/client/PetApiTest.kt @@ -0,0 +1,101 @@ +package org.openapitools.client + +import io.kotlintest.shouldBe +import io.kotlintest.matchers.numerics.shouldBeGreaterThan +import io.kotlintest.specs.ShouldSpec +import org.openapitools.client.apis.PetApi +import org.openapitools.client.models.Category +import org.openapitools.client.models.Pet +import org.openapitools.client.models.Tag + +class PetApiTest : ShouldSpec() { + init { + + should("add a pet") { + val petId:Long = 10006 + val pet = Pet( + id = petId, + name = "kotlin client test", + photoUrls = arrayOf("http://test_kotlin_unit_test.com"), + category = Category(petId, "test kotlin category"), + tags = arrayOf(Tag(petId, "test kotlin tag")) + ) + + val api = PetApi() + api.addPet(pet) + + } + + should("get pet by id") { + val petId: Long = 10006 + val api = PetApi() + val result = api.getPetById(petId) + + result.id shouldBe (petId) + result.name shouldBe ("kotlin client test") + result.photoUrls[0] shouldBe ("http://test_kotlin_unit_test.com") + result.category!!.id shouldBe (petId) + result.category!!.name shouldBe ("test kotlin category") + result.tags!![0].id shouldBe (petId) + result.tags!![0].name shouldBe ("test kotlin tag") + + } + + should("find pet by status") { + val api = PetApi() + val result = api.findPetsByStatus(arrayOf("available")) + + result.size.shouldBeGreaterThan(0) + + for(onePet in result) { + onePet.status.shouldBe(Pet.Status.available) + } + + val result2 = api.findPetsByStatus(arrayOf("unknown_and_incorrect_status")) + + result2.size.shouldBe(0) + + } + + should("update a pet") { + val petId:Long = 10007 + val pet = Pet( + id = petId, + name = "kotlin client updatePet", + status = Pet.Status.pending, + photoUrls = arrayOf("http://test_kotlin_unit_test.com") + ) + + val api = PetApi() + api.updatePet(pet) + + // verify updated Pet + val result = api.getPetById(petId) + result.id shouldBe (petId) + result.name shouldBe ("kotlin client updatePet") + result.status shouldBe (Pet.Status.pending) + + } + + //TODO the test fail cause client doesn't support other JSON contentType/Accept + /* + should("update a pet with form") { + val petId:Long = 10007 + val name = "kotlin client updatePet with Form" + val status = "pending" + + val api = PetApi() + api.updatePetWithForm(petId, name, status) + + // verify updated Pet + val result = api.getPetById(petId) + result.id shouldBe (petId) + result.name shouldBe ("kotlin client updatePet with Form") + result.status shouldBe (Pet.Status.pending) + + } + */ + + } + +}