簡體   English   中英

使用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對其進行了測試。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM