提问者:小点点

如何通过openapitools为二进制字符串生成MultipartFile


请您帮我为文件数组生成org.springframework.web.multipart.MultipartFile的数组/集合:

type: array
items:
  type: string
  format: binary

使用的框架:openapitools v.5的openapigenerator-cli。

目前我只收集了org.springframework.core.io。资源。我尝试了typeMappings/导入地图/小胡子模板,但没有成功。

这是用于 Spring 代码生成的库文件:https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java。


共1个答案

匿名用户

使用了以下解决方法:https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/Java/pojo.mustache 将 {{{datatypeWithEnum}}} 替换为 {{#isFile}}MultipartFile{{/isFile}}{{^isFile}}{{{datatypeWithEnum}}}{{/isFile}},因此在 openapi-generator 工作后,文件将由给定类型表示。