gradle 项目中的 openApiGenerate 插件未生成源代码
openApiGenerate plugin in gradle project not generating source code
以下是我的build.gradle
配置:
plugins {
id 'java'
id 'maven-publish'
id 'org.springframework.boot' version '2.3.9.RELEASE'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id "org.openapi.generator" version "5.1.0"
}
repositories {
mavenCentral()
}
dependencies {
implementation 'io.springfox:springfox-swagger2:2.9.2'
implementation 'io.springfox:springfox-swagger-ui:2.9.2'
implementation 'io.springfox:springfox-bean-validators:2.9.2'
implementation 'org.openapitools:jackson-databind-nullable:0.2.0'
}
group = 'com.test'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
openApiGenerate {
generatorName.set("spring")
inputSpec.set("$rootDir/specs/swagger.json")
outputDir.set("$buildDir/openapi-java-client")
apiPackage.set("com.test.controllers")
modelPackage.set("com.test.models")
configOptions.put("dateLibrary", "java8")
}
sourceSets {
main {
java {
srcDir(files("${openApiGenerate.outputDir.get()}/src/main"))
}
}
}
当我 运行 这个项目 gradle build build 成功但是,它没有从 swagger.json
文件生成源代码,谁能提出什么建议?
我配置有误。现在通过以下设置解决了:
openApiGenerate {
generatorName = "spring"
inputSpec = "$rootDir/spec/swagger.json".toString()
outputDir = "$buildDir/generate-sources".toString()
invokerPackage ="com.test"
apiPackage = "com.test.controllers"
modelPackage = "com.test.models"
configOptions = [
dateLibrary: "java8"
]
}
sourceSets {
main {
java {
srcDir(files("${openApiGenerate.outputDir.get()}/src/main"))
}
}
}
以下是我的build.gradle
配置:
plugins {
id 'java'
id 'maven-publish'
id 'org.springframework.boot' version '2.3.9.RELEASE'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id "org.openapi.generator" version "5.1.0"
}
repositories {
mavenCentral()
}
dependencies {
implementation 'io.springfox:springfox-swagger2:2.9.2'
implementation 'io.springfox:springfox-swagger-ui:2.9.2'
implementation 'io.springfox:springfox-bean-validators:2.9.2'
implementation 'org.openapitools:jackson-databind-nullable:0.2.0'
}
group = 'com.test'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
openApiGenerate {
generatorName.set("spring")
inputSpec.set("$rootDir/specs/swagger.json")
outputDir.set("$buildDir/openapi-java-client")
apiPackage.set("com.test.controllers")
modelPackage.set("com.test.models")
configOptions.put("dateLibrary", "java8")
}
sourceSets {
main {
java {
srcDir(files("${openApiGenerate.outputDir.get()}/src/main"))
}
}
}
当我 运行 这个项目 gradle build build 成功但是,它没有从 swagger.json
文件生成源代码,谁能提出什么建议?
我配置有误。现在通过以下设置解决了:
openApiGenerate {
generatorName = "spring"
inputSpec = "$rootDir/spec/swagger.json".toString()
outputDir = "$buildDir/generate-sources".toString()
invokerPackage ="com.test"
apiPackage = "com.test.controllers"
modelPackage = "com.test.models"
configOptions = [
dateLibrary: "java8"
]
}
sourceSets {
main {
java {
srcDir(files("${openApiGenerate.outputDir.get()}/src/main"))
}
}
}