提问人:Arthur Shtypuliak 提问时间:11/16/2023 更新时间:11/16/2023 访问量:11
如何在gradle中抑制openApiGenerate任务的日志消息?
How to suppress log messages for openApiGenerate task in gradle?
问:
最近,我尝试使用OpenAPI工具从spec(带有端点描述的yaml文件)生成API。所有配置都很常见,添加了模式的映射以及它在 src 目录中的位置。
plugins {
id 'java'
id 'org.springframework.boot' version "2.7.17"
id 'io.spring.dependency-management' version "1.0.15.RELEASE"
id "org.openapi.generator" version "6.6.0"
}
group = 'com.example.file.service'
version = 'undefined'
java {
sourceCompatibility = '17'
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation "org.springdoc:springdoc-openapi-ui:1.7.0"
implementation "org.openapitools:jackson-databind-nullable:0.2.6"
implementation platform("software.amazon.awssdk:bom:2.20.45")
implementation "software.amazon.awssdk:s3"
}
test {
useJUnitPlatform()
}
openApiValidate {
inputSpec = "$rootDir/src/main/resources/server-api.yml"
}
openApiGenerate {
generatorName = "spring"
inputSpec = "$rootDir/src/main/resources/server-api.yml"
outputDir = "$buildDir/generated"
apiPackage = "com.example.file.service.controller"
modelPackage = "com.example.file.service.model"
configOptions = [
dateLibrary : "java8",
interfaceOnly: "true",
useTags : "true"
]
importMappings = [
"FileMetaDTO": "com.example.file.service.dto.FileMetaDTO",
"ErrorDTO": "com.example.file.service.dto.ErrorDTO",
]
}
tasks.openApiGenerate.dependsOn tasks.processResources
compileJava.dependsOn tasks.openApiGenerate
sourceSets.main.java.srcDir "$buildDir/generated/src/main/java"
sourceSets.main.resources.srcDir "$buildDir/generated/src/main/resources"
以下是具有声明端点的 openAPI yaml 文件的示例:
openapi: 3.0.3
info:
title: Cloud Storage File Service
version: 1.0.0
paths:
# UploadFileController
/cs-api/files/data:
post:
tags:
- upload-file-controller
summary: Upload file
operationId: uploadFile
requestBody:
content:
multipart/form-data:
schema:
type: object
required: [ "file" ]
properties:
file:
type: string
format: binary
required: true
description: File for saving
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: FileMetaDTO
目前一切正常,但是在日志中的openApiGenerate任务期间,我看到诸如“#/components/schemas/{pojo object} is not defined”之类的消息以及带有捐赠链接的消息之后,我发现这很烦人。 以下是我每次构建项目时收到的消息示例:
> Task :processResources
> Task :openApiGenerate
#/components/schemas/FileMetaDTO is not defined
#/components/schemas/FileMetaDTO is not defined
#/components/schemas/FileMetaDTO is not defined
#/components/schemas/FileMetaDTO is not defined
#/components/schemas/FileMetaDTO is not defined
#/components/schemas/FileMetaDTO is not defined
#/components/schemas/FileMetaDTO is not defined
#/components/schemas/FileMetaDTO is not defined
#/components/schemas/FileMetaDTO is not defined
#/components/schemas/FileMetaDTO is not defined
#/components/schemas/FileMetaDTO is not defined
#/components/schemas/FileMetaDTO is not defined
#/components/schemas/FileMetaDTO is not defined
#/components/schemas/FileMetaDTO is not defined
#/components/schemas/FileMetaDTO is not defined
#/components/schemas/FileMetaDTO is not defined
################################################################################
# Thanks for using OpenAPI Generator. #
# Please consider donation to help us maintain this project ? #
# https://opencollective.com/openapi_generator/donate #
################################################################################
Successfully generated code to C:\Users\rifleman99\Develop-projects\file-service\build/generated
> Task :compileJava
> Task :classes
> Task :bootJarMainClassName
查看了不同的资源,但没有发现任何与我的问题相关的资源。 在生成执行期间,是否有任何可能的方法可以为此任务禁用此类消息。
答: 暂无答案
评论