Skip to content
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

[typescript-angular] Support blob response types #11085

Merged
merged 8 commits into from
Dec 24, 2021

Conversation

oaklandcorp-jkaiser
Copy link
Contributor

Fixes #11021

Generated service methods will try to decide its response type by pattern matching the accept header for text, then json, otherwise defaults to a blob.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    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.
  • File the PR against the correct branch: master (5.3.0), 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Technical Committee:
@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02)

Copy link
Contributor

@amakhrov amakhrov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR!
The fix looks good, as it fixes the runtime behavior.

It looks like the type signature of the api service method remains incorrect in this case - in your example it stays Observable<string> instead of Observable<Blob>

I realize that a proper fix for the typings can be more involved (just look at those gazillions overloads in Angular's own HttpClient#request). So we can probably address it later - unless you feel like doing it and have a good approach for that in mind. Any thoughts?

@oaklandcorp-jkaiser
Copy link
Contributor Author

Thanks for your PR! The fix looks good, as it fixes the runtime behavior.

It looks like the type signature of the api service method remains incorrect in this case - in your example it stays Observable<string> instead of Observable<Blob>

I realize that a proper fix for the typings can be more involved (just look at those gazillions overloads in Angular's own HttpClient#request). So we can probably address it later - unless you feel like doing it and have a good approach for that in mind. Any thoughts?

Yes, I noticed that as well when throwing together this quick fix. I decided to keep things minimal so things would be easier to review. Also I believe that same issue plagues the support of a text response type as well, so I went into this thinking the fix wasn't introducing that as a new problem. I would love to have a solution that had an accurate TypeScript interface, but I don't think I'm familiar enough with the project yet to envision how I would make it happen. So I'd lean towards incremental improvement unless someone more experienced has a proposed solution they could walk me through.

Copy link
Contributor Author

@oaklandcorp-jkaiser oaklandcorp-jkaiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I've addressed all PR feedback so far. If there are any other changes you all would suggest please let me know and I'll try to address them as well!

@macjohnny macjohnny merged commit 02a5157 into OpenAPITools:master Dec 24, 2021
@oaklandcorp-jkaiser oaklandcorp-jkaiser deleted the fix_issue11021 branch December 29, 2021 03:55
@djnalluri
Copy link
Contributor

@macjohnny, does this need a milestone?

@macjohnny macjohnny added this to the 5.4.0 milestone Jan 3, 2022
@macjohnny
Copy link
Member

@djnalluri it will automatically be part of the next release. Added milestone 5.4.0 for reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG][typescript-angular] PDF Response Type Treated As JSON
4 participants