# Soft Chen API Reference

[![Version](https://img.shields.io/npm/v/%40soft-chen%2Fapi-reference)](https://www.npmjs.com/package/@soft-chen/api-reference)
[![Downloads](https://img.shields.io/npm/dm/%40soft-chen%2Fapi-reference)](https://www.npmjs.com/package/@soft-chen/api-reference)
[![Hits on jsdelivr](https://img.shields.io/jsdelivr/npm/hm/%40soft-chen%2Fapi-reference)](https://www.jsdelivr.com/package/npm/@soft-chen/api-reference)
[![License](https://img.shields.io/npm/l/%40soft-chen%2Fapi-reference)](https://www.npmjs.com/package/@soft-chen/api-reference)

Interactive API Reference from OpenAPI/Swagger documents.

## CDN

```html
<!doctype html>
<html lang="zh-CN">
  <head>
    <title>Soft Chen API Reference</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
  </head>
  <body>
    <div id="app"></div>

    <script src="https://cdn.jsdelivr.net/npm/@soft-chen/api-reference"></script>
    <script>
      SoftChen.createApiReference('#app', {
        configuration: {
          url: 'https://petstore3.swagger.io/api/v3/openapi.json',
          poweredByScalar: false,
          agent: {
            disabled: true,
          },
        },
        i18n: {
          locale: 'zh-CN',
        },
      })
    </script>
  </body>
</html>
```

`window.Scalar.createApiReference` is still available as a compatibility alias.

## Common configuration

Chinese configuration reference:

- [docs/zh-CN/configuration.md](docs/zh-CN/configuration.md)

Hide the sidebar branding link:

```js
SoftChen.createApiReference('#app', {
  url: '/openapi.json',
  poweredByScalar: false,
})
```

Replace the sidebar branding link:

```js
SoftChen.createApiReference('#app', {
  url: '/openapi.json',
  poweredByScalar: {
    label: 'Powered by Soft Chen',
    url: 'https://gitee.com/soft-chen',
  },
})
```

Set the default language to Chinese. The component also syncs
`document.documentElement.lang` and renders a language toggle next to the dark
mode toggle:

```js
SoftChen.createApiReference('#app', {
  configuration: {
    url: '/openapi.json',
  },
  i18n: {
    locale: 'zh-CN',
  },
})
```

Hide Ask AI:

```js
SoftChen.createApiReference('#app', {
  url: '/openapi.json',
  agent: {
    disabled: true,
  },
})
```

Hide MCP:

```js
SoftChen.createApiReference('#app', {
  url: '/openapi.json',
  mcp: {
    disabled: true,
  },
})
```

## Local development

- ESM playground: `pnpm playground:esm`
- Vue + Vite playground: `pnpm playground:vue`

## License

MIT
