Ruby generated code using SSL not requiring openssl


(Jprevost) #1

Example ruby code is looking like:

require 'uri'
require 'net/http'

url = URI("https://example.com/api/v1/ping")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body

It should require openssl to work out of the box like:

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://example.com/api/v1/ping")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body

Also, I’m not sure if this is where to file potential bug reports… if there’s a better place please let me know (although hopefully I’m done finding them as I really like stoplight in my couple hours of testing so far).


(Jprevost) #2

Hmm. Are you using httpsnippet to generate code? Based on this issue kinda looks like it:

It seems like a simple fix upstream if so, but that’s been open for a long time so maybe not.


(Taylor Barnett) #3

Nice catch. That’s the library we are using. I’ll open something on our end, but I am not sure when it will get fixed.


(Jprevost) #4

I may PR a fix upstream but it’s unclear how active the repo is.

If I do I’ll report back here (I already have a fix locally I’m just now realizing they haven’t had a successful build in CI for a long time and… ugh).


(Jprevost) #5

I’ve opened a PR to address this problem in httpsnippet.


(Taylor Barnett) #6

Could you also make the same PR here? https://github.com/stoplightio/httpsnippet

It is our forked version, and we probably have a better chance getting it merged there than in the source repo.


(Jprevost) #7

Oh excellent. Will do.


(Jprevost) #8