Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions api-playground/openapi-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
icon: "file-json"
---

OpenAPI is a specification for describing REST APIs. Mintlify supports OpenAPI 3.0+ documents to generate interactive API documentation and keep it up to date.
OpenAPI is a specification for describing APIs. Mintlify supports OpenAPI 3.0+ documents to generate interactive REST API documentation, and OpenAPI 3.1+ for documenting webhooks.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the disclaimer on the version should be closer with where the content is at. I don't think it needs to be at the high level overview


## Add an OpenAPI specification file

Expand All @@ -25,7 +25,7 @@

### Specifying the URL for your API

To enable Mintlify features like the API playground, add a `servers` field to your OpenAPI document with your API's base URL.

Check warning on line 28 in api-playground/openapi-setup.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

api-playground/openapi-setup.mdx#L28

Did you really mean 'API's'?

```json
{
Expand Down Expand Up @@ -186,16 +186,14 @@

<Note>
The method and path must exactly match the definition in your OpenAPI specification. If the endpoint doesn't exist in the OpenAPI file, the page will be empty.

For webhooks, use `webhook` (case insensitive) instead of the HTTP method (like `GET` or `POST`) in your reference.
</Note>

### Autogenerate `MDX` files

Use our Mintlify [scraper](https://www.npmjs.com/package/@mintlify/scraping) to autogenerate `MDX` pages for large OpenAPI documents.

Check warning on line 193 in api-playground/openapi-setup.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

api-playground/openapi-setup.mdx#L193

Did you really mean 'autogenerate'?

<Note>
Your OpenAPI document must be valid or the files will not autogenerate.

Check warning on line 196 in api-playground/openapi-setup.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

api-playground/openapi-setup.mdx#L196

Did you really mean 'autogenerate'?
</Note>

The scraper generates:
Expand All @@ -207,12 +205,12 @@
<Steps>
<Step title="Generate `MDX` files.">
```bash
npx @mintlify/scraping@latest openapi-file <path-to-openapi-file>

Check warning on line 208 in api-playground/openapi-setup.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

api-playground/openapi-setup.mdx#L208

Did you really mean 'npx'?
```
</Step>
<Step title="Specify an output folder.">
```bash
npx @mintlify/scraping@latest openapi-file <path-to-openapi-file> -o api-reference

Check warning on line 213 in api-playground/openapi-setup.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

api-playground/openapi-setup.mdx#L213

Did you really mean 'npx'?
```

Add the `-o` flag to specify a folder to populate the files into. If a folder is not specified, the files will populate in the working directory.
Expand All @@ -239,3 +237,29 @@
```

</CodeGroup>

## Webhooks

Webhooks are HTTP callbacks that your API sends to notify external systems when events occur. If your OpenAPI 3.1+ document defines webhooks, you can document them alongside your regular API endpoints.

### Define webhooks in your OpenAPI specification

Add a `webhooks` field to your OpenAPI document alongside the `paths` field.

For more information on defining webhooks, see [Webhooks](https://spec.openapis.org/oas/v3.1.0#oasWebhooks) in the OpenAPI documentation.

### Reference webhooks in MDX files

When creating MDX pages for webhooks, use `webhook` instead of HTTP methods like `GET` or `POST`:

```mdx
---
title: "Example webhook"
description: "Triggered when an event occurs"
openapi: "path/to/openapi-file webhook example-webhook-name"
---
```

<Note>
The webhook name must exactly match the key defined in your OpenAPI specification's `webhooks` field.
</Note>