@kubb/plugin-redoc 5.0.5 → 5.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
  [![Node][node-src]][node-href]
11
11
 
12
12
  <h4>
13
- <a href="https://kubb.dev/plugins/plugin-redoc" target="_blank">Documentation</a>
13
+ <a href="https://kubb.dev/extensions/kubb-labs/plugin-redoc" target="_blank">Documentation</a>
14
14
  <span> · </span>
15
15
  <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
16
16
  <span> · </span>
@@ -38,7 +38,7 @@ npm install @kubb/plugin-redoc
38
38
 
39
39
  ## Documentation
40
40
 
41
- See the [full documentation](https://kubb.dev/plugins/plugin-redoc) for configuration options and examples.
41
+ See the [full documentation](https://kubb.dev/extensions/kubb-labs/plugin-redoc) for configuration options and examples.
42
42
 
43
43
  ## Supporting Kubb
44
44
 
package/dist/index.cjs CHANGED
@@ -28,8 +28,14 @@ let node_path = require("node:path");
28
28
  node_path = __toESM(node_path, 1);
29
29
  let _kubb_adapter_oas = require("@kubb/adapter-oas");
30
30
  let kubb_kit = require("kubb/kit");
31
+ //#region kubb-extension.json
32
+ var compatibility = {
33
+ "kubb": ">=5.8.3",
34
+ "node": ">=22"
35
+ };
36
+ //#endregion
31
37
  //#region package.json
32
- var version = "5.0.5";
38
+ var version = "5.0.7";
33
39
  //#endregion
34
40
  //#region src/redoc.tsx
35
41
  const htmlEscapes = {
@@ -107,11 +113,12 @@ const pluginRedocName = "plugin-redoc";
107
113
  * })
108
114
  * ```
109
115
  */
110
- const pluginRedoc = (0, kubb_kit.definePlugin)({
116
+ const pluginRedoc = (0, kubb_kit.defineExtension)({
117
+ kind: "plugin",
111
118
  meta: {
112
119
  name: pluginRedocName,
113
120
  version,
114
- compatibility: { kubb: ">=5.8.0" }
121
+ compatibility
115
122
  },
116
123
  async setup(options) {
117
124
  const config = (0, kubb_kit.useConfig)();
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["definePlugin","useConfig","path","adapterOasName","ast"],"sources":["../package.json","../src/redoc.tsx","../src/plugin.ts"],"sourcesContent":["","import type { AdapterOas } from '@kubb/adapter-oas'\n\nconst htmlEscapes: Record<string, string> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n \"'\": '&#x27;',\n '`': '&#x60;',\n '=': '&#x3D;',\n}\n\nfunction escapeHtml(value: string) {\n return value.replace(/[&<>\"'`=]/g, (char) => htmlEscapes[char] ?? char)\n}\n\n/**\n * Renders a self-contained Redoc HTML page for an OpenAPI document. The page\n * embeds the spec inline and pulls Redoc's bundle from a CDN at runtime, so\n * the generated file works without further build steps.\n */\nexport async function getPageHTML(api: AdapterOas['document']) {\n const pageTitle = escapeHtml(api.info.title || 'ReDoc documentation')\n const googleFont = `<link href='https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700' rel='stylesheet' />`\n const redocHTML = `\n <script src=\"https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js\"> </script>\n <div id=\"redoc-container\"></div>\n <script>\n const data = ${JSON.stringify(api, null, 2)};\n Redoc.init(data, {\n \"expandResponses\": \"200,400\"\n }, document.getElementById('redoc-container'))\n </script>\n `\n\n return `<html>\n\n <head>\n <meta charset='utf8' />\n <title>${pageTitle}</title>\n <!-- needed for adaptive design -->\n <meta name='viewport' content='width=device-width, initial-scale=1' />\n <style>\n body {\n padding: 0;\n margin: 0;\n }\n </style>\n ${googleFont}\n </head>\n\n <body>\n ${redocHTML}\n </body>\n\n</html>`\n}\n","import path from 'node:path'\nimport type { AdapterOas } from '@kubb/adapter-oas'\nimport { adapterOasName } from '@kubb/adapter-oas'\n\nimport { type Adapter, ast, definePlugin, injectFile, useConfig } from 'kubb/kit'\nimport { version } from '../package.json'\nimport { getPageHTML } from './redoc.tsx'\nimport type { PluginRedoc } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-redoc`. Used for driver lookups and\n * cross-plugin dependency references.\n */\nexport const pluginRedocName = 'plugin-redoc' satisfies PluginRedoc['name']\n\n/**\n * Generates a self-contained static HTML documentation page from your OpenAPI\n * spec using Redoc. The file is regenerated on every Kubb build, so the docs\n * stay in lockstep with the spec the rest of your code is generated from.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb/config'\n * import { pluginRedoc } from '@kubb/plugin-redoc'\n *\n * export default defineConfig({\n * input: './petStore.yaml',\n * output: { path: './src/gen' },\n * plugins: [\n * pluginRedoc({ output: { path: 'docs.html' } }),\n * ],\n * })\n * ```\n */\nexport const pluginRedoc = definePlugin<PluginRedoc>({\n meta: { name: pluginRedocName, version, compatibility: { kubb: '>=5.8.0' } },\n async setup(options) {\n const config = useConfig()\n const { output = { path: 'docs.html' } } = options\n const extname = path.extname(output.path)\n const name = extname ? output.path.slice(0, -extname.length) : output.path\n\n const adapter = config.adapter\n\n if (adapter?.name !== adapterOasName) {\n throw new Error(\n `[${pluginRedocName}] plugin-redoc requires the OpenAPI adapter. Make sure you are using adapterOas (e.g. \\`adapter: adapterOas()\\`) in your Kubb config.`,\n )\n }\n\n const document = (adapter as Adapter<AdapterOas>).document\n\n if (!document) {\n throw new Error(\n `[${pluginRedocName}] No OpenAPI document found. The adapterOas did not produce a document — ensure the adapter has run before this plugin.`,\n )\n }\n\n const root = path.resolve(config.root, config.output.path)\n const pageHTML = await getPageHTML(document)\n\n injectFile({\n baseName: 'docs.html',\n path: path.resolve(root, output.path || './docs.html'),\n sources: [\n ast.factory.createSource({\n name: 'docs.html',\n nodes: [ast.factory.createText(pageHTML)],\n }),\n ],\n })\n\n return { output, name, exclude: [], override: [] }\n },\n})\n\nexport default pluginRedoc\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACEA,MAAM,cAAsC;CAC1C,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;AACP;AAEA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;EAED,OAAO;GAAE;GAAQ;GAAM,SAAS,CAAC;GAAG,UAAU,CAAC;EAAE;CACnD;AACF,CAAC"}
1
+ {"version":3,"file":"index.cjs","names":["defineExtension","useConfig","path","adapterOasName","ast"],"sources":["../kubb-extension.json","../package.json","../src/redoc.tsx","../src/plugin.ts"],"sourcesContent":["","","import type { AdapterOas } from '@kubb/adapter-oas'\n\nconst htmlEscapes: Record<string, string> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n \"'\": '&#x27;',\n '`': '&#x60;',\n '=': '&#x3D;',\n}\n\nfunction escapeHtml(value: string) {\n return value.replace(/[&<>\"'`=]/g, (char) => htmlEscapes[char] ?? char)\n}\n\n/**\n * Renders a self-contained Redoc HTML page for an OpenAPI document. The page\n * embeds the spec inline and pulls Redoc's bundle from a CDN at runtime, so\n * the generated file works without further build steps.\n */\nexport async function getPageHTML(api: AdapterOas['document']) {\n const pageTitle = escapeHtml(api.info.title || 'ReDoc documentation')\n const googleFont = `<link href='https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700' rel='stylesheet' />`\n const redocHTML = `\n <script src=\"https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js\"> </script>\n <div id=\"redoc-container\"></div>\n <script>\n const data = ${JSON.stringify(api, null, 2)};\n Redoc.init(data, {\n \"expandResponses\": \"200,400\"\n }, document.getElementById('redoc-container'))\n </script>\n `\n\n return `<html>\n\n <head>\n <meta charset='utf8' />\n <title>${pageTitle}</title>\n <!-- needed for adaptive design -->\n <meta name='viewport' content='width=device-width, initial-scale=1' />\n <style>\n body {\n padding: 0;\n margin: 0;\n }\n </style>\n ${googleFont}\n </head>\n\n <body>\n ${redocHTML}\n </body>\n\n</html>`\n}\n","import path from 'node:path'\nimport type { AdapterOas } from '@kubb/adapter-oas'\nimport { adapterOasName } from '@kubb/adapter-oas'\n\nimport { type Adapter, ast, defineExtension, injectFile, useConfig } from 'kubb/kit'\nimport { compatibility } from '../kubb-extension.json'\nimport { version } from '../package.json'\nimport { getPageHTML } from './redoc.tsx'\nimport type { PluginRedoc } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-redoc`. Used for driver lookups and\n * cross-plugin dependency references.\n */\nexport const pluginRedocName = 'plugin-redoc' satisfies PluginRedoc['name']\n\n/**\n * Generates a self-contained static HTML documentation page from your OpenAPI\n * spec using Redoc. The file is regenerated on every Kubb build, so the docs\n * stay in lockstep with the spec the rest of your code is generated from.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb/config'\n * import { pluginRedoc } from '@kubb/plugin-redoc'\n *\n * export default defineConfig({\n * input: './petStore.yaml',\n * output: { path: './src/gen' },\n * plugins: [\n * pluginRedoc({ output: { path: 'docs.html' } }),\n * ],\n * })\n * ```\n */\nexport const pluginRedoc = defineExtension<PluginRedoc>({\n kind: 'plugin',\n meta: { name: pluginRedocName, version, compatibility },\n async setup(options) {\n const config = useConfig()\n const { output = { path: 'docs.html' } } = options\n const extname = path.extname(output.path)\n const name = extname ? output.path.slice(0, -extname.length) : output.path\n\n const adapter = config.adapter\n\n if (adapter?.name !== adapterOasName) {\n throw new Error(\n `[${pluginRedocName}] plugin-redoc requires the OpenAPI adapter. Make sure you are using adapterOas (e.g. \\`adapter: adapterOas()\\`) in your Kubb config.`,\n )\n }\n\n const document = (adapter as Adapter<AdapterOas>).document\n\n if (!document) {\n throw new Error(\n `[${pluginRedocName}] No OpenAPI document found. The adapterOas did not produce a document — ensure the adapter has run before this plugin.`,\n )\n }\n\n const root = path.resolve(config.root, config.output.path)\n const pageHTML = await getPageHTML(document)\n\n injectFile({\n baseName: 'docs.html',\n path: path.resolve(root, output.path || './docs.html'),\n sources: [\n ast.factory.createSource({\n name: 'docs.html',\n nodes: [ast.factory.createText(pageHTML)],\n }),\n ],\n })\n\n return { output, name, exclude: [], override: [] }\n },\n})\n\nexport default pluginRedoc\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;IACvB,MAAM;IACN,OAAO,CAACA,SAAAA,IAAI,QAAQ,WAAW,QAAQ,CAAC;GAC1C,CAAC,CACH;EACF,CAAC;EAED,OAAO;GAAE;GAAQ;GAAM,SAAS,CAAC;GAAG,UAAU,CAAC;EAAE;CACnD;AACF,CAAC"}
package/dist/index.js CHANGED
@@ -1,9 +1,15 @@
1
1
  import "./rolldown-runtime-C0LytTxp.js";
2
2
  import path from "node:path";
3
3
  import { adapterOasName } from "@kubb/adapter-oas";
4
- import { ast, definePlugin, injectFile, useConfig } from "kubb/kit";
4
+ import { ast, defineExtension, injectFile, useConfig } from "kubb/kit";
5
+ //#region kubb-extension.json
6
+ var compatibility = {
7
+ "kubb": ">=5.8.3",
8
+ "node": ">=22"
9
+ };
10
+ //#endregion
5
11
  //#region package.json
6
- var version = "5.0.5";
12
+ var version = "5.0.7";
7
13
  //#endregion
8
14
  //#region src/redoc.tsx
9
15
  const htmlEscapes = {
@@ -81,11 +87,12 @@ const pluginRedocName = "plugin-redoc";
81
87
  * })
82
88
  * ```
83
89
  */
84
- const pluginRedoc = definePlugin({
90
+ const pluginRedoc = defineExtension({
91
+ kind: "plugin",
85
92
  meta: {
86
93
  name: pluginRedocName,
87
94
  version,
88
- compatibility: { kubb: ">=5.8.0" }
95
+ compatibility
89
96
  },
90
97
  async setup(options) {
91
98
  const config = useConfig();
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../package.json","../src/redoc.tsx","../src/plugin.ts"],"sourcesContent":["","import type { AdapterOas } from '@kubb/adapter-oas'\n\nconst htmlEscapes: Record<string, string> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n \"'\": '&#x27;',\n '`': '&#x60;',\n '=': '&#x3D;',\n}\n\nfunction escapeHtml(value: string) {\n return value.replace(/[&<>\"'`=]/g, (char) => htmlEscapes[char] ?? char)\n}\n\n/**\n * Renders a self-contained Redoc HTML page for an OpenAPI document. The page\n * embeds the spec inline and pulls Redoc's bundle from a CDN at runtime, so\n * the generated file works without further build steps.\n */\nexport async function getPageHTML(api: AdapterOas['document']) {\n const pageTitle = escapeHtml(api.info.title || 'ReDoc documentation')\n const googleFont = `<link href='https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700' rel='stylesheet' />`\n const redocHTML = `\n <script src=\"https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js\"> </script>\n <div id=\"redoc-container\"></div>\n <script>\n const data = ${JSON.stringify(api, null, 2)};\n Redoc.init(data, {\n \"expandResponses\": \"200,400\"\n }, document.getElementById('redoc-container'))\n </script>\n `\n\n return `<html>\n\n <head>\n <meta charset='utf8' />\n <title>${pageTitle}</title>\n <!-- needed for adaptive design -->\n <meta name='viewport' content='width=device-width, initial-scale=1' />\n <style>\n body {\n padding: 0;\n margin: 0;\n }\n </style>\n ${googleFont}\n </head>\n\n <body>\n ${redocHTML}\n </body>\n\n</html>`\n}\n","import path from 'node:path'\nimport type { AdapterOas } from '@kubb/adapter-oas'\nimport { adapterOasName } from '@kubb/adapter-oas'\n\nimport { type Adapter, ast, definePlugin, injectFile, useConfig } from 'kubb/kit'\nimport { version } from '../package.json'\nimport { getPageHTML } from './redoc.tsx'\nimport type { PluginRedoc } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-redoc`. Used for driver lookups and\n * cross-plugin dependency references.\n */\nexport const pluginRedocName = 'plugin-redoc' satisfies PluginRedoc['name']\n\n/**\n * Generates a self-contained static HTML documentation page from your OpenAPI\n * spec using Redoc. The file is regenerated on every Kubb build, so the docs\n * stay in lockstep with the spec the rest of your code is generated from.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb/config'\n * import { pluginRedoc } from '@kubb/plugin-redoc'\n *\n * export default defineConfig({\n * input: './petStore.yaml',\n * output: { path: './src/gen' },\n * plugins: [\n * pluginRedoc({ output: { path: 'docs.html' } }),\n * ],\n * })\n * ```\n */\nexport const pluginRedoc = definePlugin<PluginRedoc>({\n meta: { name: pluginRedocName, version, compatibility: { kubb: '>=5.8.0' } },\n async setup(options) {\n const config = useConfig()\n const { output = { path: 'docs.html' } } = options\n const extname = path.extname(output.path)\n const name = extname ? output.path.slice(0, -extname.length) : output.path\n\n const adapter = config.adapter\n\n if (adapter?.name !== adapterOasName) {\n throw new Error(\n `[${pluginRedocName}] plugin-redoc requires the OpenAPI adapter. Make sure you are using adapterOas (e.g. \\`adapter: adapterOas()\\`) in your Kubb config.`,\n )\n }\n\n const document = (adapter as Adapter<AdapterOas>).document\n\n if (!document) {\n throw new Error(\n `[${pluginRedocName}] No OpenAPI document found. The adapterOas did not produce a document — ensure the adapter has run before this plugin.`,\n )\n }\n\n const root = path.resolve(config.root, config.output.path)\n const pageHTML = await getPageHTML(document)\n\n injectFile({\n baseName: 'docs.html',\n path: path.resolve(root, output.path || './docs.html'),\n sources: [\n ast.factory.createSource({\n name: 'docs.html',\n nodes: [ast.factory.createText(pageHTML)],\n }),\n ],\n })\n\n return { output, name, exclude: [], override: [] }\n },\n})\n\nexport default pluginRedoc\n"],"mappings":";;;;;;;;ACEA,MAAM,cAAsC;CAC1C,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;AACP;AAEA,SAAS,WAAW,OAAe;CACjC,OAAO,MAAM,QAAQ,eAAe,SAAS,YAAY,SAAS,IAAI;AACxE;;;;;;AAOA,eAAsB,YAAY,KAA6B;CAc7D,OAAO;;;;aAbW,WAAW,IAAI,KAAK,SAAS,qBAiB5B,EAAE;;;;;;;;;;;;;MAajB;;;;kBAxBY,KAAK,UAAU,KAAK,MAAM,CAAC,EAAE;;;;;MAwB/B;;;;AAIhB;;;;;;;AC3CA,MAAa,kBAAkB;;;;;;;;;;;;;;;;;;;;AAqB/B,MAAa,cAAc,aAA0B;CACnD,MAAM;EAAE,MAAM;EAAiB;EAAS,eAAe,EAAE,MAAM,UAAU;CAAE;CAC3E,MAAM,MAAM,SAAS;EACnB,MAAM,SAAS,UAAU;EACzB,MAAM,EAAE,SAAS,EAAE,MAAM,YAAY,MAAM;EAC3C,MAAM,UAAU,KAAK,QAAQ,OAAO,IAAI;EACxC,MAAM,OAAO,UAAU,OAAO,KAAK,MAAM,GAAG,CAAC,QAAQ,MAAM,IAAI,OAAO;EAEtE,MAAM,UAAU,OAAO;EAEvB,IAAI,SAAS,SAAS,gBACpB,MAAM,IAAI,MACR,IAAI,gBAAgB,sIACtB;EAGF,MAAM,WAAY,QAAgC;EAElD,IAAI,CAAC,UACH,MAAM,IAAI,MACR,IAAI,gBAAgB,wHACtB;EAGF,MAAM,OAAO,KAAK,QAAQ,OAAO,MAAM,OAAO,OAAO,IAAI;EACzD,MAAM,WAAW,MAAM,YAAY,QAAQ;EAE3C,WAAW;GACT,UAAU;GACV,MAAM,KAAK,QAAQ,MAAM,OAAO,QAAQ,aAAa;GACrD,SAAS,CACP,IAAI,QAAQ,aAAa;IACvB,MAAM;IACN,OAAO,CAAC,IAAI,QAAQ,WAAW,QAAQ,CAAC;GAC1C,CAAC,CACH;EACF,CAAC;EAED,OAAO;GAAE;GAAQ;GAAM,SAAS,CAAC;GAAG,UAAU,CAAC;EAAE;CACnD;AACF,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../kubb-extension.json","../package.json","../src/redoc.tsx","../src/plugin.ts"],"sourcesContent":["","","import type { AdapterOas } from '@kubb/adapter-oas'\n\nconst htmlEscapes: Record<string, string> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n \"'\": '&#x27;',\n '`': '&#x60;',\n '=': '&#x3D;',\n}\n\nfunction escapeHtml(value: string) {\n return value.replace(/[&<>\"'`=]/g, (char) => htmlEscapes[char] ?? char)\n}\n\n/**\n * Renders a self-contained Redoc HTML page for an OpenAPI document. The page\n * embeds the spec inline and pulls Redoc's bundle from a CDN at runtime, so\n * the generated file works without further build steps.\n */\nexport async function getPageHTML(api: AdapterOas['document']) {\n const pageTitle = escapeHtml(api.info.title || 'ReDoc documentation')\n const googleFont = `<link href='https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700' rel='stylesheet' />`\n const redocHTML = `\n <script src=\"https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js\"> </script>\n <div id=\"redoc-container\"></div>\n <script>\n const data = ${JSON.stringify(api, null, 2)};\n Redoc.init(data, {\n \"expandResponses\": \"200,400\"\n }, document.getElementById('redoc-container'))\n </script>\n `\n\n return `<html>\n\n <head>\n <meta charset='utf8' />\n <title>${pageTitle}</title>\n <!-- needed for adaptive design -->\n <meta name='viewport' content='width=device-width, initial-scale=1' />\n <style>\n body {\n padding: 0;\n margin: 0;\n }\n </style>\n ${googleFont}\n </head>\n\n <body>\n ${redocHTML}\n </body>\n\n</html>`\n}\n","import path from 'node:path'\nimport type { AdapterOas } from '@kubb/adapter-oas'\nimport { adapterOasName } from '@kubb/adapter-oas'\n\nimport { type Adapter, ast, defineExtension, injectFile, useConfig } from 'kubb/kit'\nimport { compatibility } from '../kubb-extension.json'\nimport { version } from '../package.json'\nimport { getPageHTML } from './redoc.tsx'\nimport type { PluginRedoc } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-redoc`. Used for driver lookups and\n * cross-plugin dependency references.\n */\nexport const pluginRedocName = 'plugin-redoc' satisfies PluginRedoc['name']\n\n/**\n * Generates a self-contained static HTML documentation page from your OpenAPI\n * spec using Redoc. The file is regenerated on every Kubb build, so the docs\n * stay in lockstep with the spec the rest of your code is generated from.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb/config'\n * import { pluginRedoc } from '@kubb/plugin-redoc'\n *\n * export default defineConfig({\n * input: './petStore.yaml',\n * output: { path: './src/gen' },\n * plugins: [\n * pluginRedoc({ output: { path: 'docs.html' } }),\n * ],\n * })\n * ```\n */\nexport const pluginRedoc = defineExtension<PluginRedoc>({\n kind: 'plugin',\n meta: { name: pluginRedocName, version, compatibility },\n async setup(options) {\n const config = useConfig()\n const { output = { path: 'docs.html' } } = options\n const extname = path.extname(output.path)\n const name = extname ? output.path.slice(0, -extname.length) : output.path\n\n const adapter = config.adapter\n\n if (adapter?.name !== adapterOasName) {\n throw new Error(\n `[${pluginRedocName}] plugin-redoc requires the OpenAPI adapter. Make sure you are using adapterOas (e.g. \\`adapter: adapterOas()\\`) in your Kubb config.`,\n )\n }\n\n const document = (adapter as Adapter<AdapterOas>).document\n\n if (!document) {\n throw new Error(\n `[${pluginRedocName}] No OpenAPI document found. The adapterOas did not produce a document — ensure the adapter has run before this plugin.`,\n )\n }\n\n const root = path.resolve(config.root, config.output.path)\n const pageHTML = await getPageHTML(document)\n\n injectFile({\n baseName: 'docs.html',\n path: path.resolve(root, output.path || './docs.html'),\n sources: [\n ast.factory.createSource({\n name: 'docs.html',\n nodes: [ast.factory.createText(pageHTML)],\n }),\n ],\n })\n\n return { output, name, exclude: [], override: [] }\n },\n})\n\nexport default pluginRedoc\n"],"mappings":";;;;;;;;;;;;;;AEEA,MAAM,cAAsC;CAC1C,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;AACP;AAEA,SAAS,WAAW,OAAe;CACjC,OAAO,MAAM,QAAQ,eAAe,SAAS,YAAY,SAAS,IAAI;AACxE;;;;;;AAOA,eAAsB,YAAY,KAA6B;CAc7D,OAAO;;;;aAbW,WAAW,IAAI,KAAK,SAAS,qBAiB5B,EAAE;;;;;;;;;;;;;MAajB;;;;kBAxBY,KAAK,UAAU,KAAK,MAAM,CAAC,EAAE;;;;;MAwB/B;;;;AAIhB;;;;;;;AC1CA,MAAa,kBAAkB;;;;;;;;;;;;;;;;;;;;AAqB/B,MAAa,cAAc,gBAA6B;CACtD,MAAM;CACN,MAAM;EAAE,MAAM;EAAiB;EAAS;CAAc;CACtD,MAAM,MAAM,SAAS;EACnB,MAAM,SAAS,UAAU;EACzB,MAAM,EAAE,SAAS,EAAE,MAAM,YAAY,MAAM;EAC3C,MAAM,UAAU,KAAK,QAAQ,OAAO,IAAI;EACxC,MAAM,OAAO,UAAU,OAAO,KAAK,MAAM,GAAG,CAAC,QAAQ,MAAM,IAAI,OAAO;EAEtE,MAAM,UAAU,OAAO;EAEvB,IAAI,SAAS,SAAS,gBACpB,MAAM,IAAI,MACR,IAAI,gBAAgB,sIACtB;EAGF,MAAM,WAAY,QAAgC;EAElD,IAAI,CAAC,UACH,MAAM,IAAI,MACR,IAAI,gBAAgB,wHACtB;EAGF,MAAM,OAAO,KAAK,QAAQ,OAAO,MAAM,OAAO,OAAO,IAAI;EACzD,MAAM,WAAW,MAAM,YAAY,QAAQ;EAE3C,WAAW;GACT,UAAU;GACV,MAAM,KAAK,QAAQ,MAAM,OAAO,QAAQ,aAAa;GACrD,SAAS,CACP,IAAI,QAAQ,aAAa;IACvB,MAAM;IACN,OAAO,CAAC,IAAI,QAAQ,WAAW,QAAQ,CAAC;GAC1C,CAAC,CACH;EACF,CAAC;EAED,OAAO;GAAE;GAAQ;GAAM,SAAS,CAAC;GAAG,UAAU,CAAC;EAAE;CACnD;AACF,CAAC"}
@@ -0,0 +1,39 @@
1
+ # Options
2
+
3
+ `pluginRedoc()` accepts a single option, the path of the HTML file it writes. It takes none of the [shared plugin options](https://kubb.dev/docs/5.x/reference/plugin-options).
4
+
5
+ ## Options overview
6
+
7
+ | Option | Purpose | Default |
8
+ | ------------------- | --------------------------------------- | ----------------------- |
9
+ | [`output`](#output) | Where the HTML file is written: `path`. | `{ path: 'docs.html' }` |
10
+
11
+ ## Option details
12
+
13
+ ### output
14
+
15
+ Where the generated Redoc HTML file is written.
16
+
17
+ | | |
18
+ | -------- | ----------------------- |
19
+ | Type | `{ path: string }` |
20
+ | Required | `false` |
21
+ | Default | `{ path: 'docs.html' }` |
22
+
23
+ #### output.path
24
+
25
+ File path of the generated HTML, resolved against the global `output.path`. Unlike most plugins, this points at a single file, not a directory. End the path with `.html`. Without `.html`, Kubb writes the file at that exact path, with no extension.
26
+
27
+ | | |
28
+ | -------- | ------------- |
29
+ | Type | `string` |
30
+ | Required | `false` |
31
+ | Default | `'docs.html'` |
32
+
33
+ With `output.path` set to `'docs.html'` and the global `output.path` set to `'./src/gen'`, the plugin writes one file:
34
+
35
+ ```text
36
+ src/
37
+ └── gen/
38
+ └── docs.html
39
+ ```
@@ -0,0 +1,35 @@
1
+ # Redoc
2
+
3
+ Generates a single HTML page that documents your OpenAPI spec with Redoc. The page is rebuilt on every Kubb run, so the docs always match the spec your code comes from.
4
+
5
+ The spec is embedded in the page, so you can publish it to any static host without a build step. Viewing the page needs network access, because Redoc's scripts and fonts load from a CDN.
6
+
7
+ ## Setup
8
+
9
+ No other plugins or packages are needed. The plugin reads the spec through Kubb's default OpenAPI adapter.
10
+
11
+ ## Options worth knowing
12
+
13
+ - `output.path` is the path of the HTML file. The default is `docs.html`. It points at a file, not a folder, so end it with `.html`.
14
+
15
+ The plugin takes no other options.
16
+
17
+ ## Example
18
+
19
+ ```typescript [kubb.config.ts]
20
+ import { defineConfig } from 'kubb/config'
21
+ import { pluginRedoc } from '@kubb/plugin-redoc'
22
+
23
+ export default defineConfig({
24
+ input: './petStore.yaml',
25
+ output: { path: './src/gen' },
26
+ plugins: [
27
+ pluginRedoc({ output: { path: 'docs.html' } }),
28
+ ],
29
+ })
30
+ ```
31
+
32
+ ## See also
33
+
34
+ - [Redoc](https://redocly.com/redoc)
35
+ - [adapterOas](https://kubb.dev/extensions/kubb-labs/adapter-oas)
@@ -0,0 +1,34 @@
1
+ {
2
+ "$schema": "https://kubb.dev/schemas/kubb-extension.json",
3
+ "kind": "plugin",
4
+ "name": "plugin-redoc",
5
+ "export": "pluginRedoc",
6
+ "displayName": "Redoc",
7
+ "description": "Generates a single-file HTML page from your OpenAPI spec with Redoc, rebuilt on every Kubb run so the docs match the spec your code comes from.",
8
+ "category": "documentation",
9
+ "icon": {
10
+ "light": "https://kubb.dev/feature/openapi.svg"
11
+ },
12
+ "tags": ["redoc", "api-docs", "documentation", "interactive-docs", "codegen", "openapi"],
13
+ "docs": "https://kubb.dev/extensions/kubb-labs/plugin-redoc",
14
+ "maintainers": [
15
+ {
16
+ "name": "Stijn Van Hulle",
17
+ "github": "stijnvanhulle"
18
+ }
19
+ ],
20
+ "compatibility": {
21
+ "kubb": ">=5.8.3",
22
+ "node": ">=22"
23
+ },
24
+ "options": [
25
+ {
26
+ "key": "outputPath",
27
+ "path": ["output", "path"],
28
+ "label": "Output Path",
29
+ "description": "Path of the generated HTML file. End it in .html.",
30
+ "type": "text",
31
+ "default": "docs.html"
32
+ }
33
+ ]
34
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-redoc",
3
- "version": "5.0.5",
3
+ "version": "5.0.7",
4
4
  "description": "Generate a ReDoc API reference page with Kubb. Produces a standalone HTML file you can host without a build step.",
5
5
  "keywords": [
6
6
  "api-docs",
@@ -13,7 +13,7 @@
13
13
  "redoc",
14
14
  "typescript"
15
15
  ],
16
- "homepage": "https://kubb.dev/plugins/plugin-redoc",
16
+ "homepage": "https://kubb.dev/extensions/kubb-labs/plugin-redoc",
17
17
  "license": "MIT",
18
18
  "author": "stijnvanhulle",
19
19
  "repository": {
@@ -37,6 +37,8 @@
37
37
  ],
38
38
  "files": [
39
39
  "dist",
40
+ "kubb-extension.json",
41
+ "docs",
40
42
  "!/**/**.test.**",
41
43
  "!/**/__tests__/**",
42
44
  "!/**/__snapshots__/**"
@@ -55,20 +57,21 @@
55
57
  "import": "./dist/index.js",
56
58
  "require": "./dist/index.cjs"
57
59
  },
58
- "./package.json": "./package.json"
60
+ "./package.json": "./package.json",
61
+ "./kubb-extension.json": "./kubb-extension.json"
59
62
  },
60
63
  "publishConfig": {
61
64
  "access": "public",
62
65
  "registry": "https://registry.npmjs.org/"
63
66
  },
64
67
  "dependencies": {
65
- "@kubb/adapter-oas": "^5.8.0"
68
+ "@kubb/adapter-oas": "^5.8.3"
66
69
  },
67
70
  "devDependencies": {
68
- "kubb": "^5.8.0"
71
+ "kubb": "^5.8.3"
69
72
  },
70
73
  "peerDependencies": {
71
- "kubb": "^5.8.0"
74
+ "kubb": "^5.8.3"
72
75
  },
73
76
  "engines": {
74
77
  "node": ">=22"