forked from loafle/openapi-generator-original
[Enhancement] [Gradle Plugin] Allow templates from classpath (#14909)
* [Enhancement] [Gradle Plugin] Allow templates from classpath * Adding missing argument binding.
This commit is contained in:
parent
ea0190324e
commit
f36590051f
@ -174,6 +174,10 @@ apply plugin: 'org.openapi.generator'
|
||||
|None
|
||||
|The template directory holding a custom template.
|
||||
|
||||
|templateResourcePath
|
||||
|String
|
||||
|Directory with mustache templates via resource path. This option will overwrite any option defined in `templateDir`
|
||||
|
||||
|auth
|
||||
|String
|
||||
|None
|
||||
|
@ -100,6 +100,7 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
||||
inputSpecRootDirectory.set(generate.inputSpecRootDirectory)
|
||||
remoteInputSpec.set(generate.remoteInputSpec)
|
||||
templateDir.set(generate.templateDir)
|
||||
templateResourcePath.set(generate.templateResourcePath)
|
||||
auth.set(generate.auth)
|
||||
globalProperties.set(generate.globalProperties)
|
||||
configFile.set(generate.configFile)
|
||||
|
@ -69,6 +69,11 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
|
||||
*/
|
||||
val templateDir = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* The template location (which may be a directory or a classpath location) holding custom templates.
|
||||
*/
|
||||
val templateResourcePath = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* Adds authorization headers when fetching the OpenAPI definitions remotely.
|
||||
* Pass in a URL-encoded string of name:header with a comma separating multiple values
|
||||
|
@ -133,6 +133,13 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
|
||||
@PathSensitive(PathSensitivity.RELATIVE)
|
||||
val templateDir = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* Resource path containing template files.
|
||||
*/
|
||||
@Optional
|
||||
@Input
|
||||
val templateResourcePath = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* Adds authorization headers when fetching the OpenAPI definitions remotely.
|
||||
* Pass in a URL-encoded string of name:header with a comma separating multiple values
|
||||
@ -707,6 +714,13 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
|
||||
configurator.setTemplateDir(value)
|
||||
}
|
||||
|
||||
templateResourcePath.ifNotEmpty { value ->
|
||||
templateDir.ifNotEmpty {
|
||||
logger.warn("Both templateDir and templateResourcePath were configured. templateResourcePath overwrites templateDir.")
|
||||
}
|
||||
configurator.setTemplateDir(value)
|
||||
}
|
||||
|
||||
packageName.ifNotEmpty { value ->
|
||||
configurator.setPackageName(value)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user