Skip to content

[Ruby] Enhance Faraday middleware support#12873

Merged
wing328 merged 1 commit into
OpenAPITools:masterfrom
ykitamura-mdsol:ruby-enhance-faraday-middleware-support
Jul 21, 2022
Merged

[Ruby] Enhance Faraday middleware support#12873
wing328 merged 1 commit into
OpenAPITools:masterfrom
ykitamura-mdsol:ruby-enhance-faraday-middleware-support

Conversation

@ykitamura-mdsol

Copy link
Copy Markdown
Contributor

Thanks to @johngallagher Faraday middlewares are configurable now:

In this PR, I'd like to enhance the Faraday middleware support to be able to call the methods to push onto the various positions in the stack (insert, insert_before, insert_after, swap, and delete) and also to be able to pass a block to the methods.

Usage

PetstoreAPI.configure do |config|
  config.set_faraday_middleware(:request, :retry, max: 3, methods: [:get, :post], retry_statuses: [503])
  config.set_faraday_middleware(:response, :logger, nil, { bodies: true, log_level: :debug })
  config.set_faraday_middleware(:use, Faraday::HttpCache, store: Rails.cache, shared_cache: false)
  config.set_faraday_middleware(:insert, 0, FaradayMiddleware::FollowRedirects, { standards_compliant: true, limit: 1 })
  config.set_faraday_middleware(:swap, 0, Faraday::Response::Logger) })
  config.set_faraday_middleware(:delete, Faraday::Multipart::Middleware)
  :

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 (6.1.0) (minor release - breaking changes with fallbacks), 7.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@wing328

@wing328

wing328 commented Jul 15, 2022

Copy link
Copy Markdown
Member

@ykitamura-mdsol thanks for the PR.

cc @cliffano (2017/07) @zlx (2017/09) @autopp (2019/02)

@wing328 wing328 merged commit 9b154bb into OpenAPITools:master Jul 21, 2022
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.

2 participants