mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-09 06:46:12 +00:00
Generate merge spec (#14387)
This commit is contained in:
@@ -39,6 +39,7 @@ import org.openapitools.codegen.CodegenConstants
|
||||
import org.openapitools.codegen.DefaultGenerator
|
||||
import org.openapitools.codegen.config.CodegenConfigurator
|
||||
import org.openapitools.codegen.config.GlobalSettings
|
||||
import org.openapitools.codegen.config.MergedSpecBuilder
|
||||
|
||||
/**
|
||||
* A task which generates the desired code.
|
||||
@@ -96,6 +97,21 @@ open class GenerateTask : DefaultTask() {
|
||||
@PathSensitive(PathSensitivity.RELATIVE)
|
||||
val inputSpec = project.objects.property<String>()
|
||||
|
||||
/**
|
||||
* Local root folder with spec files
|
||||
*/
|
||||
@Optional
|
||||
@get:InputFile
|
||||
@PathSensitive(PathSensitivity.RELATIVE)
|
||||
val inputSpecRootDirectory = project.objects.property<String>();
|
||||
|
||||
/**
|
||||
* Name of the file that will contains all merged specs
|
||||
*/
|
||||
@Input
|
||||
@Optional
|
||||
val mergedFileName = project.objects.property<String>();
|
||||
|
||||
/**
|
||||
* The remote Open API 2.0/3.x specification URL location.
|
||||
*/
|
||||
@@ -527,6 +543,11 @@ open class GenerateTask : DefaultTask() {
|
||||
@Suppress("unused")
|
||||
@TaskAction
|
||||
fun doWork() {
|
||||
inputSpecRootDirectory.ifNotEmpty { inputSpecRootDirectoryValue -> {
|
||||
inputSpec.set(MergedSpecBuilder(inputSpecRootDirectoryValue, mergedFileName.get()).buildMergedSpec())
|
||||
logger.info("Merge input spec would be used - {}", inputSpec.get())
|
||||
}}
|
||||
|
||||
cleanupOutput.ifNotEmpty { cleanup ->
|
||||
if (cleanup) {
|
||||
project.delete(outputDir)
|
||||
|
||||
Reference in New Issue
Block a user