bsm / grape-pagy Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
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"
}
}
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.
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]
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, ¶ms_block)
end
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.