Skip to content

Commit b34db1f

Browse files
authored
Clarify page on syncing OpenAPI spec (API Definitions) (#515)
1 parent 8fbc93d commit b34db1f

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

fern/products/api-def/api-def.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ navigation:
1414
- page: Authentication
1515
path: ./openapi-pages/auth.mdx
1616
- page: Servers
17-
path: ./openapi-pages/servers.mdx
17+
path: ./openapi-pages/servers.mdx
18+
- page: Automation
19+
path: ./openapi-pages/automation.mdx
20+
slug: sync-your-open-api-specification
1821
- section: Endpoints
1922
slug: endpoints
2023
contents:
@@ -60,14 +63,7 @@ navigation:
6063
- page: Schema names
6164
path: ./openapi-pages/extensions/schema-names.mdx
6265
- page: Server names
63-
path: ./openapi-pages/extensions/server-names.mdx
64-
- section: Workflow & automation
65-
skip-slug: true
66-
contents:
67-
- page: Overlay customizations
68-
path: ./openapi-pages/overrides.mdx
69-
- page: Sync your OpenAPI specification
70-
path: ./openapi-pages/automation.mdx
66+
path: ./openapi-pages/extensions/server-names.mdx
7167
- section: Integrate your server framework
7268
slug: frameworks
7369
contents:

fern/products/api-def/openapi-pages/automation.mdx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,31 @@ title: Sync your OpenAPI Specification
33
subtitle: Pull your latest OpenAPI Specification into your Fern Folder automatically.
44
---
55

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+
78
## Setup
89
<Steps>
910
<Step title="Configure the origin URL">
1011
Add the origin field to your generators.yml to specify where your OpenAPI spec is hosted:
1112
```yml title="generators.yml"
1213
api:
13-
path: openapi/openapi.json
14-
origin: https://api.example.com/openapi.json
14+
specs:
15+
- openapi: .path/to/openapi.json # Definition file
16+
overrides: .path/to-openapi-overrides.yml # Overrides file
17+
origin: https://api.example.com/openapi.json # URL to fetch latest spec from
1518
```
1619
</Step>
1720
<Step title="Add the GitHub Action">
1821
Create `.github/workflows/sync-openapi.yml` in your repository:
1922
```yml
2023
name: Sync OpenAPI Specs # can be customized
2124
on: # additional custom triggers can be configured
22-
workflow_dispatch: # manual dispatch
25+
workflow_dispatch: # Manual trigger
2326
push:
2427
branches:
25-
- main # on push to main
28+
- main # Trigger on push to
2629
schedule:
27-
- cron: '0 3 * * *' # everyday at 3:00 AM UTC
30+
- cron: '0 3 * * *' # Daily at 3:00 AM UTC
2831
jobs:
2932
update-from-source:
3033
runs-on: ubuntu-latest
@@ -42,13 +45,16 @@ If you host your OpenAPI Specification at a publicly available URL, you can have
4245
add_timestamp: true
4346
```
4447
</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.
4750
</Step>
4851
<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**.
5053
</Step>
5154
</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).
5355

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

Comments
 (0)