Generate merge spec (#14387)

This commit is contained in:
Oleh Kurpiak
2023-02-17 04:40:05 +02:00
committed by GitHub
parent 0816008f1e
commit 2bc963f00c
10 changed files with 490 additions and 2 deletions

View File

@@ -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)