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

[REQ] [RUBY] [FARADAY] Allow middleware to be configured #10495

Merged
merged 7 commits into from
Oct 4, 2021
Merged

[REQ] [RUBY] [FARADAY] Allow middleware to be configured #10495

merged 7 commits into from
Oct 4, 2021

Conversation

johngallagher
Copy link
Contributor

@johngallagher johngallagher commented Sep 29, 2021

What and why

As a developer
Given I am generating a Ruby client
And I am using Faraday
When I configure the generated Ruby client
Then I expect to be able to add middleware in the configuration block
But I cannot
And I have to depend on ugly monkey patches
And that makes my code less reusable and less understandable

For more details, see this issue

Usage

PetstoreAPI.configure do |config|
  config.use :instrumentation, name: "request.faraday.petstore"
  config.request :retry, { retry_statuses: [429], max: 10 }
  config.server_index = nil
end

ActiveSupport::Notifications.subscribe(/request\.faraday.*/) do |name, starts, ends, _, env|
  $stdout.puts '<%s> [%s] %s (%.3f s)' % [name, env[:url].to_s, env[:method].to_s, ends - starts]
end

More details

  • I'm borrowing Faraday's use, request and response syntax to specify the different middleware
  • Then I'm forwarding these onto the connection
  • I've tested this with clients I've generated locally and it works

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.

@wing328
Copy link
Member

wing328 commented Oct 2, 2021

@johngallagher thanks for the PR, which looks good to me.

Is there anything else you want to add to this PR?

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

@johngallagher
Copy link
Contributor Author

johngallagher commented Oct 2, 2021

@johngallagher thanks for the PR, which looks good to me.

Is there anything else you want to add to this PR?

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

Wow - thanks @wing328 !

Ruby pom.xml tests are failing locally

I was trying to get the Ruby pom.xml tests passing but couldn't figure out how to do that.

UPDATE: Circle CI tests are failing

Couldn't figure out how to fix that. I get a Too long with no output (exceeded 10m0s): context deadline exceeded error.

UPDATE: Bitrise CI tests are also failing

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.1.0:jar (default-jar) on project openapi-generator: Execution default-jar of goal org.apache.maven.plugins:maven-jar-plugin:3.1.0:jar failed: Plugin org.apache.maven.plugins:maven-jar-plugin:3.1.0 or one of its dependencies could not be resolved: Could not transfer artifact org.codehaus.plexus:plexus-archiver:jar:3.5 from/to central (https://repo.maven.apache.org/maven2): transfer failed for https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archiver/3.5/plexus-archiver-3.5.jar: Connection reset -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :openapi-generator

What do I do with the above failing tests? Ignore or should I try to fix?

Docs needing updated?

Are there any docs that need updating now that I've added some functionality to the Faraday client?

@johngallagher johngallagher marked this pull request as ready for review October 2, 2021 08:57
@wing328
Copy link
Member

wing328 commented Oct 4, 2021

@wing328 wing328 merged commit 2ceccfb into OpenAPITools:master Oct 4, 2021
@johngallagher johngallagher deleted the ruby-faraday--allow-middleware-to-be-configured branch November 12, 2021 14:11
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.

None yet

2 participants