apiary-client
apiary-client copied to clipboard
uninitialized constant Apiary::Command::Fetch::OpenStruct (NameError)
The apiary fetch command is giving me an OpenStruct error:
➜ apiary fetch --api-name="api" --output="api.apib"
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
/Users/user/.rvm/gems/ruby-3.3.1@apidocs/gems/apiaryio-0.17.0/lib/apiary/command/fetch.rb:12:in `initialize': uninitialized constant Apiary::Command::Fetch::OpenStruct (NameError)
@options = OpenStruct.new(opts)
^^^^^^^^^^
from /Users/user/.rvm/gems/ruby-3.3.1@apidocs/gems/apiaryio-0.17.0/lib/apiary/cli.rb:28:in `new'
This can be fixed by adding require 'ostruct' after the require 'json' in gems/apiaryio-0.17.0/lib/apiary/command/fetch.rb
e.g.
➜ head -7 /Users/user/.rvm/gems/ruby-3.3.1@apidocs/gems/apiaryio-0.17.0/lib/apiary/command/fetch.rb
# encoding: utf-8
require 'rest-client'
require 'json'
require 'ostruct'
require 'apiary/agent'
I have not raised this as a pull request at this point as I felt it was worth a discussion first. I'm not sure if this is related to the version of Ruby. I'm using v3.3.1. Please let me know your thoughts and whether I should raise this as a PR?
I went ahead and submitted a simple PR to fix this. I'd love to hear the maintainers' comments on how to improve it though. https://github.com/apiaryio/apiary-client/pull/220
A workaround is to use the environment variable RUBYOPT='-rostruct'
Example : RUBYOPT='-rostruct' apiary preview