Skip to main content

OpenAPI Embed

3 min readStableIntermediate

OpenApiEmbed turns a remote OpenAPI or Swagger URL into a full API reference inside an MDX page. The fetch, the validation, and the rendering all run on the server, so every endpoint ships as plain HTML that OwnDocs search and search engines can read. Operations render through the same API Blocks, ParamField, and ResponseField components used on hand-written API reference pages. There's no CLI step and no generated file to keep in sync.

Quick Start

One tag with a URL is the whole setup. The embed below reads the live Swagger Petstore document, groups its operations by tag, and keeps the fetch cached for an hour.

Swagger Petstore - OpenAPI 3.0

Version 1.0.27.

This is a sample Pet Store Server based on the OpenAPI 3.0 specification. You can find out more about Swagger at https://swagger.io. In the third iteration of the pet store, we've switched to the design first approach! You can now help us improve the API whether it's by making changes to the definition itself or to the code. That way, with time, we can improve the API in general, and expose some of the new features in OAS3.

Some useful links:

Servers

  • /api/v3

Compatibility: openapi-3-0 · Source paths: 13 · Rendered operations: 19 · Slug: swagger-petstore-openapi-3-0

Pet

Add a new pet to the store.

Add a new pet to the store.

POST/api/v3/petOAuth 2.0

Add a new pet to the store.

Request Body
{ "id": 10, "name": "doggie", "category": { "id": 1, "name": "Dogs" }, "photoUrls": [ "string" ], "tags": [ { "id": 0, "name": "string" } ], "status": "available" }
Request Example
curl -X POST "/api/v3/pet" \ -H "Authorization: Bearer <oauth-token>" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d '{"id":10,"name":"doggie","category":{"id":1,"name":"Dogs"},"photoUrls":["string"],"tags":[{"id":0,"name":"string"}],"status":"available"}'
Response
{ "id": 10, "name": "doggie", "category": { "id": 1, "name": "Dogs" }, "photoUrls": [ "string" ], "tags": [ { "id": 0, "name": "string" } ], "status": "available" }

Request Body

idintegerbody
No description provided.
namestringbodyrequired
No description provided.
categoryobjectbody
No description provided.
category.idintegerbody
No description provided.
category.namestringbody
No description provided.
photoUrlsstring[]bodyrequired
No description provided.
tagsobject[]body
No description provided.
tags[].idintegerbody
No description provided.
tags[].namestringbody
No description provided.
statusstringbody
pet status in the store

Response Fields

idinteger
No description provided.
namestringrequired
No description provided.
categoryobject
No description provided.
category.idinteger
No description provided.
category.namestring
No description provided.
photoUrlsstring[]required
No description provided.
tagsobject[]
No description provided.
tags[].idinteger
No description provided.
tags[].namestring
No description provided.
statusstring
pet status in the store

Update an existing pet.

Update an existing pet by Id.

PUT/api/v3/petOAuth 2.0

Update an existing pet.

Request Body
{ "id": 10, "name": "doggie", "category": { "id": 1, "name": "Dogs" }, "photoUrls": [ "string" ], "tags": [ { "id": 0, "name": "string" } ], "status": "available" }
Request Example
curl -X PUT "/api/v3/pet" \ -H "Authorization: Bearer <oauth-token>" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d '{"id":10,"name":"doggie","category":{"id":1,"name":"Dogs"},"photoUrls":["string"],"tags":[{"id":0,"name":"string"}],"status":"available"}'
Response
{ "id": 10, "name": "doggie", "category": { "id": 1, "name": "Dogs" }, "photoUrls": [ "string" ], "tags": [ { "id": 0, "name": "string" } ], "status": "available" }

Request Body

idintegerbody
No description provided.
namestringbodyrequired
No description provided.
categoryobjectbody
No description provided.
category.idintegerbody
No description provided.
category.namestringbody
No description provided.
photoUrlsstring[]bodyrequired
No description provided.
tagsobject[]body
No description provided.
tags[].idintegerbody
No description provided.
tags[].namestringbody
No description provided.
statusstringbody
pet status in the store

Response Fields

idinteger
No description provided.
namestringrequired
No description provided.
categoryobject
No description provided.
category.idinteger
No description provided.
category.namestring
No description provided.
photoUrlsstring[]required
No description provided.
tagsobject[]
No description provided.
tags[].idinteger
No description provided.
tags[].namestring
No description provided.
statusstring
pet status in the store

Finds Pets by status.

Multiple status values can be provided with comma separated strings.

GET/api/v3/pet/findByStatusOAuth 2.0

Finds Pets by status.

Request Example
curl -X GET "/api/v3/pet/findByStatus?status=available" \ -H "Authorization: Bearer <oauth-token>" \ -H "Accept: application/json"
Response
[ { "id": 10, "name": "doggie", "category": { "id": 1, "name": "Dogs" }, "photoUrls": [ "string" ], "tags": [ { "id": 0, "name": "string" } ], "status": "available" } ]

Query Parameters

statusstringqueryDefault: availablerequired
Status values that need to be considered for filter

Response Fields

items.idinteger
No description provided.
items.namestringrequired
No description provided.
items.categoryobject
No description provided.
items.category.idinteger
No description provided.
items.category.namestring
No description provided.
items.photoUrlsstring[]required
No description provided.
items.tagsobject[]
No description provided.
items.tags[].idinteger
No description provided.
items.tags[].namestring
No description provided.
items.statusstring
pet status in the store

Finds Pets by tags.

Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.

GET/api/v3/pet/findByTagsOAuth 2.0

Finds Pets by tags.

Request Example
curl -X GET "/api/v3/pet/findByTags?tags=%3Ctags%3E" \ -H "Authorization: Bearer <oauth-token>" \ -H "Accept: application/json"
Response
[ { "id": 10, "name": "doggie", "category": { "id": 1, "name": "Dogs" }, "photoUrls": [ "string" ], "tags": [ { "id": 0, "name": "string" } ], "status": "available" } ]

Query Parameters

tagsstring[]queryrequired
Tags to filter by

Response Fields

items.idinteger
No description provided.
items.namestringrequired
No description provided.
items.categoryobject
No description provided.
items.category.idinteger
No description provided.
items.category.namestring
No description provided.
items.photoUrlsstring[]required
No description provided.
items.tagsobject[]
No description provided.
items.tags[].idinteger
No description provided.
items.tags[].namestring
No description provided.
items.statusstring
pet status in the store

Find pet by ID.

Returns a single pet.

GET/api/v3/pet/{petId}api_key

Find pet by ID.

Request Example
curl -X GET "/api/v3/pet/{petId}" \ -H "X-API-Key: <api-key>" \ -H "Accept: application/json"
Response
{ "id": 10, "name": "doggie", "category": { "id": 1, "name": "Dogs" }, "photoUrls": [ "string" ], "tags": [ { "id": 0, "name": "string" } ], "status": "available" }

Path Parameters

petIdintegerpathrequired
ID of pet to return

Response Fields

idinteger
No description provided.
namestringrequired
No description provided.
categoryobject
No description provided.
category.idinteger
No description provided.
category.namestring
No description provided.
photoUrlsstring[]required
No description provided.
tagsobject[]
No description provided.
tags[].idinteger
No description provided.
tags[].namestring
No description provided.
statusstring
pet status in the store

Updates a pet in the store with form data.

Updates a pet resource based on the form data.

POST/api/v3/pet/{petId}OAuth 2.0

Updates a pet in the store with form data.

Request Example
curl -X POST "/api/v3/pet/{petId}?name=%3Cname%3E&status=%3Cstatus%3E" \ -H "Authorization: Bearer <oauth-token>" \ -H "Accept: application/json"
Response
{ "id": 10, "name": "doggie", "category": { "id": 1, "name": "Dogs" }, "photoUrls": [ "string" ], "tags": [ { "id": 0, "name": "string" } ], "status": "available" }

Path Parameters

petIdintegerpathrequired
ID of pet that needs to be updated

Query Parameters

namestringquery
Name of pet that needs to be updated
statusstringquery
Status of pet that needs to be updated

Response Fields

idinteger
No description provided.
namestringrequired
No description provided.
categoryobject
No description provided.
category.idinteger
No description provided.
category.namestring
No description provided.
photoUrlsstring[]required
No description provided.
tagsobject[]
No description provided.
tags[].idinteger
No description provided.
tags[].namestring
No description provided.
statusstring
pet status in the store

Deletes a pet.

Delete a pet.

DELETE/api/v3/pet/{petId}OAuth 2.0

Deletes a pet.

Request Example
curl -X DELETE "/api/v3/pet/{petId}" \ -H "Authorization: Bearer <oauth-token>" \ -H "api_key: <api_key>"
Response

Path Parameters

petIdintegerpathrequired
Pet id to delete

Header Parameters

api_keystringheader
No description provided.

Uploads an image.

Upload image of the pet.

POST/api/v3/pet/{petId}/uploadImageOAuth 2.0

Uploads an image.

Request Body
"string"
Request Example
curl -X POST "/api/v3/pet/{petId}/uploadImage?additionalMetadata=%3CadditionalMetadata%3E" \ -H "Authorization: Bearer <oauth-token>" \ -H "Accept: application/json" \ -H "Content-Type: application/octet-stream" \ -d '"string"'
Response
{ "code": 0, "type": "string", "message": "string" }

Path Parameters

petIdintegerpathrequired
ID of pet to update

Query Parameters

additionalMetadatastringquery
Additional Metadata

Response Fields

codeinteger
No description provided.
typestring
No description provided.
messagestring
No description provided.

Store

Returns pet inventories by status.

Returns a map of status codes to quantities.

GET/api/v3/store/inventoryapi_key

Returns pet inventories by status.

Request Example
curl -X GET "/api/v3/store/inventory" \ -H "X-API-Key: <api-key>" \ -H "Accept: application/json"
Response

Place an order for a pet.

Place a new order in the store.

POST/api/v3/store/orderNo auth required

Place an order for a pet.

Request Body
{ "id": 10, "petId": 198772, "quantity": 7, "shipDate": "2026-01-01T00:00:00Z", "status": "approved", "complete": false }
Request Example
curl -X POST "/api/v3/store/order" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d '{"id":10,"petId":198772,"quantity":7,"shipDate":"2026-01-01T00:00:00Z","status":"approved","complete":false}'
Response
{ "id": 10, "petId": 198772, "quantity": 7, "shipDate": "2026-01-01T00:00:00Z", "status": "approved", "complete": false }

Request Body

idintegerbody
No description provided.
petIdintegerbody
No description provided.
quantityintegerbody
No description provided.
shipDatestringbody
No description provided.
statusstringbody
Order Status
completebooleanbody
No description provided.

Response Fields

idinteger
No description provided.
petIdinteger
No description provided.
quantityinteger
No description provided.
shipDatestring
No description provided.
statusstring
Order Status
completeboolean
No description provided.

Find purchase order by ID.

For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.

GET/api/v3/store/order/{orderId}No auth required

Find purchase order by ID.

Request Example
curl -X GET "/api/v3/store/order/{orderId}" \ -H "Accept: application/json"
Response
{ "id": 10, "petId": 198772, "quantity": 7, "shipDate": "2026-01-01T00:00:00Z", "status": "approved", "complete": false }

Path Parameters

orderIdintegerpathrequired
ID of order that needs to be fetched

Response Fields

idinteger
No description provided.
petIdinteger
No description provided.
quantityinteger
No description provided.
shipDatestring
No description provided.
statusstring
Order Status
completeboolean
No description provided.

Delete purchase order by identifier.

For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors.

DELETE/api/v3/store/order/{orderId}No auth required

Delete purchase order by identifier.

Request Example
curl -X DELETE "/api/v3/store/order/{orderId}"
Response

Path Parameters

orderIdintegerpathrequired
ID of the order that needs to be deleted

User

Create user.

This can only be done by the logged in user.

POST/api/v3/userNo auth required

Create user.

Request Body
{ "id": 10, "username": "theUser", "firstName": "John", "lastName": "James", "email": "john@email.com", "password": "12345", "phone": "12345", "userStatus": 1 }
Request Example
curl -X POST "/api/v3/user" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d '{"id":10,"username":"theUser","firstName":"John","lastName":"James","email":"john@email.com","password":"12345","phone":"12345","userStatus":1}'
Response
{ "id": 10, "username": "theUser", "firstName": "John", "lastName": "James", "email": "john@email.com", "password": "12345", "phone": "12345", "userStatus": 1 }

Request Body

idintegerbody
No description provided.
usernamestringbody
No description provided.
firstNamestringbody
No description provided.
lastNamestringbody
No description provided.
emailstringbody
No description provided.
passwordstringbody
No description provided.
phonestringbody
No description provided.
userStatusintegerbody
User Status

Response Fields

idinteger
No description provided.
usernamestring
No description provided.
firstNamestring
No description provided.
lastNamestring
No description provided.
emailstring
No description provided.
passwordstring
No description provided.
phonestring
No description provided.
userStatusinteger
User Status

Creates list of users with given input array.

Creates list of users with given input array.

POST/api/v3/user/createWithListNo auth required

Creates list of users with given input array.

Request Body
[ { "id": 10, "username": "theUser", "firstName": "John", "lastName": "James", "email": "john@email.com", "password": "12345", "phone": "12345", "userStatus": 1 } ]
Request Example
curl -X POST "/api/v3/user/createWithList" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d '[{"id":10,"username":"theUser","firstName":"John","lastName":"James","email":"john@email.com","password":"12345","phone":"12345","userStatus":1}]'
Response
{ "id": 10, "username": "theUser", "firstName": "John", "lastName": "James", "email": "john@email.com", "password": "12345", "phone": "12345", "userStatus": 1 }

Request Body

items.idintegerbody
No description provided.
items.usernamestringbody
No description provided.
items.firstNamestringbody
No description provided.
items.lastNamestringbody
No description provided.
items.emailstringbody
No description provided.
items.passwordstringbody
No description provided.
items.phonestringbody
No description provided.
items.userStatusintegerbody
User Status

Response Fields

idinteger
No description provided.
usernamestring
No description provided.
firstNamestring
No description provided.
lastNamestring
No description provided.
emailstring
No description provided.
passwordstring
No description provided.
phonestring
No description provided.
userStatusinteger
User Status

Logs user into the system.

Log into the system.

GET/api/v3/user/loginNo auth required

Logs user into the system.

Request Example
curl -X GET "/api/v3/user/login?username=%3Cusername%3E&password=%3Cpassword%3E" \ -H "Accept: application/json"
Response
"string"

Query Parameters

usernamestringquery
The user name for login
passwordstringquery
The password for login in clear text

Logs out current logged in user session.

Log user out of the system.

GET/api/v3/user/logoutNo auth required

Logs out current logged in user session.

Request Example
curl -X GET "/api/v3/user/logout"
Response

Get user by user name.

Get user detail based on username.

GET/api/v3/user/{username}No auth required

Get user by user name.

Request Example
curl -X GET "/api/v3/user/{username}" \ -H "Accept: application/json"
Response
{ "id": 10, "username": "theUser", "firstName": "John", "lastName": "James", "email": "john@email.com", "password": "12345", "phone": "12345", "userStatus": 1 }

Path Parameters

usernamestringpathrequired
The name that needs to be fetched. Use user1 for testing

Response Fields

idinteger
No description provided.
usernamestring
No description provided.
firstNamestring
No description provided.
lastNamestring
No description provided.
emailstring
No description provided.
passwordstring
No description provided.
phonestring
No description provided.
userStatusinteger
User Status

Update user resource.

This can only be done by the logged in user.

PUT/api/v3/user/{username}No auth required

Update user resource.

Request Body
{ "id": 10, "username": "theUser", "firstName": "John", "lastName": "James", "email": "john@email.com", "password": "12345", "phone": "12345", "userStatus": 1 }
Request Example
curl -X PUT "/api/v3/user/{username}" \ -H "Content-Type: application/json" \ -d '{"id":10,"username":"theUser","firstName":"John","lastName":"James","email":"john@email.com","password":"12345","phone":"12345","userStatus":1}'
Response

Path Parameters

usernamestringpathrequired
name that need to be deleted

Request Body

idintegerbody
No description provided.
usernamestringbody
No description provided.
firstNamestringbody
No description provided.
lastNamestringbody
No description provided.
emailstringbody
No description provided.
passwordstringbody
No description provided.
phonestringbody
No description provided.
userStatusintegerbody
User Status

Delete user resource.

This can only be done by the logged in user.

DELETE/api/v3/user/{username}No auth required

Delete user resource.

Request Example
curl -X DELETE "/api/v3/user/{username}"
Response

Path Parameters

usernamestringpathrequired
The name that needs to be deleted
app/getting-started/openapi-embed.mdx
MDX
<OpenApiEmbed url="https://petstore3.swagger.io/api/v3/openapi.json" />

Adding Options

Two props shape what readers get. revalidate sets the cache window in seconds, and showOverview={false} drops the title, version, servers, Postman button, and summary line so only the operation list remains. Combine them when the surrounding page already introduces the API and the spec changes often.

app/getting-started/openapi-embed.mdx
MDX
<OpenApiEmbed
  url="https://api.example.com/openapi.yaml"
  revalidate={300}
  showOverview={false}
/>

Advanced

JSON and YAML both work. The component reads the response content type and falls back to the URL file extension when the server sends none, so a plain .yaml file served as text/plain still parses. Pass revalidate={0} while a spec is still moving and every page render refetches it.

app/getting-started/openapi-embed.mdx
MDX
<OpenApiEmbed
  url="https://example.com/specs/internal-api.yaml"
  revalidate={0}
/>

Grouping And Methods

  • Operations group by their first tag. Without tags, they group by the first path segment, and a leading version segment such as /v1 falls through to the next one.
  • GET, POST, PUT, PATCH, and DELETE render. HEAD, OPTIONS, and TRACE are skipped.
  • Sample requests carry a placeholder auth header built from the spec's security scheme, such as Authorization: Bearer <token> or X-API-Key: <api-key>. The component stores no credentials and forwards nothing from the reader's browser.
  • Source examples render as published. The upstream document decides what readers see.

Failure Handling

The embed fails closed. When a source can't be loaded, an inline banner names the URL and the cause, and the rest of the page still renders. These are the cases it catches:

  • A URL that won't parse, or a protocol other than http and https
  • A host that stays silent past the 15-second timeout, or answers non-2xx
  • More than five redirect hops
  • A body that isn't valid JSON or YAML
  • A document that isn't OpenAPI 3.0, 3.1, 3.2, or Swagger 2.0
  • A document larger than 10 MB

Postman Export

The overview block renders a "Postman collection" download button. OwnDocs converts the source spec to a Postman v2.1 collection on the server during render and memoizes the result per resolved spec URL, so a repeat visit skips the converter. The click streams the JSON as a Blob URL. That file imports into Postman or feeds Newman for command-line testing. You'll find the button at the top of the Petstore embed above.

Options

urlstringrequired

HTTP(S) URL of a JSON or YAML document written against OpenAPI 3.0, 3.1, 3.2, or Swagger 2.0. The protocol is re-checked on every redirect hop.

revalidatenumberDefault: 3600

Seconds the fetched spec stays in the Next.js fetch cache. Set it to 0 to refetch on every render.

showOverviewbooleanDefault: true

Renders the API title, version, description, server list, Postman download button, and the compatibility summary above the operations.

Was this page helpful?