Skip to content

Calling to_hash method on Ruby models causes a NoMethodError #5

@sjdemartini

Description

@sjdemartini

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)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions