Giter Site home page Giter Site logo

grape-pagy's Issues

Not throwing validation error: When max_items set

In an endpoint, max_items set to 10. It should have to throw the error if endpoint parms contain items value large than max_items

params do
      use :pagy,
          max_items: 10
 end

Expected:

{
    "error": {
        "status": 422,
        "message": "max_items value max can be 10"
    }
}

max_page - no information provided to the end user

First -- thanks for the great plugin. Super easy to use.

Following on from #8 - there is no way for the user to know what the max_items is set to.

So if it defaults to per_page=10 and the max is also 10 and a user puts in per_page=20. There isn't anyway they can know this was invalid.

Since no error is returned, I would suggest that the max_page value automatically be added to the description of per page.

Alternatively, there should be a way to overwrite the default description value.

Unable to start

Hi :-)

Thank you very much for grape-pagy, this is very handy ! ๐Ÿ‘

I'm trying to use grape-pagy with pagy 6.x but it fails to start with the following error:

/home/app/.gem/ruby/3.1.2/gems/grape-pagy-0.5.1/lib/grape/pagy.rb:35:in `block in <module:Helpers>': undefined method `delete' for nil:NilClass (NoMethodError)
        items = opts.delete(:items) || ::Pagy::DEFAULT[:items]

Deprecation Warnings

Not sure if it is my specific implementation, but I'm getting deprecation warnings when I run rspec. It would seem that we are using the double splat operator, but the code that calls the params does not pass the double splat.

/home/jchan/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/grape-1.6.2/lib/grape/dsl/parameters.rb:67: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/home/jchan/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/grape-pagy-0.3.1/lib/grape/pagy.rb:34: warning: The called method is defined here
      params :pagy do |items: nil, page: nil, **opts|
        items ||= ::Pagy::VARS[:items]
        page ||= ::Pagy::VARS[:page]
        page_param = opts[:page_param] || ::Pagy::VARS[:page_param]
        items_param = opts[:items_param] || ::Pagy::VARS[:items_param]

        @api.route_setting(:pagy_options, opts)
        optional page_param, type: Integer, default: page, desc: 'Page offset to fetch.'
        optional items_param, type: Integer, default: items, desc: 'Number of items to return per page.'
      end
      def use(*names)
        named_params = @api.namespace_stackable_with_hash(:named_params) || {}
        options = names.extract_options!
        names.each do |name|
          params_block = named_params.fetch(name) do
            raise "Params :#{name} not found!"
          end
          instance_exec(options, &params_block)
        end
      end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.