-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add max_per_page value to grape swagger docs
If a max_per_page value is added to grape then it is show in the docs. This avoids confusing if someone tries to pass in a value greater than max_per_page as it will return an error so the user can correct themself. Note this may be a breaking change for some people.
- Loading branch information
Owen Davies
committed
Apr 25, 2018
1 parent
3bf4feb
commit a0b3e6b
Showing
4 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,11 +39,16 @@ def paginate(collection) | |
def self.paginate(options = {}) | ||
route_setting :per_page, options[:per_page] | ||
route_setting :max_per_page, options[:max_per_page] | ||
|
||
enforce_max_per_page = options[:max_per_page] && options[:enforce_max_per_page] | ||
per_page_values = enforce_max_per_page ? 0..options[:max_per_page] : nil | ||
|
||
params do | ||
optional :page, :type => Integer, :default => 1, | ||
:desc => 'Page of results to fetch.' | ||
optional :per_page, :type => Integer, | ||
:desc => 'Number of results to return per page.' | ||
optional :page, :type => Integer, :default => 1, | ||
:desc => 'Page of results to fetch.' | ||
optional :per_page, :type => Integer, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
davidcelis
Owner
|
||
:desc => 'Number of results to return per page.', | ||
:values => per_page_values | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
is there a specific reason not to supply default here ?
something like
during the documentation generation we end up with blank input and it would be nice to see some defaut value instead
if there is a way to do it, please let me know