- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试让 swagger codegen
在使用 gradle (kotlin) 构建的项目中工作。
我的引用是这里的这个例子:https://github.com/int128/gradle-swagger-generator-plugin这是在 Gradle groovy 版本中制作的。
现在 build.gradle.kts
如下:
repositories {
jcenter()
}
plugins {
java
id("org.springframework.boot") version "2.1.2.RELEASE"
id("io.spring.dependency-management") version "1.0.6.RELEASE"
id("org.hidetake.swagger.generator") version "2.16.0"
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation ("io.swagger:swagger-annotations:1.5.21")
swaggerCodeGen("io.swagger:swagger-codegen-cli:2.3.1")
// Use JUnit test framework
testImplementation ("junit:junit:4.12")
}
swaggerSources {
petstore {
inputFile = file('petstore.yaml')
code {
language = 'spring'
}
}
}
但是 IntelliJ 不喜欢谈论 Swagger 的台词:
我是 gradle 的新手,所以我不明白我应该做什么。 swaggerCodeGen 应该是一个函数吗?这个功能应该在哪里导入? swaggerSources
应该导入哪里?
最佳答案
import org.hidetake.gradle.swagger.generator.GenerateSwaggerCode
// plugins, repositories are same, but note import above ^^^
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation ("io.swagger:swagger-annotations:1.5.21")
"swaggerCodegen"("io.swagger:swagger-codegen-cli:2.3.1") // 1
// Use JUnit test framework
testImplementation ("junit:junit:4.12")
}
swaggerSources {
create("petstore").apply { // 2
setInputFile(file("petstore.yaml")) // 3
code(closureOf<GenerateSwaggerCode> { // 4
language = "spring"
})
}
}
1 - Kotlin 中的动态解析配置如下所示(动态地来自 Groovy,因此在编译时使用它存在问题,String 上的扩展调用运算符是我们的救星);
2 - swaggerSources
返回你NamedDomainObjectContainer<SwaggerSource>
,因此要添加新容器,我们调用 create
以它的名字作为参数;
3 - Kotlin 不如 Groovy 灵活,因此调用 setter 而不是设置字段;
4 - Groovy 的闭包远非函数式接口(interface),因此我们在插件的源代码中指定泛型类型 Closure
没有参数化。
关于kotlin - 尝试在 gradle kotlindsl 中包含 swagger-codegen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54233751/
我需要一种方法来注释我的 openapi 3 规范,以便 swagger-codegen 将注释添加到我的 java 类中,例如 @JsonIgnoreProperties(ignoreUnknown
我升级到 swagger-codegen 3.0.10,屏幕上突然出现大量调试输出。似乎没有关闭它的命令行选项。 有谁知道如何关闭调试输出? 最佳答案 想通了。 Swagger-codegen 使用
我正在尝试使用 https://github.com/swagger-api/swagger-codegen 生成 nodejs 客户端 sdk这是我使用的命令 swagger-codegen gen
I would like to ask if there is a Swagger tool that can generate clients according to the latest
在我的 package.json 文件中,我有运行 graphql-codegen 的脚本条目,但它提示 --config 参数无效: $> yarn gen yarn run v1.21.1 $ g
我有一个.Net Core v2.1 Web API,它使用NSwag生成其Swagger Json。 我有一个这样的响应模型- public class LoginResponse { pu
我正在使用 slick 2.x's codegen从数据库模式生成 Scala 模型的功能。但是,是否可以遍历外键约束以生成相关模型,例如如果我有这个架构 CREATE TABLE people(id
我如何才能获得敏捷的代码生成器,以使用现有的类而不是创建新的类?这可能吗?例如,我想使用org.springframework.data.domain.Page而不是大张旗鼓地创建另一个页面类。 最佳
我正在寻找进入 Swagger,更具体地说,swagger-codegen 工具。我在 github 和 http://swagger.io/ 中都找到了提供的信息、文档和规范。相当困惑(另外,一些指
我正在使用 swagger codegen maven 插件从 swagger 规范生成服务器 stub 。如果我运行 mvn compile然后它正确生成并编译项目。但是,有时我只想运行生成。 具体
我正在尝试从包含的 yaml 生成客户端 acceptParam: name: Accept type: string required: true in: hea
我遇到了 apollo-codegen 未成功生成 typescript 代码的情况。 对于 graphql 文件( generated/schema.graphql ): type Author {
我已经为特定 API 生成了带有 swagger codegen 的客户端应用程序,javascript版本。用 npm 等初始化它。一切都拍手。 然而,当我尝试使用生成的 api 从我的本地主机向
我已经生成了一个 swagger 客户端 api: java -jar swagger-codegen-2.2.3/modules/swagger-codegen-cli/target/swagger
我在 Postgres 中有一个如下所示的设置: CREATE TYPE my_enum AS ENUM ( 'left', 'right'); CREATE TABLE my_table ( dir
我正在尝试使用 codegen 将以下 Matlab 代码转换为 C++。但是它在构建时失败了,我得到了错误: "??? Unless 'rows' is specified, the first i
我目前正在尝试建立一个 Maven 项目,该项目根据一些 WSDL 文件生成一些 Java 代码。 不幸的是,我遇到了一些问题,因为我的测试环境没有有效的 SSL 证书(我已使用 chrome 确认了
我正在使用 swagger/swagger-codegen 实现我的第二个 API。在有了第一个良好的开端之后,我有点陷入以下问题:我有多个定义,如下所示: TopIssueReference:
我需要根据提供的 swagger 文件生成类。不幸的是我对此文件的内容没有影响。 我在 Gladle 中的配置如下所示: task generateApi { doLast { def con
我想从 xml 文件创建 java 类。我用的是JIBX。我试试这个: java -cp C:\Documents and Settings\kliver\Мои документы\Загрузки
我是一名优秀的程序员,十分优秀!