scalar
БесплатноБез исполняемых скриптовНе проверенScalar renders an OpenAPI document as interactive API documentation with a built-in request client, and ships a CLI to validate, lint, bundle, mock and…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Scalar — Interactive API reference and OpenAPI CLI
Overview
Scalar turns an OpenAPI (or AsyncAPI) description into a browsable reference page where readers can also send requests. The page can be mounted as a route in a Node web framework, loaded from a CDN in a plain HTML file, or previewed locally with the Scalar CLI. The same CLI validates, lints, bundles and mocks the spec, so one tool covers writing, checking and showing the contract.
Verified against @scalar/express-api-reference 0.10.33, @scalar/fastify-api-reference 1.76.2, @scalar/hono-api-reference 0.12.16 and @scalar/cli 2.13.2.
Instructions
Preview a spec with the CLI (fastest path)
npm install --save-dev @scalar/cli
npx scalar document validate openapi.yaml --no-input
npx scalar document serve openapi.yaml --port 5050 --no-input
serve starts a local server and prints the address; add --watch to reload when the file changes, and --config reference.json to pass reference options (theme, layout) as a JSON file. Always pass --no-input in scripts so the CLI never prompts or opens a browser.
Other scalar document subcommands that work offline on local files:
| Command | Purpose |
|---|---|
validate [file|url] |
Check the spec is a valid OpenAPI/AsyncAPI description |
lint [file|url] |
Run Spectral rules; exits with errors and warnings listed |
bundle [file|url] -o out.yaml |
Inline external $refs into one file (--treeShake drops unused components) |
join <files...> |
Merge several descriptions of the same format |
format, split, markdown, convert |
Reformat, split into referenced files, generate Markdown, convert a Postman collection |
mock [file|url] --port 4010 |
Run a mock server from the spec (--watch supported) |
auth, registry, project, team, share and sdk talk to the Scalar cloud service and need an account; skip them unless the user has one and asks.
Mount the reference in Express
npm install express @scalar/express-api-reference
import express from 'express'
import { apiReference } from '@scalar/express-api-reference'
const app = express()
app.get('/openapi.json', (_req, res) => res.sendFile('openapi.json', { root: process.cwd() }))
app.use('/reference', apiReference({ url: '/openapi.json', theme: 'default' }))
app.listen(4000, '127.0.0.1', () => console.log('Docs at http://127.0.0.1:4000/reference'))
The handler answers with a small HTML page that loads the reference script from the jsDelivr CDN, so the browser (not the server) needs internet access. In a test run, GET /reference returned 200 with that page, and the configuration object was embedded as JSON.
Mount the reference in Fastify
npm install fastify @scalar/fastify-api-reference
import Fastify from 'fastify'
import fastifyApiReference from '@scalar/fastify-api-reference'
import { readFileSync } from 'node:fs'
const app = Fastify()
const spec = JSON.parse(readFileSync('./openapi.json', 'utf8'))
await app.register(fastifyApiReference, {
routePrefix: '/reference',
configuration: { content: spec },
})
await app.listen({ port: 4000, host: '127.0.0.1' })
The plugin also serves the spec itself at /reference/openapi.json (and /reference/openapi.yaml). Requesting /reference redirects (301) to the trailing-slash route, which is normal.
Mount the reference in Hono
npm install hono @hono/node-server @scalar/hono-api-reference
import { Hono } from 'hono'
import { serve } from '@hono/node-server'
import { Scalar } from '@scalar/hono-api-reference'
const app = new Hono()
app.get('/openapi.json', (c) => c.json(buildSpec()))
app.get('/reference', Scalar({ url: '/openapi.json' }))
serve({ fetch: app.fetch, port: 4000, hostname: '127.0.0.1' })
Here buildSpec() stands for whatever returns your spec object (for example app.getOpenAPI31Document(...) with @hono/zod-openapi). Scalar.serve({ document }) is an alternative that also exposes the document at /openapi.json under its mount point.
Plain HTML page (no server framework)
The generated page in the Express test used this exact shape, which works as a static file:
<!doctype html>
<html>
<head>
<title>Bookshop API reference</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<div id="app"></div>
<script type="module">
import { createApiReference } from 'https://cdn.jsdelivr.net/npm/@scalar/api-reference/esm.js'
createApiReference('#app', { url: './openapi.yaml' })
</script>
</body>
</html>
Serve the folder over HTTP (for example npx http-server -a 127.0.0.1 -p 5051); opening the file with file:// blocks the spec fetch.
Common configuration keys
Pass these in the same object as url/content: theme, layout (modern or classic), darkMode, forceDarkModeState, `hideDarkModeTogg
Установить scalar в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл scalar?
Scalar renders an OpenAPI document as interactive API documentation with a built-in request client, and ships a CLI to validate, lint, bundle, mock and preview specs. Use when asked to "add API docs to my Express/Fastify/Hono app", "replace Swagger UI", "preview my openapi.yaml", "lint an OpenAPI file", "mock an API from a spec", or "serve a reference page from a spec".
Как установить скилл scalar?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл scalar запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic