[Go] Fix for 'Invalid code for files array in multipart/form-data request'…#8103
[Go] Fix for 'Invalid code for files array in multipart/form-data request'…#8103wing328 merged 3 commits intoOpenAPITools:masterfrom aliakseiz:bug/files-array
Conversation
|
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors. Let me know if you need help fixing it. |
|
Please also run |
|
It looks that circleci build failed due to network connection issue: @wing328 can you please rerun the build? |
|
@aliakseiz thanks for the PR. What about using tabs instead of 4-spaces in the Go mustache templates? |
|
No problem, @wing328 . |
| } | ||
|
|
||
| // readFileHeaderToTempFile reads multipart.FileHeader and writes it to a temporary file | ||
| func readFileHeaderToTempFile(fileHeader *multipart.FileHeader) (*os.File, error) { |
There was a problem hiding this comment.
multipart is not defined as an import here. We should add "mime/multipart" in the import list
Fixes invalid code generation, when multipart/form-data requestBody contains array of files (#8093).
In addition to existing
ReadFormFileToTempFilefunction a new one introducedReadFormFilesToTempFilesreturning a slice of*os.File.To avoid code duplication, common part related to
FileHeaderreading and storing in temporary file moved to newreadFileHeaderToTempFilefunction.controller-api.mustacheupdated to invoke corresponding function, depending on either single or multiple files are in a request.Condition verifying the
ospackage import extended inGoServerCodegen.javawith a slice of files type.Replaced a temporary directory path
"tmp"with""inioutil.TempFilecall to makeTempFile()using the defaultos.TempDirdirectory.Testing
Existing automated tests passed. No new tests added.
Built project locally, manually tested generated code with different specifications (single file, array of files, various file formats).
Technical committee
@antihax @grokify @kemokemo @bkabrda
PR checklist
./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.master