[Dart2] Fix a bug when asking to upload a MultipartFile as body.#7736
[Dart2] Fix a bug when asking to upload a MultipartFile as body.#7736wing328 merged 6 commits intoOpenAPITools:masterfrom noordawod:feature/multipart-file-request
Conversation
| case 'DELETE': return await _client.delete(url, headers: nullableHeaderParams,); | ||
| case 'PATCH': return await _client.patch(url, headers: nullableHeaderParams, body: msgBody,); | ||
| case 'HEAD': return await _client.head(url, headers: nullableHeaderParams,); | ||
| case 'GET': return await _client.get(url, headers: nullableHeaderParams,); |
There was a problem hiding this comment.
Some use dartfmt to reformat the generated code, this would make it look nicer for them. Same below.
|
Are you available on slack or gitter? can you msg me there? Would be nice to have some tests for it. |
I'm on Slack. If there's a Slack channel for openapi, then I'm not on it yet. Invite? (email is on my profile page) |
Yes, of course. With this change, we no longer need to define a helper class (extending MultipartRequest) and we can reuse the existing StreamedRequest class that comes with Dart. Simple and efficient. |
|
If no one has further feedback on this change, I'll merge it tomorrow (Tue) |
The current generator produces code that won't work when trying to upload a file not part of a multipart-form data.
As an example, the generated code for an API endpoint with a file which is not part of a multipart-form request is as follows:
However,
invokeAPI()doesn't take that into account and only checks for aMultipartRequest. This pr adds support for sending a single file when uploading non-multipart form data.plus, added some tlc to the
QueryParamclass :)@ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) @athornz (2019/12) @amondnet (2019/12) @agilob @wing328 @sbu-WBT
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