Micronaut Swagger Groovy无法生成openapi yaml文件

时间:2019-01-27 18:40:27

标签: micronaut

我正在将Micronaut 1.0.3与Groovy语言一起使用。 https://docs.micronaut.io/latest/guide/index.html#openapi根据此文档创建了常规代码。

import io.micronaut.runtime.Micronaut
import groovy.transform.CompileStatic
import io.swagger.v3.oas.annotations.*;
import io.swagger.v3.oas.annotations.info.*;

@OpenAPIDefinition(
        info = @Info(
                title = "Hello World",
                version = "0.0",
                description = "My API",
                license = @License(name = "Apache 2.0", url = "http://foo.bar"),
                contact = @Contact(url = "http://gigantic-server.com", name = "Fred", email = "Fred@gigagantic-server.com")
        )
)

@CompileStatic
class Application {
    static void main(String[] args) {
        Micronaut.run(Application)
    }
}

运行应用程序时,它不会生成META-INF/swagger/hello-world-0.0.yml文件。

是否有解决此问题的提示?

谢谢 SR

1 个答案:

答案 0 :(得分:0)

build.gradle中的以下依赖对我有用

annotationProcessor "io.micronaut.configuration:micronaut-openapi"
compile "io.swagger.core.v3:swagger-annotations"
compileOnly "io.micronaut.configuration:micronaut-openapi"

您也可以尝试mn create-app hello-world --features swagger-groovy