mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-06 15:40:54 +00:00
[gradle-plugin] Pass openapiGeneratorIgnoreList option from the openApiGenerate extension to the corresponding task (#21363)
This commit is contained in:
parent
b929970db2
commit
fbca2b28d0
@ -117,6 +117,7 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
|||||||
additionalProperties.set(generate.additionalProperties)
|
additionalProperties.set(generate.additionalProperties)
|
||||||
serverVariables.set(generate.serverVariables)
|
serverVariables.set(generate.serverVariables)
|
||||||
languageSpecificPrimitives.set(generate.languageSpecificPrimitives)
|
languageSpecificPrimitives.set(generate.languageSpecificPrimitives)
|
||||||
|
openapiGeneratorIgnoreList.set(generate.openapiGeneratorIgnoreList)
|
||||||
importMappings.set(generate.importMappings)
|
importMappings.set(generate.importMappings)
|
||||||
schemaMappings.set(generate.schemaMappings)
|
schemaMappings.set(generate.schemaMappings)
|
||||||
inlineSchemaNameMappings.set(generate.inlineSchemaNameMappings)
|
inlineSchemaNameMappings.set(generate.inlineSchemaNameMappings)
|
||||||
|
@ -570,4 +570,55 @@ class GenerateTaskDslTest : TestBase() {
|
|||||||
"Dry run results message is missing."
|
"Dry run results message is missing."
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `openapiGenerate should set openapiGeneratorIgnoreList option`() {
|
||||||
|
// 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"
|
||||||
|
configOptions = [
|
||||||
|
dateLibrary: "java8"
|
||||||
|
]
|
||||||
|
openapiGeneratorIgnoreList = ["README.md"]
|
||||||
|
}
|
||||||
|
""".trimIndent(),
|
||||||
|
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."
|
||||||
|
)
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
"README.md" !in File(temp, "build/kotlin/").list(),
|
||||||
|
"README.md should not be generated when it is in the openapiGeneratorIgnoreList."
|
||||||
|
)
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
TaskOutcome.SUCCESS, result.task(":openApiGenerate")?.outcome,
|
||||||
|
"Expected a successful run, but found ${result.task(":openApiGenerate")?.outcome}"
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user