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
9 changes: 9 additions & 0 deletions open-api/rest-catalog-open-api.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ class Namespace(BaseModel):
)


class NextPageToken(BaseModel):
__root__: str = Field(
...,
description='An opaque next page token, when non-empty this indicates that more results can be returned by server. This should be used in the next request for the query parameter of pageToken.',
)


class TableIdentifier(BaseModel):
namespace: Namespace
name: str
Expand Down Expand Up @@ -581,10 +588,12 @@ class GetNamespaceResponse(BaseModel):


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


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


Expand Down
45 changes: 45 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,33 @@ components:
explode: false
example: "vended-credentials,remote-signing"

page-token:
name: pageToken
in: query
description:
An opaque token which allows clients to make use of pagination for a list API (e.g. ListTables) by signaling to the service that they would
that they would prefer response to be paginated. If pageSize is specified, the service should return exactly the number of items specified by it.

Clients that support pagination initiate the request by sending an 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 NextPageToken in response if there are more results available.
Servers that are non-pagination aware will ignore the token and return all results.
required: false
allowEmptyValue: true
schema:
type: string

page-size:
name: pageSize
in: query
description:
For servers that support pagination, this signals an upper bound of the number of results that client will receive.
For servers that do not support pagination, clients may receive results larger than the indicated pageSize.
required: false
allowEmptyValue: true
schema:
type: string

##############################
# Application Schema Objects #
##############################
Expand Down Expand Up @@ -1581,6 +1616,12 @@ components:
type: string
example: [ "accounting", "tax" ]

NextPageToken:
description:
An opaque next page token, when non-empty this indicates that more results can be returned by server.
This should be used in the next request for the query parameter of pageToken.
type: string

TableIdentifier:
type: object
required:
Expand Down Expand Up @@ -3169,6 +3210,8 @@ components:
ListTablesResponse:
type: object
properties:
next-page-token:
$ref: '#/components/schemas/NextPageToken'
identifiers:
type: array
uniqueItems: true
Expand All @@ -3178,6 +3221,8 @@ components:
ListNamespacesResponse:
type: object
properties:
next-page-token:
$ref: '#/components/schemas/NextPageToken'
namespaces:
type: array
uniqueItems: true
Expand Down