Skip to content

Add pagination to open api spec for listing of namespaces, tables, views #9660

New issue

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

Merged
merged 14 commits into from
Feb 29, 2024
Merged
2 changes: 2 additions & 0 deletions open-api/rest-catalog-open-api.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,10 +581,12 @@ class GetNamespaceResponse(BaseModel):


class ListTablesResponse(BaseModel):
next_page_token: Optional[str] = Field(None, alias='next-page-token')
identifiers: Optional[List[TableIdentifier]] = Field(None, unique_items=True)


class ListNamespacesResponse(BaseModel):
next_page_token: Optional[str] = Field(None, alias='next-page-token')
namespaces: Optional[List[Namespace]] = Field(None, unique_items=True)


Expand Down
52 changes: 52 additions & 0 deletions open-api/rest-catalog-open-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ paths:
If `parent` is not provided, all top-level namespaces should be listed.
operationId: listNamespaces
parameters:
- $ref: '#/components/parameters/page-token'
- $ref: '#/components/parameters/page-size'
- name: parent
in: query
description:
Expand Down Expand Up @@ -448,6 +450,9 @@ paths:
summary: List all table identifiers underneath a given namespace
description: Return all table identifiers under this namespace
operationId: listTables
parameters:
- $ref: '#/components/parameters/page-token'
- $ref: '#/components/parameters/page-size'
responses:
200:
$ref: '#/components/responses/ListTablesResponse'
Expand Down Expand Up @@ -1070,6 +1075,9 @@ paths:
summary: List all view identifiers underneath a given namespace
description: Return all view identifiers under this namespace
operationId: listViews
parameters:
- $ref: '#/components/parameters/page-token'
- $ref: '#/components/parameters/page-size'
responses:
200:
$ref: '#/components/responses/ListTablesResponse'
Expand Down Expand Up @@ -1482,6 +1490,38 @@ components:
explode: false
example: "vended-credentials,remote-signing"

page-token:
name: pageToken
in: query
description:
A unique token which allows clients to make use of pagination by signaling to the service that they would
prefer requests to be paginated based on the number of items specified by pageSize.

New Clients always start the request by sending a required empty pageToken e.g. GET /tables?pageToken
Servers supporting pagination would recognize pagination is requested due to the presence of the pageToken
and honor the contracts specified above by returning a non-empty next pageToken
if there are more results available, or an empty next pageToken indicating no more results.
Servers that are non-pagination aware will ignore the token and return all results as they previously did.

Old clients should not be specifying the new parameters
For servers that support pagination, they would notice the lack of the pageToken
in the query string and return all results at once (mimicking existing behavior).
For servers not supporting pagination, this is the current state and they would return all values at once.
required: false
allowEmptyValue: true
schema:
type: string

page-size:
name: pageSize
in: query
description:
An upper bound on the number of results to return on the next page.
required: false
allowEmptyValue: true
schema:
type: string

##############################
# Application Schema Objects #
##############################
Expand Down Expand Up @@ -3169,6 +3209,12 @@ components:
ListTablesResponse:
type: object
properties:
next-page-token:
description:
A unique next page token, when non-empty this indicates that more results can be returned by server,
and when empty this indicates the returned results are complete.
This should be used in the next request for the query parameter of pageToken.
type: string
identifiers:
type: array
uniqueItems: true
Expand All @@ -3178,6 +3224,12 @@ components:
ListNamespacesResponse:
type: object
properties:
next-page-token:
description:
A unique next page token, when non-empty this indicates that more results can be returned by server,
and when empty this indicates the returned results are complete.
This should be used in the next request for the query parameter of pageToken.
type: string
namespaces:
type: array
uniqueItems: true
Expand Down