lib/grape-swagger/endpoint/params_parser.rb in grape-swagger-0.34.2 vs lib/grape-swagger/endpoint/params_parser.rb in grape-swagger-1.0.0

- old
+ new

@@ -1,19 +1,20 @@ # frozen_string_literal: true module GrapeSwagger module Endpoint class ParamsParser - attr_reader :params, :settings + attr_reader :params, :settings, :endpoint - def self.parse_request_params(params, settings) - new(params, settings).parse_request_params + def self.parse_request_params(params, settings, endpoint) + new(params, settings, endpoint).parse_request_params end - def initialize(params, settings) + def initialize(params, settings, endpoint) @params = params @settings = settings + @endpoint = endpoint end def parse_request_params public_params.each_with_object({}) do |(name, options), memo| name = name.to_s @@ -53,10 +54,16 @@ def public_parameter?(param) param_options = param.last return true unless param_options.key?(:documentation) && !param_options[:required] param_hidden = param_options[:documentation].fetch(:hidden, false) - param_hidden = param_hidden.call if param_hidden.is_a?(Proc) + if param_hidden.is_a?(Proc) + param_hidden = if settings[:token_owner] + param_hidden.call(endpoint.send(settings[:token_owner].to_sym)) + else + param_hidden.call + end + end !param_hidden end def includes_body_param? params.any? do |_, options|