使用 kotlin dsl 在 gradle 构建脚本中配置 swagger
Configure swagger in gradle build script with kotlin dsl
我正在尝试在构建脚本中将我的简单项目从 Groovy 切换到 Kotlin。
我正在使用这个插件:
https://github.com/gigaSproule/swagger-gradle-plugin
我的构建脚本中有这个配置:
swagger{
apiSource {
springmvc = false
locations = ['my.location']
schemes = ['https']
host = 'test.com:8080'
info {
title = 'My Service'
version = 'v1'
}
swaggerDirectory = "$buildDir/swagger"
}
这种情况应该指哪里呢?
我应该做类似的事情吗?
task( "swagger" ) {
...
}
我不是很熟悉。
谢谢
如果有人仍在寻找此信息,这就是使用 Gradle Kotlin DSL 的方法:
import com.benjaminsproule.swagger.gradleplugin.model.*
plugins {
id("com.benjaminsproule.swagger") version "1.0.0"
}
swagger {
apiSource(closureOf<ApiSourceExtension> {
springmvc = false
schemes = mutableListOf("https")
host = "test.com:8080"
info(closureOf<InfoExtension> {
title = "My Service"
version = "v1"
description = "My Service Description"
termsOfService = "http://www.example.com/termsOfService"
contact(closureOf<ContactExtension> {
email = "email@internet.com"
name = "A Developer"
url = "http://www.internet.com"
})
license(closureOf<LicenseExtension> {
url = "http://www.apache.org/licenses/LICENSE-2.0.html"
name = "Apache 2.0"
})
})
locations = mutableListOf("com.foo.fighting")
swaggerDirectory = "$buildDir/swagger"
})
}
我已经使用 Gradle v4.6 对其进行了测试。
我正在尝试在构建脚本中将我的简单项目从 Groovy 切换到 Kotlin。 我正在使用这个插件: https://github.com/gigaSproule/swagger-gradle-plugin 我的构建脚本中有这个配置:
swagger{
apiSource {
springmvc = false
locations = ['my.location']
schemes = ['https']
host = 'test.com:8080'
info {
title = 'My Service'
version = 'v1'
}
swaggerDirectory = "$buildDir/swagger"
}
这种情况应该指哪里呢? 我应该做类似的事情吗?
task( "swagger" ) {
...
}
我不是很熟悉。 谢谢
如果有人仍在寻找此信息,这就是使用 Gradle Kotlin DSL 的方法:
import com.benjaminsproule.swagger.gradleplugin.model.*
plugins {
id("com.benjaminsproule.swagger") version "1.0.0"
}
swagger {
apiSource(closureOf<ApiSourceExtension> {
springmvc = false
schemes = mutableListOf("https")
host = "test.com:8080"
info(closureOf<InfoExtension> {
title = "My Service"
version = "v1"
description = "My Service Description"
termsOfService = "http://www.example.com/termsOfService"
contact(closureOf<ContactExtension> {
email = "email@internet.com"
name = "A Developer"
url = "http://www.internet.com"
})
license(closureOf<LicenseExtension> {
url = "http://www.apache.org/licenses/LICENSE-2.0.html"
name = "Apache 2.0"
})
})
locations = mutableListOf("com.foo.fighting")
swaggerDirectory = "$buildDir/swagger"
})
}
我已经使用 Gradle v4.6 对其进行了测试。