Bug Report Checklist
Description
I want to define api for 'Multiple File Upload' which refer the part in swagger document File Upload.
But the generated script deals with binaries as simple string.
localVarFormParams.append('files', files.join(COLLECTION_FORMATS.csv));
openapi-generator version
v4.3.1
OpenAPI declaration file content or url
I added encoding parameter to force form style but not works well.
openapi: 3.0.3
info:
title: test
version: '0.1'
tags:
- name: test
description: test
servers:
- url: 'http://localhost:3000'
paths:
/api/upload:
post:
tags: []
operationId: upload files
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
message:
type: string
files:
type: array
items:
type: string
format: binary
required:
- message
encoding:
files:
style: form
explode: true
responses:
'200':
description: ok
Generation Details
use this command.
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v4.3.1 generate \
-p supportsES6=true \
-p modelPropertyNaming=camelCase \
-i /local/doc/test.yaml \
-g typescript-axios \
-o /local/app/javascript --verbose
Steps to reproduce
just run by above command, then it generate following script.
if (files) {
localVarFormParams.append('files', files.join(COLLECTION_FORMATS.csv));
}
here is verbose output https://gist.github.com/shrkw/5002c71e33177b99c0529f1506d6ff22
and api.ts https://gist.github.com/shrkw/5002c71e33177b99c0529f1506d6ff22#file-api-ts-L77
Related issues/PRs
Not sure but may be same issue.
BUG multi file upload not implemented fully · Issue #6752 · OpenAPITools/openapi-generator · GitHub
Same issue is facing to this guy.
BUGJavaSpring multiple files upload · Issue #4803 · OpenAPITools/openapi-generator · GitHub
Suggest a fix
I want to set isCollectionFormatMulti attribute, but not sure how to do it.
openapi-generator/apiInner.mustache at f752f29af202885e6b817e5ec002facee1ef0c33 · OpenAPITools/openapi-generator · GitHub
{{#isCollectionFormatMulti}}
{{paramName}}.forEach((element) => {
localVarFormParams.append('{{baseName}}', element as any);
})
{{/isCollectionFormatMulti}}
Bug Report Checklist
Description
I want to define api for 'Multiple File Upload' which refer the part in swagger document File Upload.
But the generated script deals with binaries as simple string.
localVarFormParams.append('files', files.join(COLLECTION_FORMATS.csv));openapi-generator version
v4.3.1
OpenAPI declaration file content or url
I added encoding parameter to force form style but not works well.
Generation Details
use this command.
Steps to reproduce
just run by above command, then it generate following script.
here is verbose output https://gist.github.com/shrkw/5002c71e33177b99c0529f1506d6ff22
and api.ts https://gist.github.com/shrkw/5002c71e33177b99c0529f1506d6ff22#file-api-ts-L77
Related issues/PRs
Not sure but may be same issue.
BUG multi file upload not implemented fully · Issue #6752 · OpenAPITools/openapi-generator · GitHub
Same issue is facing to this guy.
BUGJavaSpring multiple files upload · Issue #4803 · OpenAPITools/openapi-generator · GitHub
Suggest a fix
I want to set isCollectionFormatMulti attribute, but not sure how to do it.
openapi-generator/apiInner.mustache at f752f29af202885e6b817e5ec002facee1ef0c33 · OpenAPITools/openapi-generator · GitHub