Skip to main content
OwnDocs

OpenAPI Embed

4 min read

This page shows the OpenApiEmbed component, an MDX tag that renders a full API reference inline from a remote OpenAPI or Swagger URL. At render time, OwnDocs fetches the spec, checks it against OpenAPI 3.0/3.1/3.2 or Swagger 2.0, redacts credential-like values, and renders each operation with the standard ApiBlock, ParamField, and ResponseField components. There's no CLI, no generated files, and no manual conversion step. Use the page as a working reference for the official Swagger Petstore, or as a template for your own API docs.

Live Example: Swagger Petstore

The official Swagger Petstore is the OpenAPI 3.0 reference document kept by the OpenAPI Initiative. The embed below fetches the live JSON spec on the server, parses it, groups operations by tag, and renders each endpoint with the same components used elsewhere on this site.

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.

Headers
AuthorizationBearer <oauth-token>
Acceptapplication/json
Content-Typeapplication/json
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"}'
Response200
{ "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.

Headers
AuthorizationBearer <oauth-token>
Acceptapplication/json
Content-Typeapplication/json
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"}'
Response200
{ "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.

Headers
AuthorizationBearer <oauth-token>
Acceptapplication/json
Request Example
curl -X GET "/api/v3/pet/findByStatus" \ -H "Authorization: Bearer <oauth-token>" \ -H "Accept: application/json"
Response200
[ { "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.

Headers
AuthorizationBearer <oauth-token>
Acceptapplication/json
Request Example
curl -X GET "/api/v3/pet/findByTags" \ -H "Authorization: Bearer <oauth-token>" \ -H "Accept: application/json"
Response200
[ { "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.

Headers
X-API-Key<api-key>
Acceptapplication/json
Request Example
curl -X GET "/api/v3/pet/{petId}" \ -H "X-API-Key: <api-key>" \ -H "Accept: application/json"
Response200
{ "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.

Headers
AuthorizationBearer <oauth-token>
Acceptapplication/json
Request Example
curl -X POST "/api/v3/pet/{petId}" \ -H "Authorization: Bearer <oauth-token>" \ -H "Accept: application/json"
Response200
{ "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.

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

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.

Headers
AuthorizationBearer <oauth-token>
Acceptapplication/json
Content-Typeapplication/octet-stream
Request Body
"string"
Request Example
curl -X POST "/api/v3/pet/{petId}/uploadImage" \ -H "Authorization: Bearer <oauth-token>" \ -H "Accept: application/json" \ -H "Content-Type: application/octet-stream" \ -d '"string"'
Response200
{ "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.

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

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.

Headers
Acceptapplication/json
Content-Typeapplication/json
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}'
Response200
{ "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.

Headers
Acceptapplication/json
Request Example
curl -X GET "/api/v3/store/order/{orderId}" \ -H "Accept: application/json"
Response200
{ "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}"

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.

Headers
Acceptapplication/json
Content-Typeapplication/json
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}'
Response200
{ "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.

Headers
Acceptapplication/json
Content-Typeapplication/json
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}]'
Response200
{ "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.

Headers
Acceptapplication/json
Request Example
curl -X GET "/api/v3/user/login" \ -H "Accept: application/json"
Response200
"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"

Get user by user name.

Get user detail based on username.

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

Get user by user name.

Headers
Acceptapplication/json
Request Example
curl -X GET "/api/v3/user/{username}" \ -H "Accept: application/json"
Response200
{ "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.

Headers
Content-Typeapplication/json
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}'

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}"

Path Parameters

usernamestringpathrequired
The name that needs to be deleted

Usage

To embed a publicly reachable JSON or YAML OpenAPI document, add one tag to your MDX page. The component fetches, validates, and renders it.

MDX
MDX
<OpenApiEmbed url="https://petstore3.swagger.io/api/v3/openapi.json" />

Custom Cache Window

By default, the fetched specification is cached for one hour through the Next.js fetch cache. Override that window by passing revalidate in seconds. Set to 0 to refetch on every request.

MDX
MDX
<OpenApiEmbed url="https://api.example.com/openapi.yaml" revalidate={300} />

Hiding the Overview

The component renders an overview block above the operation list with the API title, version, description, server URLs, and source summary. Hide it for a smaller embed when the page around it already gives context.

MDX
MDX
<OpenApiEmbed url="https://api.example.com/openapi.yaml" showOverview={false} />

Embedding a YAML Source

JSON and YAML both work. The component negotiates content types and falls back to the URL file extension when the server omits one.

MDX
MDX
<OpenApiEmbed url="https://example.com/specs/internal-api.yaml" />

Postman Collection Export

Every embed renders a "Postman collection" download button inside the overview block. OwnDocs converts the source spec to a Postman v2.1 collection on the server during rendering, then streams it as a Blob URL when the reader clicks the button. The conversion is memoized per resolved spec URL, so repeat visits don't re-run the converter. The button sits at the top of the Swagger Petstore embed above. The JSON file it produces imports into Postman or feeds Newman for command-line testing.

Supported Props

The OpenApiEmbed component accepts the following props:

  • urlstring (required)
    • HTTP(S) URL to a JSON or YAML OpenAPI 3.0/3.1/3.2 or Swagger 2.0 document
  • revalidatenumber
    • Seconds to cache the fetched spec through the Next.js fetch cache; defaults to 3600. Set to 0 to refetch every render.
  • showOverviewboolean
    • Shows the API title, version, description, servers, and source summary above the operation list; defaults to true.

Behavior

The embed runs on the server during page render, so the HTML is pre-rendered, indexed by OwnDocs search, and visible to search engines without extra configuration.

  • Operations are grouped by tag. When a source has no tags, operations are grouped by the first non-version segment of each path.
  • The component renders the HTTP methods ApiBlock supports (GET, POST, PUT, PATCH, DELETE) and skips the rest.
  • Source examples render exactly as published. The component doesn't modify or filter spec content. The upstream OpenAPI document decides what readers see.
  • The component uses the same component map as the catch-all route, so ApiBlock interactivity, copy buttons, and theme variants apply.

Failures

The embed fails closed and never crashes the page around it. When something goes wrong, an inline error banner replaces the API reference and names the cause. The rest of the page still renders.

Common failure scenarios include:

  • Invalid URL syntax or non-http(s) protocols
  • Unreachable hosts or non-2xx HTTP responses
  • Redirect chains that exceed the safety limit
  • Source documents that are not valid JSON or YAML
  • Source documents that are not OpenAPI 3.0/3.1/3.2 or Swagger 2.0
  • Source documents larger than 10 MB

Security

The fetcher enforces a small set of guardrails before parsing any source content:

  • Only http:// and https:// URLs are accepted; the protocol is re-checked on every redirect hop.
  • A request timeout and a redirect limit stop slow or looping sources from blocking page rendering.
  • Source documents larger than 10 MB are rejected.
  • Source documents that fail JSON or YAML parsing are rejected before rendering.
  • The component stores no credentials and doesn't forward request headers from the visitor's browser.

See also

Was this page helpful?