Skip to content
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

Fixed issue where scope is nil when a param_group is used inside an array_of_hash #693

Closed
wants to merge 1 commit into from

Conversation

joshio1
Copy link
Contributor

@joshio1 joshio1 commented Aug 17, 2020

When a param_group is used inside an array_of_hash and the param_group is in a different module / controller, the scope is set to nil, when the param_group is initialized.
This leads to this error:
apipie-rails/lib/apipie/dsl_definition.rb:379:in `param_group': undefined method `apipie_concern?' for nil:NilClass (NoMethodError)

Steps to reproduce:
In a different module define the following param_group:

module UsersSchema:

 module UsersSchema
   def self.included(klazz)
     klazz.def_param_group :index_users do
       property :response, Hash do
          property :users, array_of: Hash do
            param_group :extended_users_schema
          end
       end
     end
     klazz.def_param_group :extended_users_schema do
        property :id, Integer, :desc => 'ID of the user'
     end
   end
 end

The :extended_users_schema gets a scope of nil and a scope has to be explicitly passed to this param_group.

This PR is an attempt to avoid doing that and infer the scope based on the parent param's param_group.

@ofedoren ofedoren force-pushed the master branch 2 times, most recently from 69442b9 to 8215e30 Compare July 25, 2021 19:41
Copy link
Collaborator

@mathieujobin mathieujobin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a test to reproduce the problem if you can 🙏

@mathieujobin
Copy link
Collaborator

merged in with #774

@mathieujobin
Copy link
Collaborator

released as v0.8.2

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.

2 participants