openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[typescript-fetch] Support per-request configuration for interceptors

Open orange-buffalo opened this issue 2 years ago • 1 comments

Status Quo

Currently it is not possible to pass any additional per-request configuration to middleware/interceptors used by the clients created by typescript-fetch generator.

An example where such configuration is useful could be:

  • Application that uses default interceptor for error handling (e.g. display a growl message to a user whenever a request fails).
  • In some particular cases, this default behaviour is not suitable and custom error handling is required for the request (e.g. execute a different request, use cached values, etc).

PR suggestion

This PR suggests to pass additional metadata to the requests in the generated clients, which is then passed through to the interceptors. Users of the API clients can then provide custom configuration on per-request basis and their interceptors can make the necessary decisions reading this configuration.

PR checklist

  • [x] Read the contribution guidelines.
  • [x] 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.
  • [x] 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.
  • [x] File the PR against the correct branch: master (6.0.1) (patch release), 6.1.x (breaking changes with fallbacks), 7.0.x (breaking changes without fallbacks)
  • [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.

orange-buffalo avatar Jul 03 '22 02:07 orange-buffalo

cc @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) @davidgamero (2022/03) @mkusaka (2022/04)

orange-buffalo avatar Jul 03 '22 02:07 orange-buffalo