Swagger代码生成到Java Spring从二进制格式的OpenAPI组件生成不正确的文件响应实体

问题描述 投票:1回答:1

我正在使用swagger-codegen-maven-plugin从OpenAPI文件(OpenAPI 3.0.2)生成Spring接口

<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.14</version>

一个REST API的响应应该是PDF文件

components:
    schemas:
        contractFile:
            type: string
            format: binary

生成的Java REST接口然后包含以下方法

default ResponseEntity<File> getContract(@ApiParam(value = "File to download",required=true) @PathVariable("uid") String uid) {
...
}

文件类代表文件系统的路径,但是我在文件系统上没有文件,只是Java内存中的字节,我不想将它们另存为文件到磁盘。

我希望getContract从内存中的流/字节中返回一些StreamResource或文件的某些其他表示形式。是否可能通过swagger-codegen-maven-plugin或其他一些选项?

java spring swagger openapi swagger-codegen
1个回答
0
投票

尝试这样的事情:

© www.soinside.com 2019 - 2024. All rights reserved.