我正在使用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或其他一些选项?
尝试这样的事情: