useAbStractionForfiles OpenAPI WebClient无法正常工作
我使用OpenAPI Generator(Gradle插件5.4.0)来生成一些API调用。所述电话之一,从外部服务下载文件,即我的应用程序呼叫并下载,然后代表事件。对于该API,请调用我返回的content-type
设置为application-zip
。当直接调用该API时(IE从浏览器)都可以正常工作。
使用该API定义,我正在尝试生成一个可以有效下载该文件的项目使用的WebClient。这样做我面临以下问题:
每当我尝试调用API下载文件时,我会收到以下错误:
nested Exception是org.springframework.web.reaeactive.function.function.unsupportedmediatiatiatypeepection:内容类型'application/zip'不支持bodytype = java.io.file
我生成的
似乎被忽略了。webclient
似乎返回mono< file>
而不是其他对象实例。我试图通过设置以下OpenAPI Generator配置选项useAbstractionForfiles
来禁用此行为。
谁能为我如何解决这个问题提供一些启示?在这里参考是我的OpenApi Gradle插件配置选项:
configOptions = [
dateLibrary : 'java8',
serializationLibrary : 'jackson',
library : 'webclient',
useAbstractionForFiles : 'true',
useBeanValidation : "true",
interfaceOnly : "true",
serializableModel : "true",
useTags : "true",
reactive : "true",
sourceFolder : 'src/main/java',
testFolder : 'src/test/java'
]
I am using OpenAPI generator (Gradle plugin version 5.4.0) to generate a few API calls. One of said calls, revolves a file download from an external service i.e my application calls that one and downloads and then should proxy the event. For that API call my returned content-type
is set to application-zip
. When invoking that API directly (i.e from a browser) everything works OK.
Using that API definition, I am trying to generate a WebClient to be used by another project that will effectively download that file. Doing so I am facing the following problems:
Whenever I try to invoke the API to download the file I am getting the following error:
nested exception is org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type 'application/zip' not supported for bodyType=java.io.File
My generated
WebClient
seems to return aMono<File>
instead of some other object instance. I tried to disable this behavior by setting the following openapi generator configuration optionuseAbstractionForFiles
but is seems to get ignored.
Can anyone shed some light as to how I can resolve this issue? For reference here is my OpenAPI Gradle Plugin configuration options:
configOptions = [
dateLibrary : 'java8',
serializationLibrary : 'jackson',
library : 'webclient',
useAbstractionForFiles : 'true',
useBeanValidation : "true",
interfaceOnly : "true",
serializableModel : "true",
useTags : "true",
reactive : "true",
sourceFolder : 'src/main/java',
testFolder : 'src/test/java'
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基于OpenAPI-Generator中的测试类,此属性旨在与以下类型的请求主体一起使用:
您可以将文件映射到此类所需类型:
Based on test classes in openapi-generator, this property is intended to work with request body of the following type:
You can map File to any desired type like this: