[BUG][Java][Spring] multiple files upload
Created by: purple-dragon
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
use open api spec 3 to define api to upload multiple files, but openapi generator generate incorrect, following openapi spec
https://swagger.io/specification/#mediaTypeObject section: "To upload multiple files, a multipart media type MUST be used:"
default ResponseEntity<Document> createDocument(@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file,@ApiParam(value = "") @RequestParam(value="metadata", required=false) Object metadata)
should be array: MultipartFile[] file
default ResponseEntity<Document> createDocument(@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile[] file,@ApiParam(value = "") @RequestParam(value="metadata", required=false) Object metadata)
openapi-generator version
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator</artifactId>
<version>4.2.2</version>
</dependency>
OpenAPI declaration file content or url
openapi: "3.0.2"
info:
version: "1.0.0"
title: "File Management API"
description: >-
File Management
paths:
/api/v1/documents:
post:
tags:
- Manage Files
summary: "Upload new file"
operationId: "createDocument"
requestBody:
content:
multipart/form-data:
schema:
properties:
file:
type: array
items:
type: string
format: binary
metadata:
type: object
responses:
201:
description: "Document created, return generated document information"
404:
description: "Not Found"
409:
description: "Conflict"
500:
description: "Internal Server Error"
Command line used for generation
Steps to reproduce
Related issues/PRs
looks like there are similar issues, not sure if it fixed or not.
https://github.com/OpenAPITools/openapi-generator/issues/2210 https://github.com/ga4gh/workflow-execution-service-schemas/issues/43