Skip to content

Commit acbf96f

Browse files
rahil-cRahil Chertara
andauthored
Add pagination to open api spec for listing of namespaces, tables, views (#9660)
* Add pagination to open api spec for listing of namespaces, tables, views * Rev for pagination in open api spec * Fix writing in pagination descriptions * Use opaque token * Rev on pagination pr writing * Rev on pagination pr writing py file * Rev on description for pageSize * revise pageToken description * minor rev and make int for pageSize * minor rev and remove emtpy val true for pageSize * use only PageToken instead of NextPageToken * address jack and nastra comments * address final comments * remove they and use min 1 for pageSize --------- Co-authored-by: Rahil Chertara <rchertar@amazon.com>
1 parent bb53c3d commit acbf96f

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

open-api/rest-catalog-open-api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ class Namespace(BaseModel):
7777
)
7878

7979

80+
class PageToken(BaseModel):
81+
__root__: str = Field(
82+
...,
83+
description='An opaque token which allows clients to make use of pagination for a list API (e.g. ListTables). Clients will initiate the first paginated request by sending an empty `pageToken` e.g. `GET /tables?pageToken` or `GET /tables?pageToken=` signaling to the service that the response should be paginated.\nServers that support pagination will recognize `pageToken` and return a `next-page-token` in response if there are more results available. After the initial request, it is expected that the value of `next-page-token` from the last response is used in the subsequent request. Servers that do not support pagination will ignore `next-page-token` and return all results.',
84+
)
85+
86+
8087
class TableIdentifier(BaseModel):
8188
namespace: Namespace
8289
name: str
@@ -597,10 +604,12 @@ class GetNamespaceResponse(BaseModel):
597604

598605

599606
class ListTablesResponse(BaseModel):
607+
next_page_token: Optional[PageToken] = Field(None, alias='next-page-token')
600608
identifiers: Optional[List[TableIdentifier]] = Field(None, unique_items=True)
601609

602610

603611
class ListNamespacesResponse(BaseModel):
612+
next_page_token: Optional[PageToken] = Field(None, alias='next-page-token')
604613
namespaces: Optional[List[Namespace]] = Field(None, unique_items=True)
605614

606615

open-api/rest-catalog-open-api.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ paths:
201201
If `parent` is not provided, all top-level namespaces should be listed.
202202
operationId: listNamespaces
203203
parameters:
204+
- $ref: '#/components/parameters/page-token'
205+
- $ref: '#/components/parameters/page-size'
204206
- name: parent
205207
in: query
206208
description:
@@ -448,6 +450,9 @@ paths:
448450
summary: List all table identifiers underneath a given namespace
449451
description: Return all table identifiers under this namespace
450452
operationId: listTables
453+
parameters:
454+
- $ref: '#/components/parameters/page-token'
455+
- $ref: '#/components/parameters/page-size'
451456
responses:
452457
200:
453458
$ref: '#/components/responses/ListTablesResponse'
@@ -1070,6 +1075,9 @@ paths:
10701075
summary: List all view identifiers underneath a given namespace
10711076
description: Return all view identifiers under this namespace
10721077
operationId: listViews
1078+
parameters:
1079+
- $ref: '#/components/parameters/page-token'
1080+
- $ref: '#/components/parameters/page-size'
10731081
responses:
10741082
200:
10751083
$ref: '#/components/responses/ListTablesResponse'
@@ -1482,6 +1490,25 @@ components:
14821490
explode: false
14831491
example: "vended-credentials,remote-signing"
14841492

1493+
page-token:
1494+
name: pageToken
1495+
in: query
1496+
required: false
1497+
allowEmptyValue: true
1498+
schema:
1499+
$ref: '#/components/schemas/PageToken'
1500+
1501+
page-size:
1502+
name: pageSize
1503+
in: query
1504+
description:
1505+
For servers that support pagination, this signals an upper bound of the number of results that a client will receive.
1506+
For servers that do not support pagination, clients may receive results larger than the indicated `pageSize`.
1507+
required: false
1508+
schema:
1509+
type: integer
1510+
minimum: 1
1511+
14851512
##############################
14861513
# Application Schema Objects #
14871514
##############################
@@ -1581,6 +1608,17 @@ components:
15811608
type: string
15821609
example: [ "accounting", "tax" ]
15831610

1611+
PageToken:
1612+
description:
1613+
An opaque token which allows clients to make use of pagination for a list API (e.g. ListTables).
1614+
Clients will initiate the first paginated request by sending an empty `pageToken` e.g. `GET /tables?pageToken` or `GET /tables?pageToken=`
1615+
signaling to the service that the response should be paginated.
1616+
1617+
Servers that support pagination will recognize `pageToken` and return a `next-page-token` in response if there are more results available.
1618+
After the initial request, it is expected that the value of `next-page-token` from the last response is used in the subsequent request.
1619+
Servers that do not support pagination will ignore `next-page-token` and return all results.
1620+
type: string
1621+
15841622
TableIdentifier:
15851623
type: object
15861624
required:
@@ -3207,6 +3245,8 @@ components:
32073245
ListTablesResponse:
32083246
type: object
32093247
properties:
3248+
next-page-token:
3249+
$ref: '#/components/schemas/PageToken'
32103250
identifiers:
32113251
type: array
32123252
uniqueItems: true
@@ -3216,6 +3256,8 @@ components:
32163256
ListNamespacesResponse:
32173257
type: object
32183258
properties:
3259+
next-page-token:
3260+
$ref: '#/components/schemas/PageToken'
32193261
namespaces:
32203262
type: array
32213263
uniqueItems: true

0 commit comments

Comments
 (0)