首页 > 解决方案 > openApiGenerate 不生成模型

问题描述

我使用 gradle 插件

id "org.openapi.generator" version "5.1.1"

和 gradle.plugin 中的任务

openApiGenerate {
    generatorName = "kotlin"
    inputSpec = "$rootDir/src/main/resources/META-INF/resources/API.v1.yaml".toString()
    outputDir = "$rootDir/generated".toString()
    apiPackage = "org.openapi.example.api"
    invokerPackage = "org.openapi.example.invoker"
    modelPackage = "org.openapi.example.model"
    configOptions = [
  

      dateLibrary: "java8"
]

}

当我调用gradlew openApiGenerate

我有

Execution failed for task ':openApiGenerate'.
> There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
   | Error count: 244, Warning count: 0
  Errors:
      
  -attribute paths.'/v1/pet/{name}/home/'(post).responses.406.content is unexpected
  -attribute paths.'/v1/pet/{name}/home'(post).responses.400.content is unexpected
  .......... 

但是如果我在 CLI 版本中调用我的 yaml 生成模型和 API

为什么它称之为异常?

不幸的是,我什至无法在此处添加我的 yaml 的一部分,因为网站告诉我“看起来你添加了很多代码”

如果我添加

skipValidateSpec         = true

我只得到没有模型的 API。为什么?

标签: build.gradlegradle-pluginopenapi-generator

解决方案


推荐阅读