Skip to content

Calling to_hash method on Ruby models causes a NoMethodError #5

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

Closed
sjdemartini opened this issue Aug 2, 2020 · 2 comments · Fixed by #19
Closed

Calling to_hash method on Ruby models causes a NoMethodError #5

sjdemartini opened this issue Aug 2, 2020 · 2 comments · Fixed by #19
Assignees

Comments

@sjdemartini
Copy link

Bug

Calling the to_hash method on models (such as Patch::ProjectListResponse) leads to a NoMethodError, due to undefined method `openapi_nullable'.

Context

It looks like in this commit 4dc45af#diff-2e1c309b08ff393f103c7a4806b6f7bfL42-L44, the self.openapi_nullable methods were (mistakenly?) removed from each of the models, but openapi_nullable is still referenced in the to_hash methods (e.g. here).

To reproduce

require 'patch_ruby'

Patch.configure do |config|
  config.access_token = ENV['PATCH_RUBY_API_KEY']
end

puts Patch::Project.retrieve_projects(page: 1)

which should lead to:

  5: from app.rb:7:in `puts'
  4: from gems/patch_ruby-1.0.0/lib/patch_ruby/models/project_list_response.rb:212:in `to_s'
  3: from gems/patch_ruby-1.0.0/lib/patch_ruby/models/project_list_response.rb:225:in `to_hash'
  2: from gems/patch_ruby-1.0.0/lib/patch_ruby/models/project_list_response.rb:225:in `each_pair'
  1: from gems/patch_ruby-1.0.0/lib/patch_ruby/models/project_list_response.rb:228:in `block in to_hash'
gems/patch_ruby-1.0.0/lib/patch_ruby/models/project_list_response.rb:52:in `method_missing': undefined method `openapi_nullable' for Patch::ProjectListResponse:Class (NoMethodError)
@bspellacy bspellacy self-assigned this Aug 2, 2020
@biglovisa biglovisa assigned biglovisa and unassigned bspellacy Jan 8, 2021
@biglovisa
Copy link
Contributor

biglovisa commented Jan 8, 2021

Thanks for submitting the issue @sjdemartini! Apologies for taking so long to get back to you, we have a fix up: #19.

@sjdemartini
Copy link
Author

Cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants