Redocly API Block - Default
Display interactive API documentation from OpenAPI specification files.
Syntax
<RedoclyAPIBlock src="path/to/openapi.yaml" />
Parameters
-
src: Path to OpenAPI specification file (YAML or JSON). Placement depends on file type:
- YAML files: Can be under
/src/pages(use a relative path from the current page) or in thestatic/folder (see below). Example: fromsrc/pages/api/reference/index.md, a spec atsrc/pages/assets/openapi.yaml→src="../../assets/openapi.yaml" - JSON files: Must be in the
static/folder only — JSON files under/src/pageswill fail deployment. static/folder (at repo root, not under/src/pages): Usesrc="/{pathPrefix}/{pathToFileRelativeToStaticFolder}"— the path includes pathPrefix but excludes thestaticsegment.
- YAML files: Can be under
Default Settings
- Width: 500px
- Sidebar navigation enabled
- Search enabled
- Try-it-out panel enabled
- JSON samples expanded to 2 levels
Examples
Relative path (YAML under /src/pages): From a page at api/reference/index.md, referencing assets/openapi.yaml:
<RedoclyAPIBlock src="../../assets/openapi.yaml" />
Static folder (pathPrefix format): For static/petstore.json with pathPrefix my-product:
<RedoclyAPIBlock src="/my-product/petstore.json" />
data-src=../../assets/openapi.yaml