com.ancientlightstudios.quarkus.kotlin.openapi.GenerateMojo.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-kotlin-openapi-maven-plugin Show documentation
Show all versions of quarkus-kotlin-openapi-maven-plugin Show documentation
A Maven plugin to use the OpenAPI generator.
package com.ancientlightstudios.quarkus.kotlin.openapi
import org.apache.maven.plugin.AbstractMojo
import org.apache.maven.plugins.annotations.LifecyclePhase
import org.apache.maven.plugins.annotations.Mojo
import org.apache.maven.plugins.annotations.Parameter
import org.apache.maven.project.MavenProject
import java.io.File
abstract class GenerateMojo : AbstractMojo() {
/**
* The current Maven project.
*/
@Parameter(property = "project", required = true, readonly = true)
lateinit var project: MavenProject
/**
* The list of the source files.
*/
@Parameter(required = true)
lateinit var sources: List
/**
* The list of JSON-Patch files to apply to the OpenAPI specification.
*/
@Parameter
var patches: List = listOf()
/**
* Path where the debug output should be written.
*/
@Parameter
var debugOutputFile: String? = null
/**
* The package name of the generated classes.
*/
@Parameter(defaultValue = "com.example.openapi")
lateinit var packageName: String
/**
* Additional package/class imports that should be included. These can contain custom validators or custom type converters.
*/
@Parameter
var additionalImports: List = listOf()
/**
* The name of the interface to generate.
*/
@Parameter(defaultValue = "ExampleInterface")
lateinit var interfaceName: String
/**
* Path prefix to be prepended to generated endpoints.
*/
@Parameter(defaultValue = "")
var pathPrefix: String = ""
/**
* The directory where the generated sources should be put
*/
abstract var outputDirectory: File
@Parameter
var endpoints: List = listOf()
@Parameter
var splitByTags: Boolean = false
@Parameter
var typeMappings: List = listOf()
@Parameter
var contentTypeMappings: List = listOf()
@Parameter
lateinit var interfaceType: InterfaceType
/**
* A list of additional provider classes which should be added as @RegisterProvider annotations to the generated interface.
*/
@Parameter
var additionalProviders: List = listOf()
/**
* If true, generated files will be overwritten even if they are newer than the source files.
*/
@Parameter(defaultValue = "false")
var forceOverwriteGeneratedFiles: Boolean = false
@Parameter(defaultValue = "Request")
lateinit var operationRequestPostfix : String
@Parameter(defaultValue = "Response")
lateinit var operationResponsePostfix : String
@Parameter(defaultValue = "HttpResponse")
lateinit var operationHttpResponsePostfix : String
@Parameter(defaultValue = "Error")
lateinit var operationErrorPostfix : String
@Parameter(defaultValue = "Context")
lateinit var operationContextPostfix : String
@Parameter(defaultValue = "Builder")
lateinit var operationBuilderPostfix : String
@Parameter(defaultValue = "Validator")
lateinit var operationValidatorPostfix : String
@Parameter(defaultValue = "")
var modelNamePrefix : String = ""
@Parameter(defaultValue = "")
var modelNamePostfix : String = ""
override fun execute() {
val config = Config(
sources,
patches,
debugOutputFile,
interfaceName,
packageName,
additionalImports,
outputDirectory.path,
pathPrefix,
endpoints,
splitByTags,
typeMappings,
contentTypeMappings,
interfaceType,
additionalProviders,
forceOverwriteGeneratedFiles,
operationRequestPostfix,
operationResponsePostfix,
operationHttpResponsePostfix,
operationErrorPostfix,
operationContextPostfix,
operationBuilderPostfix,
operationValidatorPostfix,
modelNamePrefix,
modelNamePostfix
)
Generator(config).generate()
registerSourceRoot()
}
abstract fun registerSourceRoot()
}