Skip to content

Commit 9a5dabb

Browse files
chore: documented webhooks native support (#330)
Co-authored-by: Danny Sheridan <[email protected]>
1 parent 195504e commit 9a5dabb

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

fern/docs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,9 @@ redirects:
469469
- source: /learn/api-definition/openapi/:slug*
470470
destination: /learn/openapi-definition/:slug*
471471
permanent: true
472+
- source: /learn/openapi-definition/extensions/webhooks
473+
destination: /learn/openapi-definition/endpoints/webhooks
474+
permanent: true
472475

473476
# API Definition Fern specific redirects first
474477
- source: /learn/api-definition/fern/endpoints/:slug*
@@ -546,3 +549,4 @@ redirects:
546549
- source: /learn/api-reference/tokens/:slug*
547550
destination: /learn/cli-api-reference/api-reference/tokens/:slug*
548551
permanent: true
552+

fern/products/docs/pages/api-references/generate-webhook-ref.mdx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@ title: Generate your Webhook Reference
33
description: Use Fern Docs to generate your Webhook Reference documentation from your API definition, using your choice of either OpenAPI or Fern Definition.
44
---
55

6-
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!
6+
Similar to API References, Fern Docs can automatically generate your Webhook Reference documentation from your API definition.
7+
8+
Fern supports webhooks through:
9+
- **OpenAPI 3.1+**: Use the native `webhooks` field with an `operationId` (recommended)
10+
- **OpenAPI 3.0**: Use the `x-fern-webhook: true` extension
11+
- **Fern Definition**: Define `webhooks` in your specification
12+
13+
For more information on how to define webhooks, see:
14+
- [Webhooks in OpenAPI](../../openapi-definition/endpoints/webhooks)
15+
- [Webhooks in Fern Definition](../../fern-definition/webhooks)
716

817
Example:
918

fern/products/openapi-def/openapi-def.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ navigation:
1111
- page: HTTP JSON Endpoints
1212
path: ./pages/endpoints/rest.mdx
1313
slug: http
14+
- page: Webhooks
15+
path: ./pages/webhooks.mdx
1416
- page: Multipart Form Uploads
1517
path: ./pages/endpoints/multipart.mdx
1618
slug: multipart
@@ -20,8 +22,6 @@ navigation:
2022
- section: Extensions
2123
slug: extensions
2224
contents:
23-
- page: Webhooks
24-
path: ./pages/webhooks.mdx
2525
- page: Audiences
2626
path: ./pages/extensions/audiences.mdx
2727
- page: SDK Method Names

fern/products/openapi-def/pages/webhooks.mdx

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
11
---
2-
title: Define Webhooks in OpenAPI
3-
subtitle: Use the `x-fern-webhook` extension to define webhooks in your OpenAPI spec
2+
title: Webhooks
3+
subtitle: Define webhooks using OpenAPI 3.1+ native webhook support or Fern's extensions
44
---
55

6-
To define a webhook in your OpenAPI specification, add the `x-fern-webhook: true` extension to your endpoint. OpenAPI 3.0.0 or higher is required. Fern will treat the `requestBody` as the webhook payload.
6+
Fern supports two methods for defining webhooks in your OpenAPI specification:
7+
8+
1. Using OpenAPI 3.1's native webhook support (recommended)
9+
2. Using Fern's `x-fern-webhook` extension
10+
11+
## OpenAPI 3.1 Webhooks
12+
13+
For OpenAPI 3.1 specifications, use the `webhooks` top-level field to define your webhook operations. Each webhook requires an `operationId` to be properly processed by Fern.
14+
15+
```yaml openapi.yml {4}
16+
webhooks:
17+
newPlant:
18+
post:
19+
operationId: newPlantWebhook
20+
requestBody:
21+
description: Information about a new Plant in the system
22+
content:
23+
application/json:
24+
schema:
25+
$ref: '#/components/schemas/Plant'
26+
responses:
27+
'200':
28+
description: Return a 200 status to indicate that the data was received successfully
29+
```
30+
31+
## Fern Webhook Extension
32+
33+
For OpenAPI 3.0, use the `x-fern-webhook: true` extension to define webhooks. Fern will treat the `requestBody` as the webhook payload.
734

835
```yaml openapi.yml {6}
936
paths:

0 commit comments

Comments
 (0)