We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Consider enhancing pagination to include page metadata?
Many APIs provide additional page information. All of this information is available to us.
Example: https://stapi.co/api/v2/rest/spacecraft/search
{ "page": { "pagingStrategy": "numeric|cursor" // `numeric` means $page, `cursor` means $after, "pageNumber": 0, // null when pagingStrategy == cursor "pageSize": 50, // reflects the global setting "totalPages": 29, // totalElements / pageSize "totalElements": 1443, // database count(*) with same filter "firstPage": true, // pageNumber == 0 "lastPage": false // pageNumber == totalPages } }
{ "runtime": { "pagination": { "max-page-size": 1000000, "default-page-size": 100, "include-metadata": <boolean; default: false> } } }
$page-metadata
https://server/api/entity?$page-metadata=true
$page
$after
true
false
When the global setting is true:
$page-metadata=true
When the global setting is false:
Priority:
public static bool ShouldIncludeMetadata( int? pageValue, string? afterValue, bool? includeMetadata, bool globalSetting = false) { return includeMetadata switch { true when pageValue.HasValue => true, true when !string.IsNullOrEmpty(afterValue) => true, null when pageValue.HasValue => globalSetting, null when !string.IsNullOrEmpty(afterValue) => globalSetting, _ => false }; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Proposal
Consider enhancing pagination to include page metadata?
Why?
Many APIs provide additional page information. All of this information is available to us.
Example: https://stapi.co/api/v2/rest/spacecraft/search
Example
Configuration
Ad hoc request
$page-metadata
Syntax
https://server/api/entity?$page-metadata=true
Rules
$page
present
$after
present
$page-metadata
value
setting
true
true
true
true
false
false
false
false
As English
When the global setting is
true
:$page
,$after
, and$page-metadata
) are absent.$page
is used.$after
is used.$page-metadata=true
is explicitly used.When the global setting is
false
:$page-metadata
is not used or is set tofalse
.$page-metadata=true
is explicitly used.Priority:
$page-metadata
takes precedence when explicitly set, overriding the absence of$page
or$after
.As C#
The text was updated successfully, but these errors were encountered: