Skip to content

Commit 9bba92b

Browse files
authored
Update Deep Dives (#93)
1 parent faab920 commit 9bba92b

File tree

4 files changed

+185
-171
lines changed

4 files changed

+185
-171
lines changed

fern/products/sdks/guides/configure-auto-pagination.mdx

Lines changed: 94 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -11,84 +11,8 @@ managing pagination complexity manually.
1111

1212
This page describes how to configure auto pagination for your API endpoints.
1313

14-
## Setting up auto pagination
15-
16-
To configure auto pagination, specify the dot-access path to the related request
17-
or response property in the `x-fern-pagination extension` (OpenAPI) or `pagination`
18-
field (Fern Definition).
19-
20-
For example, if results of `my_nested_object` are located in the subfield
21-
`inner_list`, the dot-access path would be `results:
22-
$response.my_nested_object.inner_list`.
23-
24-
```yaml {7-10}
25-
MyResponseObject:
26-
type: object
27-
properties:
28-
my_nested_object:
29-
type: object
30-
properties:
31-
inner_list: # location of results
32-
type: array
33-
items:
34-
$ref: '#/components/schemas/MyObject'
35-
```
36-
37-
38-
<Tabs>
39-
<Tab title="OpenAPI">
40-
<CodeBlocks>
41-
```yaml Offset {6}
42-
...
43-
paths:
44-
/path/to/my/endpoint:
45-
x-fern-pagination:
46-
offset: $request.page_number
47-
results: $response.results
48-
...
49-
```
50-
51-
```yaml Cursor {8}
52-
...
53-
paths:
54-
/path/to/my/endpoint:
55-
get:
56-
x-fern-pagination:
57-
cursor: $request.cursor
58-
next_cursor: $response.next
59-
results: $response.results
60-
...
61-
```
62-
</CodeBlocks>
63-
</Tab>
64-
65-
<Tab title="Fern Definition">
66-
<CodeBlocks>
67-
68-
```yaml Offset {6}
69-
service:
70-
endpoints:
71-
listWithOffsetPagination:
72-
pagination:
73-
offset: $request.page
74-
results: $response.data
75-
```
76-
77-
```yaml Cursor {7}
78-
service:
79-
endpoints:
80-
listWithCursorPagination:
81-
pagination:
82-
cursor: $request.starting_after
83-
next_cursor: $response.page.next.starting_after
84-
results: $response.data
85-
```
14+
## How it works for SDK users
8615

87-
</CodeBlocks>
88-
</Tab>
89-
</Tabs>
90-
91-
## Generated SDK Usage
9216
<Tabs>
9317
<Tab title="TypeScript" language="typescript">
9418

@@ -159,3 +83,96 @@ service:
15983
</Tab>
16084
</Tabs>
16185

86+
87+
## Setting up auto pagination
88+
89+
Setting up auto pagination involves defining your pagination scheme and where
90+
your results are located.
91+
92+
<AccordionGroup>
93+
<Accordion title="OpenAPI">
94+
95+
To set up auto pagination for OpenAPI:
96+
97+
1. Annotate the desired paginated endpoint with the `x-fern-pagination` extension.
98+
1. Specify the pagination scheme, `offset` or `cursor`
99+
1. Specify where your `results` are located, using dot-access notation.
100+
101+
102+
<CodeBlocks>
103+
```yaml Offset {4-6}
104+
...
105+
paths:
106+
/path/to/my/endpoint:
107+
x-fern-pagination: # Add pagination extension
108+
offset: $request.page_number # Specify offset pagination scheme
109+
results: $response.results # Specify result location
110+
...
111+
```
112+
113+
```yaml Cursor {5-8}
114+
...
115+
paths:
116+
/path/to/my/endpoint:
117+
get:
118+
x-fern-pagination: # Add pagination extension
119+
cursor: $request.cursor # Specify cursor pagination scheme
120+
next_cursor: $response.next
121+
results: $response.results # Specify result location
122+
...
123+
```
124+
</CodeBlocks>
125+
126+
<Info title="How to find the location of your results">
127+
128+
For example, if results of `my_nested_object` are located in the subfield
129+
`inner_list`, the dot-access path would be `results:
130+
$response.my_nested_object.inner_list`.
131+
132+
```yaml {4, 7}
133+
MyResponseObject:
134+
type: object
135+
properties:
136+
my_nested_object:
137+
type: object
138+
properties:
139+
inner_list: # location of results
140+
type: array
141+
items:
142+
$ref: '#/components/schemas/MyObject'
143+
```
144+
</Info>
145+
</Accordion>
146+
147+
<Accordion title="Fern Definition">
148+
149+
To set up auto pagination for the Fern Definition:
150+
151+
1. Annotate the desired paginated endpoint with the `pagination` field.
152+
1. Specify the pagination scheme, `offset` or `cursor`
153+
1. Specify where your `results` are located, using dot-access notation.
154+
155+
<CodeBlocks>
156+
157+
```yaml Offset {6}
158+
service:
159+
endpoints:
160+
listWithOffsetPagination:
161+
pagination: # Add pagination field
162+
offset: $request.page # Specify offset pagination scheme
163+
results: $response.data # Specify result location
164+
```
165+
166+
```yaml Cursor {7}
167+
service:
168+
endpoints:
169+
listWithCursorPagination:
170+
pagination: # Add pagination field
171+
cursor: $request.starting_after # Specify cursor pagination scheme
172+
next_cursor: $response.page.next.starting_after
173+
results: $response.data # Specify result location
174+
```
175+
176+
</CodeBlocks>
177+
</Accordion>
178+
</AccordionGroup>

fern/products/sdks/guides/configure-idempotency.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ for non-idempotent endpoints. This is to ensure that the user knows exactly
6666
which invocations are idempotent and which are not.
6767
</Note>
6868

69-
## Configuring idempotency headers
69+
### Setting up idempotency headers
7070

7171
To set up idempotency headers in your API, you need to do the following in your `overrides` file:
7272
1. Configure the idempotency headers

0 commit comments

Comments
 (0)