1 minute to read
exportOpenAPI
About This Task
This task exports an OpenAPI Specification definition yaml file to a AsciiDoc document. Currently, this task depends on OpenAPI Generator (v4.3.1) and its gradle plugin.
Configuration
Config.groovy
// Configuration for OpenAPI related task
openApi = [:]
// 'specFile' is the name of OpenAPI specification yaml file. Tool expects this file inside working dir (as a filename or relative path with filename)
// 'infoUrl' and 'infoEmail' are specification metadata about further info related to the API. By default this values would be filled by openapi-generator plugin placeholders
//
openApi.with {
specFile = 'src/docs/petstore-v2.0.yaml' // i.e. 'petstore.yaml', 'src/doc/petstore.yaml'
infoUrl = 'https://my-api.company.com'
infoEmail = 'info@company.com'
}
Source
Show source code of scripts/exportOpenApi.gradle
or go directly to GitHub · docToolchain/scripts/exportOpenApi.gradle.
scripts/exportOpenApi.gradle
task exportOpenApi (
type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask,
group: 'docToolchain',
description: 'exports OpenAPI specification to the asciidoc file') {
if (!specFile) {
logger.info("\n---> OpenAPI specification file not found in Config.groovy (https://doctoolchain.github.io/docToolchain/#_exportopenapi)")
return
} else {
logger.info("Found OpenAPI specification in Config.groovy")
}
outputs.upToDateWhen { false }
outputs.cacheIf { false }
generatorName = 'asciidoc'
outputDir = "${targetDir}/OpenAPI".toString()
inputSpec = "${docDir}/${specFile}" // plugin is not able to find file if inputPath is defined as '.'
logger.debug("\n=====================\nProject Config:\n=====================")
logger.debug("Docdir: ${docDir}")
logger.debug("Target: ${targetDir}")
logger.info("\n=====================\nOpenAPI Config:\n=====================")
logger.info("Specification file: ${specFile}")
logger.info("inputSpec: ${inputSpec}")
logger.info("outputDir: ${outputDir}\n")
additionalProperties = [
infoEmail:"${config.openApi.infoEmail}",
infoUrl:"${config.openApi.infoUrl}"
]
}
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.