forked from loafle/openapi-generator-original
* added my fork from https://github.com/Place1/swagger-codegen-typescript-browser * ran bin/typescript-fetch-petstore-all.sh * use FormData.append rather than .set for IE11 compat * reverted change to licenseInfo.mustache * reverted some comments * added package.json and tsconfig.json back to the generator * added support for blob (application/octet-stream) responses * models and apis are now in folders * added support for modelPropertyNaming based on the spec * bug fix * updated samples * Restore pom.xml for typescript project * Restore samples/client/petstore/typescript-fetch/tests/default/package.json ≈ * added support for response type Date conversion * updated samples * Rework pom in "samples.ci" * Restore "samples/client/petstore/typescript-fetch/tests/default" * updated configuration class to use property getters to allow clients to implement configuration values as getters * added {{datatype}}ToJSON functions to handle serialization and naming conversions * fixed missing import * fixed compilation error. updated samples * 1 character change to get CI to run again * updated samples * added support for array type request body * updated tests * support for optional request bodies * updated models json converters to handle undefined inputs (to simplify usage in optional contexts like optional request bodies) * updated samples * updated tests * changed to typescript version 2.4 * updated samples * support for optional properties being null, undefined or omitted * updated samples * bug fix * bug fix * updated samples * ran npm install in test project * patch to get tests running * added support for retrieving raw response. added support for binary request bodies. added support for blob data type for files/binary.
71 lines
2.8 KiB
Kotlin
71 lines
2.8 KiB
Kotlin
package org.openapitools.generator.gradle.plugin
|
|
|
|
import org.gradle.testkit.runner.GradleRunner
|
|
import org.gradle.testkit.runner.TaskOutcome
|
|
import org.testng.annotations.Test
|
|
import java.io.File
|
|
import kotlin.test.assertEquals
|
|
import kotlin.test.assertTrue
|
|
|
|
class GenerateTaskDslTest : TestBase() {
|
|
override var temp: File = createTempDir(javaClass.simpleName)
|
|
|
|
private val defaultBuildGradle = """
|
|
plugins {
|
|
id 'org.openapi.generator'
|
|
}
|
|
openApiGenerate {
|
|
generatorName = "kotlin"
|
|
inputSpec = file("spec.yaml").absolutePath
|
|
outputDir = file("build/kotlin").absolutePath
|
|
apiPackage = "org.openapitools.example.api"
|
|
invokerPackage = "org.openapitools.example.invoker"
|
|
modelPackage = "org.openapitools.example.model"
|
|
configOptions = [
|
|
dateLibrary: "java8"
|
|
]
|
|
}
|
|
""".trimIndent()
|
|
|
|
@Test
|
|
fun `openApiGenerate should create an expected file structure from DSL config`() {
|
|
// Arrange
|
|
val projectFiles = mapOf(
|
|
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0.yaml")
|
|
)
|
|
withProject(defaultBuildGradle, projectFiles)
|
|
|
|
// Act
|
|
val result = GradleRunner.create()
|
|
.withProjectDir(temp)
|
|
.withArguments("openApiGenerate")
|
|
.withPluginClasspath()
|
|
.build()
|
|
|
|
// Assert
|
|
assertTrue(result.output.contains("Successfully generated code to"), "User friendly generate notice is missing.")
|
|
|
|
listOf(
|
|
"build/kotlin/.openapi-generator-ignore",
|
|
"build/kotlin/docs/PetsApi.md",
|
|
"build/kotlin/docs/Pets.md",
|
|
"build/kotlin/docs/Error.md",
|
|
"build/kotlin/docs/Pet.md",
|
|
"build/kotlin/README.md",
|
|
"build/kotlin/build.gradle",
|
|
"build/kotlin/.openapi-generator/VERSION",
|
|
"build/kotlin/settings.gradle",
|
|
"build/kotlin/src/main/kotlin/org/openapitools/example/model/Pets.kt",
|
|
"build/kotlin/src/main/kotlin/org/openapitools/example/model/Pet.kt",
|
|
"build/kotlin/src/main/kotlin/org/openapitools/example/model/Error.kt",
|
|
"build/kotlin/src/main/kotlin/org/openapitools/example/api/PetsApi.kt",
|
|
"build/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt"
|
|
).map {
|
|
val f = File(temp, it)
|
|
assertTrue(f.exists() && f.isFile, "An expected file was not generated when invoking the generation.")
|
|
}
|
|
|
|
assertEquals(TaskOutcome.SUCCESS, result.task(":openApiGenerate")?.outcome,
|
|
"Expected a successful run, but found ${result.task(":openApiGenerate")?.outcome}")
|
|
}
|
|
} |