-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs): Document configuring a webhook reference in Fern Docs (#5778
) * feat(docs): Document configuring a webhook reference in Fern Docs * update webhook reference * add to nav * small updates --------- Co-authored-by: fern-bot <info@buildwithfern.com>
- Loading branch information
1 parent
05b0e7b
commit 1184c52
Showing
3 changed files
with
96 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
--- | ||
title: Generate your Webhook Reference | ||
description: Use Fern Docs to generate your Webhook Reference documentation from your API definition, using your choice of either OpenAPI or Fern Definition. | ||
--- | ||
|
||
Similar to API References, Fern Docs can automatically generate your Webhook Reference documentation from your API definition. Simply add `x-fern-webhook: true` to the webhook definitions in your OpenAPI specification or define `webhooks` in your Fern Definition and Fern will generate comprehensive documentation for all your webhooks! | ||
|
||
Example: | ||
|
||
```yml docs.yml {11-12} | ||
navigation: | ||
- section: Introduction | ||
contents: | ||
- page: Getting Started | ||
path: ../introduction/getting-started.md | ||
- page: Authentication | ||
path: ../introduction/authentication.md | ||
- api: API Reference | ||
api-name: api-v1 | ||
display-errors: true | ||
- api: Webhook Reference | ||
api-name: webhooks-v1 | ||
``` | ||
For a real-world example of webhook documentation generated from an API definition, check out [Webflow's Webhooks](https://developers.webflow.com/data/reference/webhooks/events/form-submission). | ||
### Directory Structure | ||
Your webhooks should be defined in a dedicated folder within your Fern project: | ||
<Tabs> | ||
<Tab title="OpenAPI"> | ||
```bash | ||
fern/ | ||
└── apis/ | ||
├── webhooks-v1/ # Webhook definition | ||
│ ├── openapi/ | ||
│ │ └── openapi.yml | ||
│ └── generators.yml | ||
└── api-v1/ # Regular API endpoints | ||
``` | ||
|
||
If you're using OpenAPI, your `generators.yml` file should point to your OpenAPI specification: | ||
|
||
```yml generators.yml | ||
api: | ||
path: openapi/openapi.yml | ||
``` | ||
You can read more about how to define webhooks in your OpenAPI specification [here](/learn/api-definition/openapi/webhooks). | ||
</Tab> | ||
<Tab title="Fern Definition"> | ||
```bash | ||
fern/ | ||
└── apis/ | ||
├── webhooks-v1/ # Webhook definition | ||
│ ├── definition/ | ||
│ │ ├── api.yml | ||
│ │ └── webhooks.yml | ||
│ └── generators.yml | ||
└── api-v1/ # Regular API endpoints | ||
``` | ||
|
||
You can read more about how to define webhooks in your Fern Definition [here](/learn/api-definition/fern/webhooks). | ||
</Tab> | ||
</Tabs> | ||
|
||
### Include more than one Webhook Reference | ||
To include multiple webhook definitions in your documentation, use the `webhook-name` property: | ||
|
||
```yaml title="docs.yml" | ||
navigation: | ||
- api: Payment Webhooks | ||
api-name: payment-webhooks | ||
- api: Order Webhooks | ||
api-name: order-webhooks | ||
``` | ||
When using multiple webhook definitions, organize them in separate directories within your Fern project: | ||
```bash | ||
fern/ | ||
└── apis/ | ||
├── payment-webhooks/ # Payment webhook definitions | ||
│ ├── openapi/ | ||
│ │ └── openapi.yml # Payment webhook OpenAPI spec | ||
│ └── generators.yml | ||
└── order-webhooks/ # Order webhook definitions | ||
├── openapi/ | ||
│ └── openapi.yml # Order webhook OpenAPI spec | ||
└── generators.yml | ||
``` |