Skip to content

Fix undefined methods#52

Open
mcauser wants to merge 2 commits into
adrian-gomez:masterfrom
mcauser:inject-fix
Open

Fix undefined methods#52
mcauser wants to merge 2 commits into
adrian-gomez:masterfrom
mcauser:inject-fix

Conversation

@mcauser
Copy link
Copy Markdown

@mcauser mcauser commented Jul 6, 2023

  1. In Operation def definitions was building a definitions hash by id, but not actually returning the hash for chaining. Resulting in error:
undefined method `[]=' for #<Swaggard::Swagger::Definition:0x00007feae308c048 @id="Api::V1::CustomersController.create_response", @title="", @properties=[#<Swaggard::Swagger::Response::ResponseModel:0x00007feae308c318 @is_array_response=nil, @response_class="CustomerSerializer", @id="customer">], @description="", @ancestors=[], @ignore_inherited=false>
  1. In Definition def to_doc was selecting required properties, but all_properties contained a ResponseModel which didn't have a required? method.
undefined method `required?' for #<Swaggard::Swagger::Response::ResponseModel:0x00007fc65125fbb0 @is_array_response=nil, @response_class="CustomerSerializer", @id="customer">

Adding the missing required? method seemed cleaner than checking each for the presence of the method before calling it.

# existing
required_properties = all_properties.select(&:required?).map(&:id)
# meh
required_properties = all_properties.select { |p| p.respond_to?(:required?) && p.required? }.map(&:id)

On Ruby 3.0.6 / Rails 6.1.7.4

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 this pull request may close these issues.

1 participant