[typescript-fetch] Add support for File (application/octet-stream) response types#1367
[typescript-fetch] Add support for File (application/octet-stream) response types#1367spallister wants to merge 2 commits intoOpenAPITools:masterfrom
Conversation
…helper to TS-Fetch API template.
|
@spallister I'll review this change over the weekend and let you know if I've any question. I may need your help to resolve the merge conflicts. |
|
reminder: conflicts should be resolved |
|
@spallister @wing328 ping |
|
@spallister can you please resolve the merge conflicts when you've time? then we'll merge it into master if no one has further feedback on this PR. |
|
Is this still viable in 5.x/6.0 or have too many changes been made since this was introduced to merge it in? |
|
Is there any news for this feature? Being able to use the generated API for downloading blobs seems essential. |
|
@wlievens: This PR would unfortunately need to be updated before it can be accepted given the merge conflicts and submission ~5 years ago (not sure if anything substantially changed that would require changes to this PR's implementation). If you have some time on your hands, we would of course welcome a PR resolving this :) |
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\.master,3.4.x,4.0.x. Default:master.@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @nicokoenig (2018/09) @topce (2018/10)
Description of the PR
This is a copy of a similar PR I submitted to the swagger-codgen repo here. A while back, @wing328 reached out to let me know the majority of the community moved over here, where I might want to consider re-submitting my PR.
The purpose of this PR is to return
application/octet-streamresponse types asFiles, instead of processing them as JSON. In the PR I had submitted to the swagger-codegen repo, I was returning such response types asBlobs, but soon after had a need to obtain the file's name (i.e. whichFilesupports, butBlobdoes not).Note that this PR includes a change for
DefaultGenerator.java, as I needed to add a property to the mustache template model to determine whether the API contained at least one 'File Response'-type Operation. In particular, this was needed so that I could conditionally include aresponseToFilehelper method withinapi.mustacheas necessary (i.e. our TS linter would otherwise throw an unused method warning for applications where no 'File Response'-type Operations were in use).It looks like there is a TypeScript-fetch rewrite taking place over at #569, but figured I'd submit this in case it can be merged in the interim, or incorporated into that rewrite.
Fixes #531