[BUG][Ruby] Faraday - handle HTTP 0 without Typhoeus/libcurl
Created by: jethrodaniel
Description
When using the Ruby faraday
library
The Ruby client, when built with the faraday
library
option, currently handles HTTP 0 response in a curl/typhoeus specific way, which errors if you're using a different adapter (which is the default case).
The actual error is a no method error for return_message
on Faraday::Response
.
openapi-generator version
openapitools/openapi-generator-cli:v6.2.0
Generation Details
Relevant portion of openapi-generator-config.yaml
:
library: faraday
gemRequiredRubyVersion: '>= 2.7'
Suggest a fix
Fix is simple, just add a respond_to?
here in the response.status == 0
conditional:
https://github.com/OpenAPITools/openapi-generator/blob/3eec4eb326a6c7abd49dcd60e63f3019b966466f/modules/openapi-generator/src/main/resources/ruby-client/api_client_faraday_partial.mustache#L15-L26
i.e,
unless response.success?
- if response.status == 0
+ if response.status == 0 && response.respond_to?(:return_message)
# Errors from libcurl will be made visible here
fail ApiError.new(code: 0,
message: response.return_message)