无法使用 openapi-generator-gradle-plugin 生成接口

Unable to generate interface with openapi-generator-gradle-plugin

我正在尝试使用 openapi-generator-gradle-plugin 生成模型和控制器接口。

我遇到的问题是插件生成 classes 而不是接口。

生成的 class 如下所示:

    public class DossiersApi {
        private ApiClient localVarApiClient;
    
        public DossiersApi() {
            this(Configuration.getDefaultApiClient());
        }
    
        public DossiersApi(ApiClient apiClient) {
            this.localVarApiClient = apiClient;
        }
    
        public ApiClient getApiClient() {
            return localVarApiClient;
        }
    
        public void setApiClient(ApiClient apiClient) {
            this.localVarApiClient = apiClient;
        }
    
        /**
         * Build call for getDossier
         * @param dossierId Unique identifier of the dossier. (required)
         * @param _callback Callback for upload/download progress
         * @return Call to execute
         * @throws ApiException If fail to serialize the request body object
         * @http.response.details
         <table summary="Response Details" border="1">
            <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
             ...
         </table>
         */
        public okhttp3.Call getDossierCall(Long Id, final ApiCallback _callback) throws ApiException {
            Object localVarPostBody = null; 
    ...

虽然我正在尝试生成一个接口,以便我可以在我的其余控制器中实现它。 查看配置时,我假设 interfaceOnly 参数将使 openapi-generator-gradle-plugin 生成接口而不是 classes,但在我的情况下它不起作用,我我不确定是什么问题。

我已经检查过了,但是 none 的解决方案对我有用: ,

Generate only REST interfaces for spring boot with openapi-generator-gradle-plugin

我的 gradle.build 看起来像这样:

plugins {
    id 'org.springframework.boot' version '2.6.1'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
    id "org.openapi.generator" version "5.1.1"
}

group = 'com.cs'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
targetCompatibility = '17'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.postgresql:postgresql:42.1.4'
    implementation 'javax.validation:validation-api:2.0.1.Final'
    implementation 'org.springframework.boot:spring-boot-starter-security:2.6.1'
    implementation 'io.swagger.core.v3:swagger-annotations:2.1.11'
    implementation 'io.springfox:springfox-swagger2:3.0.0'
    implementation 'io.springfox:springfox-swagger-ui:3.0.0'
    implementation 'org.openapitools:jackson-databind-nullable:0.2.2'
    implementation 'io.jsonwebtoken:jjwt:0.9.1'
    implementation 'org.modelmapper:modelmapper:2.4.4'


    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

test {
    useJUnitPlatform()
}

openApiGenerate {
    generatorName = "java"
    inputSpec = "$rootDir/src/main/resources/swagger.yaml".toString()
    outputDir = "$buildDir/generated".toString()
    apiPackage = "org.openapi.example.api"
    invokerPackage = "org.openapi.example.invoker"
    modelNameSuffix = "Dto"
    generateApiTests = false
    generateModelTests = false
    modelPackage = "org.openapi.example.model"
    configOptions = [
            dateLibrary: 'java8',
            interfaceOnly: 'true',
            skipDefaultInterface: 'true',
            useApiIgnore:'fales',
            swaggerAnnotations: 'true',
    ]
    globalProperties = [
            modelDocs: 'false',
            apis: '',
            models: ''
    ]
}

请注意,我也尝试将 openapi 生成器的版本降级到 5.1.1(我从 5.3.0 开始),但这并没有解决问题。 有人知道如何解决这个问题吗?

谢谢。

java generator(简单地)不支持(优雅地(?-> debug/verbose!))interfaceOnly 选项。

尝试generatorName = "spring" or refer to one of the generators documented in the parent directory