Merge remote-tracking branch 'origin/master' into 6.0.x

This commit is contained in:
William Cheng
2021-09-22 12:13:44 +08:00
1475 changed files with 60168 additions and 24150 deletions

View File

@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.3.20'
ext.kotlin_version = '1.3.30'
repositories {
mavenLocal()
maven { url "https://repo1.maven.org/maven2" }

View File

@@ -644,6 +644,8 @@ open class GenerateTask : DefaultTask() {
engine.ifNotEmpty { value ->
if ("handlebars".equals(value, ignoreCase = true)) {
configurator.setTemplatingEngineName("handlebars")
} else {
configurator.setTemplatingEngineName(value)
}
}

View File

@@ -228,4 +228,40 @@ class GenerateTaskDslTest : TestBase() {
assertEquals(TaskOutcome.FAILED, result.task(":openApiGenerate")?.outcome,
"Expected a failed run, but found ${result.task(":openApiGenerate")?.outcome}")
}
@Test
fun `openapiGenerate should attempt to set my-custom-engine (or any other) when specified as engine`() {
// Arrange
val projectFiles = mapOf(
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0.yaml")
)
withProject("""
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"
engine = "my-custom-engine"
}
""".trimIndent(), projectFiles)
// Act
val result = GradleRunner.create()
.withProjectDir(temp)
.withArguments("openApiGenerate", "--stacktrace")
.withPluginClasspath()
.buildAndFail()
// Assert
// as the custom generator doesn't exist, we'll just test that the configurator has set my-custom-engine as the engine.
assertTrue(result.output.contains("my-custom-engine"), "Build should have attempted to use my-custom-engine.")
assertEquals(TaskOutcome.FAILED, result.task(":openApiGenerate")?.outcome,
"Expected a failed run, but found ${result.task(":openApiGenerate")?.outcome}")
}
}