forked from loafle/openapi-generator-original
The gradle plugin sets all System properties before generation, then reverts them back to their original state. System.getProperty/setProperty return null if the property was not previously set. The Kotlin map was defined with non-nullable key/value constraints, so setting something not commonly set (modelDocs: "false") would result in an runtime exception. This changes the map to support nullable values, and rather than setting a null System property at the end, it clears those which previously had no value.
73 lines
2.0 KiB
Groovy
73 lines
2.0 KiB
Groovy
buildscript {
|
|
repositories {
|
|
mavenLocal()
|
|
mavenCentral()
|
|
maven {
|
|
url "https://plugins.gradle.org/m2/"
|
|
}
|
|
maven {
|
|
url "https://oss.sonatype.org/content/repositories/releases/"
|
|
}
|
|
maven {
|
|
url "https://oss.sonatype.org/content/repositories/snapshots/"
|
|
}
|
|
}
|
|
dependencies {
|
|
// Updated version can be passed via command line arg as -PopenApiGeneratorVersion=VERSION
|
|
classpath "org.openapitools:openapi-generator-gradle-plugin:$openApiGeneratorVersion"
|
|
}
|
|
}
|
|
|
|
apply plugin: 'org.openapi.generator'
|
|
|
|
openApiMeta {
|
|
generatorName = "Sample"
|
|
packageName = "org.openapitools.example"
|
|
outputFolder = "$buildDir/meta".toString()
|
|
}
|
|
|
|
openApiValidate {
|
|
inputSpec = "$rootDir/petstore-v3.0-invalid.yaml".toString()
|
|
}
|
|
|
|
// Builds a Kotlin client by default.
|
|
openApiGenerate {
|
|
generatorName = "kotlin"
|
|
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
|
|
outputDir = "$buildDir/kotlin".toString()
|
|
apiPackage = "org.openapitools.example.api"
|
|
invokerPackage = "org.openapitools.example.invoker"
|
|
modelPackage = "org.openapitools.example.model"
|
|
configOptions = [
|
|
dateLibrary: "java8"
|
|
]
|
|
systemProperties = [
|
|
modelDocs: "false"
|
|
]
|
|
}
|
|
|
|
task buildGoSdk(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){
|
|
generatorName = "go"
|
|
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
|
|
additionalProperties = [
|
|
packageName: "petstore"
|
|
]
|
|
outputDir = "$buildDir/go".toString()
|
|
configOptions = [
|
|
dateLibrary: "threetenp"
|
|
]
|
|
}
|
|
|
|
task generateGoWithInvalidSpec(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){
|
|
validateSpec = true
|
|
generatorName = "go"
|
|
inputSpec = "$rootDir/petstore-v3.0-invalid.yaml".toString()
|
|
additionalProperties = [
|
|
packageName: "petstore"
|
|
]
|
|
outputDir = "$buildDir/go".toString()
|
|
configOptions = [
|
|
dateLibrary: "threetenp"
|
|
]
|
|
}
|