-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[typescript-fetch] Add support for File (application/octet-stream) response types #1367
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
base: master
Are you sure you want to change the base?
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.sh
and./bin/security/{LANG}-petstore.sh
if 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-stream
response types asFile
s, instead of processing them as JSON. In the PR I had submitted to the swagger-codegen repo, I was returning such response types asBlob
s, but soon after had a need to obtain the file's name (i.e. whichFile
supports, butBlob
does 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 aresponseToFile
helper method withinapi.mustache
as 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