xyd 0.1.0-beta - Coming Soon

/
API Pages
/
OpenAPI

OpenAPI

Reference OpenAPI endpoints in your docs pages

To describe your endpoints with OpenAPI, make sure you have a valid OpenAPI document in either JSON or YAML format that follows the OpenAPI specification.

Your document must follow OpenAPI specification 3.0+.

Configuration Quickstart

The fastest way to get started with OpenAPI is to add an openapi field to api in the settings file. This field can contain either the relative path to an OpenAPI document in your docs or the URL of a hosted OpenAPI document.

This will create a new route based on your OpenAPI specification at docs/api/rest/*.

You can also use URL-based paths to OpenAPI spec instead of local files.

Multi Spec Configuration

Creating multi API specs for more advanced use cases is also possible:

Thanks to this configuration, you'll have two routes: docs/api/rest/* and docs/api/webhooks/*.

API Reference Only

You don't need a docs site to publish an API reference. Point xyd at the document itself and it renders the reference alone — one page per operation and one per schema, no docs content:

The document can be .yaml, .yml or .json (and .graphql for a GraphQL schema). xyd dev ./openapi.yaml serves the same site locally, and the build is a static site at .xyd/build/client, exactly like a regular xyd build.

A docs.json next to the document is optional. When present it is merged over the defaults (the gusto theme, search off), so it is the place for a theme, or for advanced.basename to mount the reference under a prefix.

The Landing Page

index.md (or index.mdx) in the project is the landing page. Without one, xyd synthesizes a page from the document's info.title and info.description — the project directory stays untouched.

Hosting Under A Prefix

To serve the reference at a path such as /docs instead of the site root, set advanced.basename:

Every link, raw file (llms.txt, the .md twins) and asset URL then carries the prefix, and the build writes the whole site under .xyd/build/client/docs/:

That directory is self-contained: mount it at the prefix with any static file server that resolves clean URLs (/docs/getBookByTitle → getBookByTitle.html, /docs/ → index.html), or copy it into a larger site at that path. The Vite base follows the basename automatically; set advanced.vite.base yourself to serve the assets from somewhere else — then they stay at the client root for your own pipeline.

A complete project is in the atlas-only example.

API Docs Generation Guides

  • The generator automatically creates documentation based on your OpenAPI specification
  • Uses OpenAPI tags to create logical groups of endpoints
  • Generates clean URLs from operationId when available
  • Organizes endpoints by path when no tags are specified
  • Groups related schemas with their endpoints
  • Links response schemas to their corresponding endpoints

All defaults can be overridden using the x-docs extension

X-Docs Extension

The x-docs extension provides additional configuration options to customize your API documentation beyond the standard OpenAPI specification. Use it to control sidebar structure, code snippets, and endpoint visibility.

To make your OpenAPI documentation more organized and user-friendly, you can customize the navigation structure using the x-docs extension. This allows you to group endpoints and schemas into logical sections and control their URLs.

Since xyd creates a sidebar by default based on tags and other OpenAPI Spec, x-docs gives you more control.

You can define a complete navigation structure using the sidebar property in the x-docs extension:

above example will create sidebar:

Learn More
Navigation Customization Details

Route

The route property defines the base URL path for your API documentation. This is where all your API documentation pages will be served from.

If you define route in docs.json it will overwrite the route in OpenAPI spec.

Type

The type property in the sidebar configuration specifies what kind of content will be displayed. There are two main types:

  • endpoint: Used for API endpoints. The key can be either:

    • A path and method combination (e.g., GET /users)
    • An operationId from your OpenAPI spec
  • object: Used for schema definitions. The key should match the schema name in your OpenAPI spec

Example:

Path

Adding a path for each of pages helps to create a clean and organized URLs in your API documentation. The path property determines the URL segment for each page in your documentation.

For example:

this configuration will generate URLs like:

  • /docs/api/rest/users/get
  • /docs/api/rest/users/get-by-id

The final URL is constructed by combining the base route with the path segments from each level of the sidebar configuration.

Request Code Snippets

You can also specify supported programming languages for request code snippets using x-docs.codeLanguages:

this method generates code snippets based on specific request for defined languges.

Code Samples

If you have a code snippet already and dont wan't a generic, autogenerated one you can use x-codeSamples:

WebhooksComing Soon

Support for OpenAPI webhook documentation is currently in development and will be available in the future.

API Docs Demo

You can also check out our interactive API Docs Demo to see these features in action and experiment with different OpenAPI configurations in real-time.

OpenAPI Samples

Learn how to setup OpenAPI pages.

Built with

Show your support! Star us on GitHub ⭐️