1

我正在尝试在构建脚本中将我的简单项目从 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" ) {
      ...
    }

这对我来说不是很熟悉。谢谢。

4

1 回答 1

2

如果有人仍在寻找此信息,您可以使用 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对其进行了测试。

于 2018-04-19T12:12:31.233 回答