-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG][Java][Spring] multiple files upload #4803
Comments
How did you fix it? I am also facing the same issue. :( |
@surajgautam no solution for now :( |
Hi there, I managed to generate MultipartFile[] files by using: content: |
Hello, I have the same problem, impossible to generate a MultipartFile[] in Spring Boot with openapi-generator 4.2.2 Anyone knows how to do in Open API v3 ? |
@ericdariel pls check @surajgautam commets |
Hello, I have the same problem. Java client not work for me. I used the previously defined file public ResponseEntity<Void> createDocumentWithHttpInfo(List<File> file, Object metadata) throws RestClientException {
Object postBody = null;
String path = apiClient.expandPath("/api/v1/documents", Collections.<String, Object>emptyMap());
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap<String, String> cookieParams = new LinkedMultiValueMap<String, String>();
final MultiValueMap formParams = new LinkedMultiValueMap();
if (file != null)
//Not compile. FileSystemResource constructor wait a File, not a List<File>
formParams.put("file", new FileSystemResource(file));
if (metadata != null)
formParams.add("metadata", metadata);
final String[] accepts = { };
final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = {
"multipart/form-data"
};
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] { };
ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {};
return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType);
} |
* master: (142 commits) update python samples clarify direction of py client side validation flag (#6850) fix erronous cmd arg example for docker in readme (#6846) [BUG] [JAVA] Fix multiple files upload (#4803) (#6808) [kotlin][client] fix retrofit dependencies (#6836) [PowerShell] add more fields to be customized (#6835) [Java][WebClient]remove the dead code from java ApiClient.mustache (#6556) [PHP] Better handling of invalid data (array) (#6760) Make ApiClient in retrofit2 be able to use own OkHttpClient (#6699) mark python2 support in flask as deprecated (#6653) update samples [Java][jersey2] Add a getter for the User-Agent header value (#6831) Provides a default nil value for optional init parameters (#6827) [Java] Deprecate feignVersion option (#6824) [R] Enum R6Class Support, closes #3367 (#5728) [Rust][Client] Unify sync/async client structure (#6753) [php-ze-ph] Set required PHP version to ^7.2 (#6763) [Java][client][native][Gradle] Add missing jackson-databind-nullable (#6802) Improve sttpOpenApiClient generator (#6684) Update docker-tag-latest-release.yml ...
How can I solve the same problem with multiple files upload for ...
requestBody:
required: true
content:
multipart/form-data:
schema:
required:
- files
properties:
files:
type: array
items: { type: string, format: binary }
type: object
... It don't take into account the array of files and generates this code: const localVarFormParams = new FormData();
if (files) {
localVarFormParams.append('files', files.join(COLLECTION_FORMATS.csv));
} It would be great if it produce something like: const localVarFormParams = new FormData();
if (files) {
files.forEach((file) => {
localVarFormParams.append('files[]', file)
});
} Or maybe I'm doing something wrong? |
This issue isn't yet solved @wing328 it's still not working for the Spring generator. multipart/form-data:
schema:
type: object
properties:
files:
type: array
items:
type: string
format: binary |
@tobiashochguertel In my case this problem disappeared when I removed |
Bug Report Checklist
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:"
openapi-generator version
OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
looks like there are similar issues, not sure if it fixed or not.
#2210
ga4gh/workflow-execution-service-schemas#43
Suggest a fix
The text was updated successfully, but these errors were encountered: