You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fern/products/api-def/openapi-pages/automation.mdx
+17-11Lines changed: 17 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,28 +3,31 @@ title: Sync your OpenAPI Specification
3
3
subtitle: Pull your latest OpenAPI Specification into your Fern Folder automatically.
4
4
---
5
5
6
-
If you host your OpenAPI Specification at a publicly available URL, you can have Fern programmatically fetch the latest spec on a preconfigured cadence through the [sync-openapi GitHub Action](https://github.com/fern-api/sync-openapi). This ensures your committed OpenAPI spec stays up to date with your live API.
6
+
Automatically pull your latest OpenAPI spec from a publicly available URL into your fern folder using the [sync-openapi GitHub Action](https://github.com/fern-api/sync-openapi). This keeps your committed spec in sync with your live API without manual updates.
7
+
7
8
## Setup
8
9
<Steps>
9
10
<Steptitle="Configure the origin URL">
10
11
Add the origin field to your generators.yml to specify where your OpenAPI spec is hosted:
origin: https://api.example.com/openapi.json # URL to fetch latest spec from
15
18
```
16
19
</Step>
17
20
<Step title="Add the GitHub Action">
18
21
Create `.github/workflows/sync-openapi.yml` in your repository:
19
22
```yml
20
23
name: Sync OpenAPI Specs # can be customized
21
24
on: # additional custom triggers can be configured
22
-
workflow_dispatch: # manual dispatch
25
+
workflow_dispatch: # Manual trigger
23
26
push:
24
27
branches:
25
-
- main # on push to main
28
+
- main # Trigger on push to
26
29
schedule:
27
-
- cron: '0 3 * * *' # everyday at 3:00 AM UTC
30
+
- cron: '0 3 * * *' # Daily at 3:00 AM UTC
28
31
jobs:
29
32
update-from-source:
30
33
runs-on: ubuntu-latest
@@ -42,13 +45,16 @@ If you host your OpenAPI Specification at a publicly available URL, you can have
42
45
add_timestamp: true
43
46
```
44
47
</Step>
45
-
<Step title="Add a GitHub token">
46
-
Generate a [fine-grained personal access token](https://github.com/settings/personal-access-tokens) with read/write access to your repository.
48
+
<Step title="Create a GitHub token">
49
+
Generate a [fine-grained personal access token](https://github.com/settings/personal-access-tokens) with **Contents** and **Pull requests** read/write permissions for your repository.
47
50
</Step>
48
51
<Step title="Add to Repository Secrets">
49
-
Navigate to your repository's `Settings > Secrets and variables > Actions`. Select **New repository secret**, name it `OPENAPI_SYNC_TOKEN`, add your token, and click **Add secret**.
52
+
In your repository, go to `Settings > Secrets and variables > Actions`. Click **New repository secret**, name it `OPENAPI_SYNC_TOKEN`, paste your token, and click **Add secret**.
50
53
</Step>
51
54
</Steps>
52
-
By default, this will create daily PRs with API spec updates to the repo containing your fern folder. If you would like to adjust the frequency, learn more about GitHub's [schedule event](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule).
53
55
54
-
<Info> For detailed configuration options and other use cases, see the [sync-openapi GitHub Action README](https://github.com/fern-api/sync-openapi). </Info>
56
+
This creates daily pull requests with any API spec updates. To change the frequency, modify the `cron` schedule (see GitHub's [schedule syntax](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule)).
57
+
58
+
## Other use cases
59
+
60
+
If your OpenAPI spec lives in a different repository (rather than at a public URL), you can sync it to your Fern folder using cross-repository sync. See the [sync-openapi GitHub Action README](https://github.com/fern-api/sync-openapi) for this and other advanced configurations.
0 commit comments