@kubb/plugin-redoc 5.0.0-beta.56 → 5.0.0-beta.64

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/dist/index.cjs CHANGED
@@ -29,7 +29,7 @@ node_path = __toESM(node_path, 1);
29
29
  let _kubb_adapter_oas = require("@kubb/adapter-oas");
30
30
  let _kubb_core = require("@kubb/core");
31
31
  //#region package.json
32
- var version = "5.0.0-beta.56";
32
+ var version = "5.0.0-beta.64";
33
33
  //#endregion
34
34
  //#region src/redoc.tsx
35
35
  const htmlEscapes = {
@@ -131,9 +131,9 @@ const pluginRedoc = (0, _kubb_core.definePlugin)((options) => {
131
131
  ctx.injectFile({
132
132
  baseName: "docs.html",
133
133
  path: node_path.default.resolve(root, output.path || "./docs.html"),
134
- sources: [_kubb_core.ast.createSource({
134
+ sources: [_kubb_core.ast.factory.createSource({
135
135
  name: "docs.html",
136
- nodes: [_kubb_core.ast.createText(pageHTML)]
136
+ nodes: [_kubb_core.ast.factory.createText(pageHTML)]
137
137
  })]
138
138
  });
139
139
  } }
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["path","adapterOasName","ast"],"sources":["../package.json","../src/redoc.tsx","../src/plugin.ts"],"sourcesContent":["","import type { AdapterOas } from '@kubb/adapter-oas'\n\ntype BuildDocsOptions = {\n title?: string\n disableGoogleFont?: boolean\n templateOptions?: any\n}\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'], { title, disableGoogleFont }: BuildDocsOptions = {}) {\n const pageTitle = escapeHtml(title || api.info.title || 'ReDoc documentation')\n const googleFont = disableGoogleFont\n ? ''\n : `<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 } from '@kubb/core'\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'\n * import { pluginRedoc } from '@kubb/plugin-redoc'\n *\n * export default defineConfig({\n * input: { path: './petStore.yaml' },\n * output: { path: './src/gen' },\n * plugins: [\n * pluginRedoc({ output: { path: 'docs.html' } }),\n * ],\n * })\n * ```\n */\nexport const pluginRedoc = definePlugin<PluginRedoc>((options) => {\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 return {\n name: pluginRedocName,\n version,\n options,\n hooks: {\n async 'kubb:plugin:setup'(ctx) {\n ctx.setOptions({\n output,\n name,\n exclude: [],\n override: [],\n })\n\n const adapter = ctx.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(ctx.config.root, ctx.config.output.path)\n const pageHTML = await getPageHTML(document)\n\n ctx.injectFile({\n baseName: 'docs.html',\n path: path.resolve(root, output.path || './docs.html'),\n sources: [\n ast.createSource({\n name: 'docs.html',\n nodes: [ast.createText(pageHTML)],\n }),\n ],\n })\n },\n },\n }\n})\n\nexport default pluginRedoc\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACQA,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,EAAE,OAAO,sBAAwC,CAAC,GAAG;CAgBlH,OAAO;;;;aAfW,WAAW,SAAS,IAAI,KAAK,SAAS,qBAmBrC,EAAE;;;;;;;;;MAlBF,oBACf,KACA,qHAyBW;;;;MAIX;;;;kBAxBY,KAAK,UAAU,KAAK,MAAM,CAAC,EAAE;;;;;MAwB/B;;;;AAIhB;;;;;;;ACnDA,MAAa,kBAAkB;;;;;;;;;;;;;;;;;;;;AAqB/B,MAAa,eAAA,GAAA,WAAA,aAAA,EAAyC,YAAY;CAChE,MAAM,EAAE,SAAS,EAAE,MAAM,YAAY,MAAM;CAC3C,MAAM,UAAUA,UAAAA,QAAK,QAAQ,OAAO,IAAI;CACxC,MAAM,OAAO,UAAU,OAAO,KAAK,MAAM,GAAG,CAAC,QAAQ,MAAM,IAAI,OAAO;CAEtE,OAAO;EACL,MAAM;EACN;EACA;EACA,OAAO,EACL,MAAM,oBAAoB,KAAK;GAC7B,IAAI,WAAW;IACb;IACA;IACA,SAAS,CAAC;IACV,UAAU,CAAC;GACb,CAAC;GAED,MAAM,UAAU,IAAI,OAAO;GAE3B,IAAI,SAAS,SAASC,kBAAAA,gBACpB,MAAM,IAAI,MACR,IAAI,gBAAgB,sIACtB;GAGF,MAAM,WAAY,QAAgC;GAElD,IAAI,CAAC,UACH,MAAM,IAAI,MACR,IAAI,gBAAgB,wHACtB;GAGF,MAAM,OAAOD,UAAAA,QAAK,QAAQ,IAAI,OAAO,MAAM,IAAI,OAAO,OAAO,IAAI;GACjE,MAAM,WAAW,MAAM,YAAY,QAAQ;GAE3C,IAAI,WAAW;IACb,UAAU;IACV,MAAMA,UAAAA,QAAK,QAAQ,MAAM,OAAO,QAAQ,aAAa;IACrD,SAAS,CACPE,WAAAA,IAAI,aAAa;KACf,MAAM;KACN,OAAO,CAACA,WAAAA,IAAI,WAAW,QAAQ,CAAC;IAClC,CAAC,CACH;GACF,CAAC;EACH,EACF;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"index.cjs","names":["path","adapterOasName","ast"],"sources":["../package.json","../src/redoc.tsx","../src/plugin.ts"],"sourcesContent":["","import type { AdapterOas } from '@kubb/adapter-oas'\n\ntype BuildDocsOptions = {\n title?: string\n disableGoogleFont?: boolean\n templateOptions?: any\n}\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'], { title, disableGoogleFont }: BuildDocsOptions = {}) {\n const pageTitle = escapeHtml(title || api.info.title || 'ReDoc documentation')\n const googleFont = disableGoogleFont\n ? ''\n : `<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 } from '@kubb/core'\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'\n * import { pluginRedoc } from '@kubb/plugin-redoc'\n *\n * export default defineConfig({\n * input: { path: './petStore.yaml' },\n * output: { path: './src/gen' },\n * plugins: [\n * pluginRedoc({ output: { path: 'docs.html' } }),\n * ],\n * })\n * ```\n */\nexport const pluginRedoc = definePlugin<PluginRedoc>((options) => {\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 return {\n name: pluginRedocName,\n version,\n options,\n hooks: {\n async 'kubb:plugin:setup'(ctx) {\n ctx.setOptions({\n output,\n name,\n exclude: [],\n override: [],\n })\n\n const adapter = ctx.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(ctx.config.root, ctx.config.output.path)\n const pageHTML = await getPageHTML(document)\n\n ctx.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 },\n }\n})\n\nexport default pluginRedoc\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACQA,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,EAAE,OAAO,sBAAwC,CAAC,GAAG;CAgBlH,OAAO;;;;aAfW,WAAW,SAAS,IAAI,KAAK,SAAS,qBAmBrC,EAAE;;;;;;;;;MAlBF,oBACf,KACA,qHAyBW;;;;MAIX;;;;kBAxBY,KAAK,UAAU,KAAK,MAAM,CAAC,EAAE;;;;;MAwB/B;;;;AAIhB;;;;;;;ACnDA,MAAa,kBAAkB;;;;;;;;;;;;;;;;;;;;AAqB/B,MAAa,eAAA,GAAA,WAAA,aAAA,EAAyC,YAAY;CAChE,MAAM,EAAE,SAAS,EAAE,MAAM,YAAY,MAAM;CAC3C,MAAM,UAAUA,UAAAA,QAAK,QAAQ,OAAO,IAAI;CACxC,MAAM,OAAO,UAAU,OAAO,KAAK,MAAM,GAAG,CAAC,QAAQ,MAAM,IAAI,OAAO;CAEtE,OAAO;EACL,MAAM;EACN;EACA;EACA,OAAO,EACL,MAAM,oBAAoB,KAAK;GAC7B,IAAI,WAAW;IACb;IACA;IACA,SAAS,CAAC;IACV,UAAU,CAAC;GACb,CAAC;GAED,MAAM,UAAU,IAAI,OAAO;GAE3B,IAAI,SAAS,SAASC,kBAAAA,gBACpB,MAAM,IAAI,MACR,IAAI,gBAAgB,sIACtB;GAGF,MAAM,WAAY,QAAgC;GAElD,IAAI,CAAC,UACH,MAAM,IAAI,MACR,IAAI,gBAAgB,wHACtB;GAGF,MAAM,OAAOD,UAAAA,QAAK,QAAQ,IAAI,OAAO,MAAM,IAAI,OAAO,OAAO,IAAI;GACjE,MAAM,WAAW,MAAM,YAAY,QAAQ;GAE3C,IAAI,WAAW;IACb,UAAU;IACV,MAAMA,UAAAA,QAAK,QAAQ,MAAM,OAAO,QAAQ,aAAa;IACrD,SAAS,CACPE,WAAAA,IAAI,QAAQ,aAAa;KACvB,MAAM;KACN,OAAO,CAACA,WAAAA,IAAI,QAAQ,WAAW,QAAQ,CAAC;IAC1C,CAAC,CACH;GACF,CAAC;EACH,EACF;CACF;AACF,CAAC"}
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import path from "node:path";
3
3
  import { adapterOasName } from "@kubb/adapter-oas";
4
4
  import { ast, definePlugin } from "@kubb/core";
5
5
  //#region package.json
6
- var version = "5.0.0-beta.56";
6
+ var version = "5.0.0-beta.64";
7
7
  //#endregion
8
8
  //#region src/redoc.tsx
9
9
  const htmlEscapes = {
@@ -105,9 +105,9 @@ const pluginRedoc = definePlugin((options) => {
105
105
  ctx.injectFile({
106
106
  baseName: "docs.html",
107
107
  path: path.resolve(root, output.path || "./docs.html"),
108
- sources: [ast.createSource({
108
+ sources: [ast.factory.createSource({
109
109
  name: "docs.html",
110
- nodes: [ast.createText(pageHTML)]
110
+ nodes: [ast.factory.createText(pageHTML)]
111
111
  })]
112
112
  });
113
113
  } }
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\ntype BuildDocsOptions = {\n title?: string\n disableGoogleFont?: boolean\n templateOptions?: any\n}\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'], { title, disableGoogleFont }: BuildDocsOptions = {}) {\n const pageTitle = escapeHtml(title || api.info.title || 'ReDoc documentation')\n const googleFont = disableGoogleFont\n ? ''\n : `<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 } from '@kubb/core'\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'\n * import { pluginRedoc } from '@kubb/plugin-redoc'\n *\n * export default defineConfig({\n * input: { path: './petStore.yaml' },\n * output: { path: './src/gen' },\n * plugins: [\n * pluginRedoc({ output: { path: 'docs.html' } }),\n * ],\n * })\n * ```\n */\nexport const pluginRedoc = definePlugin<PluginRedoc>((options) => {\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 return {\n name: pluginRedocName,\n version,\n options,\n hooks: {\n async 'kubb:plugin:setup'(ctx) {\n ctx.setOptions({\n output,\n name,\n exclude: [],\n override: [],\n })\n\n const adapter = ctx.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(ctx.config.root, ctx.config.output.path)\n const pageHTML = await getPageHTML(document)\n\n ctx.injectFile({\n baseName: 'docs.html',\n path: path.resolve(root, output.path || './docs.html'),\n sources: [\n ast.createSource({\n name: 'docs.html',\n nodes: [ast.createText(pageHTML)],\n }),\n ],\n })\n },\n },\n }\n})\n\nexport default pluginRedoc\n"],"mappings":";;;;;;;;ACQA,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,EAAE,OAAO,sBAAwC,CAAC,GAAG;CAgBlH,OAAO;;;;aAfW,WAAW,SAAS,IAAI,KAAK,SAAS,qBAmBrC,EAAE;;;;;;;;;MAlBF,oBACf,KACA,qHAyBW;;;;MAIX;;;;kBAxBY,KAAK,UAAU,KAAK,MAAM,CAAC,EAAE;;;;;MAwB/B;;;;AAIhB;;;;;;;ACnDA,MAAa,kBAAkB;;;;;;;;;;;;;;;;;;;;AAqB/B,MAAa,cAAc,cAA2B,YAAY;CAChE,MAAM,EAAE,SAAS,EAAE,MAAM,YAAY,MAAM;CAC3C,MAAM,UAAU,KAAK,QAAQ,OAAO,IAAI;CACxC,MAAM,OAAO,UAAU,OAAO,KAAK,MAAM,GAAG,CAAC,QAAQ,MAAM,IAAI,OAAO;CAEtE,OAAO;EACL,MAAM;EACN;EACA;EACA,OAAO,EACL,MAAM,oBAAoB,KAAK;GAC7B,IAAI,WAAW;IACb;IACA;IACA,SAAS,CAAC;IACV,UAAU,CAAC;GACb,CAAC;GAED,MAAM,UAAU,IAAI,OAAO;GAE3B,IAAI,SAAS,SAAS,gBACpB,MAAM,IAAI,MACR,IAAI,gBAAgB,sIACtB;GAGF,MAAM,WAAY,QAAgC;GAElD,IAAI,CAAC,UACH,MAAM,IAAI,MACR,IAAI,gBAAgB,wHACtB;GAGF,MAAM,OAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,IAAI,OAAO,OAAO,IAAI;GACjE,MAAM,WAAW,MAAM,YAAY,QAAQ;GAE3C,IAAI,WAAW;IACb,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM,OAAO,QAAQ,aAAa;IACrD,SAAS,CACP,IAAI,aAAa;KACf,MAAM;KACN,OAAO,CAAC,IAAI,WAAW,QAAQ,CAAC;IAClC,CAAC,CACH;GACF,CAAC;EACH,EACF;CACF;AACF,CAAC"}
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\ntype BuildDocsOptions = {\n title?: string\n disableGoogleFont?: boolean\n templateOptions?: any\n}\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'], { title, disableGoogleFont }: BuildDocsOptions = {}) {\n const pageTitle = escapeHtml(title || api.info.title || 'ReDoc documentation')\n const googleFont = disableGoogleFont\n ? ''\n : `<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 } from '@kubb/core'\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'\n * import { pluginRedoc } from '@kubb/plugin-redoc'\n *\n * export default defineConfig({\n * input: { path: './petStore.yaml' },\n * output: { path: './src/gen' },\n * plugins: [\n * pluginRedoc({ output: { path: 'docs.html' } }),\n * ],\n * })\n * ```\n */\nexport const pluginRedoc = definePlugin<PluginRedoc>((options) => {\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 return {\n name: pluginRedocName,\n version,\n options,\n hooks: {\n async 'kubb:plugin:setup'(ctx) {\n ctx.setOptions({\n output,\n name,\n exclude: [],\n override: [],\n })\n\n const adapter = ctx.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(ctx.config.root, ctx.config.output.path)\n const pageHTML = await getPageHTML(document)\n\n ctx.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 },\n }\n})\n\nexport default pluginRedoc\n"],"mappings":";;;;;;;;ACQA,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,EAAE,OAAO,sBAAwC,CAAC,GAAG;CAgBlH,OAAO;;;;aAfW,WAAW,SAAS,IAAI,KAAK,SAAS,qBAmBrC,EAAE;;;;;;;;;MAlBF,oBACf,KACA,qHAyBW;;;;MAIX;;;;kBAxBY,KAAK,UAAU,KAAK,MAAM,CAAC,EAAE;;;;;MAwB/B;;;;AAIhB;;;;;;;ACnDA,MAAa,kBAAkB;;;;;;;;;;;;;;;;;;;;AAqB/B,MAAa,cAAc,cAA2B,YAAY;CAChE,MAAM,EAAE,SAAS,EAAE,MAAM,YAAY,MAAM;CAC3C,MAAM,UAAU,KAAK,QAAQ,OAAO,IAAI;CACxC,MAAM,OAAO,UAAU,OAAO,KAAK,MAAM,GAAG,CAAC,QAAQ,MAAM,IAAI,OAAO;CAEtE,OAAO;EACL,MAAM;EACN;EACA;EACA,OAAO,EACL,MAAM,oBAAoB,KAAK;GAC7B,IAAI,WAAW;IACb;IACA;IACA,SAAS,CAAC;IACV,UAAU,CAAC;GACb,CAAC;GAED,MAAM,UAAU,IAAI,OAAO;GAE3B,IAAI,SAAS,SAAS,gBACpB,MAAM,IAAI,MACR,IAAI,gBAAgB,sIACtB;GAGF,MAAM,WAAY,QAAgC;GAElD,IAAI,CAAC,UACH,MAAM,IAAI,MACR,IAAI,gBAAgB,wHACtB;GAGF,MAAM,OAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,IAAI,OAAO,OAAO,IAAI;GACjE,MAAM,WAAW,MAAM,YAAY,QAAQ;GAE3C,IAAI,WAAW;IACb,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM,OAAO,QAAQ,aAAa;IACrD,SAAS,CACP,IAAI,QAAQ,aAAa;KACvB,MAAM;KACN,OAAO,CAAC,IAAI,QAAQ,WAAW,QAAQ,CAAC;IAC1C,CAAC,CACH;GACF,CAAC;EACH,EACF;CACF;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-redoc",
3
- "version": "5.0.0-beta.56",
3
+ "version": "5.0.0-beta.64",
4
4
  "description": "Generate a beautiful, interactive ReDoc API reference page from your OpenAPI specification. Produces a standalone HTML file with a responsive, developer-friendly UI.",
5
5
  "keywords": [
6
6
  "api-docs",
@@ -22,7 +22,6 @@
22
22
  "directory": "packages/plugin-redoc"
23
23
  },
24
24
  "files": [
25
- "src",
26
25
  "dist",
27
26
  "!/**/**.test.**",
28
27
  "!/**/__tests__/**",
@@ -48,8 +47,8 @@
48
47
  "registry": "https://registry.npmjs.org/"
49
48
  },
50
49
  "dependencies": {
51
- "@kubb/adapter-oas": "5.0.0-beta.55",
52
- "@kubb/core": "5.0.0-beta.55"
50
+ "@kubb/adapter-oas": "5.0.0-beta.63",
51
+ "@kubb/core": "5.0.0-beta.63"
53
52
  },
54
53
  "devDependencies": {
55
54
  "@internals/utils": "0.0.0"
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export { default, pluginRedoc, pluginRedocName } from './plugin.ts'
2
- export type { PluginRedoc } from './types.ts'
package/src/plugin.ts DELETED
@@ -1,87 +0,0 @@
1
- import path from 'node:path'
2
- import type { AdapterOas } from '@kubb/adapter-oas'
3
- import { adapterOasName } from '@kubb/adapter-oas'
4
-
5
- import { type Adapter, ast, definePlugin } from '@kubb/core'
6
- import { version } from '../package.json'
7
- import { getPageHTML } from './redoc.tsx'
8
- import type { PluginRedoc } from './types.ts'
9
-
10
- /**
11
- * Canonical plugin name for `@kubb/plugin-redoc`. Used for driver lookups and
12
- * cross-plugin dependency references.
13
- */
14
- export const pluginRedocName = 'plugin-redoc' satisfies PluginRedoc['name']
15
-
16
- /**
17
- * Generates a self-contained static HTML documentation page from your OpenAPI
18
- * spec using Redoc. The file is regenerated on every Kubb build, so the docs
19
- * stay in lockstep with the spec the rest of your code is generated from.
20
- *
21
- * @example
22
- * ```ts
23
- * import { defineConfig } from 'kubb'
24
- * import { pluginRedoc } from '@kubb/plugin-redoc'
25
- *
26
- * export default defineConfig({
27
- * input: { path: './petStore.yaml' },
28
- * output: { path: './src/gen' },
29
- * plugins: [
30
- * pluginRedoc({ output: { path: 'docs.html' } }),
31
- * ],
32
- * })
33
- * ```
34
- */
35
- export const pluginRedoc = definePlugin<PluginRedoc>((options) => {
36
- const { output = { path: 'docs.html' } } = options
37
- const extname = path.extname(output.path)
38
- const name = extname ? output.path.slice(0, -extname.length) : output.path
39
-
40
- return {
41
- name: pluginRedocName,
42
- version,
43
- options,
44
- hooks: {
45
- async 'kubb:plugin:setup'(ctx) {
46
- ctx.setOptions({
47
- output,
48
- name,
49
- exclude: [],
50
- override: [],
51
- })
52
-
53
- const adapter = ctx.config.adapter
54
-
55
- if (adapter?.name !== adapterOasName) {
56
- throw new Error(
57
- `[${pluginRedocName}] plugin-redoc requires the OpenAPI adapter. Make sure you are using adapterOas (e.g. \`adapter: adapterOas()\`) in your Kubb config.`,
58
- )
59
- }
60
-
61
- const document = (adapter as Adapter<AdapterOas>).document
62
-
63
- if (!document) {
64
- throw new Error(
65
- `[${pluginRedocName}] No OpenAPI document found. The adapterOas did not produce a document — ensure the adapter has run before this plugin.`,
66
- )
67
- }
68
-
69
- const root = path.resolve(ctx.config.root, ctx.config.output.path)
70
- const pageHTML = await getPageHTML(document)
71
-
72
- ctx.injectFile({
73
- baseName: 'docs.html',
74
- path: path.resolve(root, output.path || './docs.html'),
75
- sources: [
76
- ast.createSource({
77
- name: 'docs.html',
78
- nodes: [ast.createText(pageHTML)],
79
- }),
80
- ],
81
- })
82
- },
83
- },
84
- }
85
- })
86
-
87
- export default pluginRedoc
package/src/redoc.tsx DELETED
@@ -1,65 +0,0 @@
1
- import type { AdapterOas } from '@kubb/adapter-oas'
2
-
3
- type BuildDocsOptions = {
4
- title?: string
5
- disableGoogleFont?: boolean
6
- templateOptions?: any
7
- }
8
-
9
- const htmlEscapes: Record<string, string> = {
10
- '&': '&amp;',
11
- '<': '&lt;',
12
- '>': '&gt;',
13
- '"': '&quot;',
14
- "'": '&#x27;',
15
- '`': '&#x60;',
16
- '=': '&#x3D;',
17
- }
18
-
19
- function escapeHtml(value: string) {
20
- return value.replace(/[&<>"'`=]/g, (char) => htmlEscapes[char] ?? char)
21
- }
22
-
23
- /**
24
- * Renders a self-contained Redoc HTML page for an OpenAPI document. The page
25
- * embeds the spec inline and pulls Redoc's bundle from a CDN at runtime, so
26
- * the generated file works without further build steps.
27
- */
28
- export async function getPageHTML(api: AdapterOas['document'], { title, disableGoogleFont }: BuildDocsOptions = {}) {
29
- const pageTitle = escapeHtml(title || api.info.title || 'ReDoc documentation')
30
- const googleFont = disableGoogleFont
31
- ? ''
32
- : `<link href='https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700' rel='stylesheet' />`
33
- const redocHTML = `
34
- <script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"> </script>
35
- <div id="redoc-container"></div>
36
- <script>
37
- const data = ${JSON.stringify(api, null, 2)};
38
- Redoc.init(data, {
39
- "expandResponses": "200,400"
40
- }, document.getElementById('redoc-container'))
41
- </script>
42
- `
43
-
44
- return `<html>
45
-
46
- <head>
47
- <meta charset='utf8' />
48
- <title>${pageTitle}</title>
49
- <!-- needed for adaptive design -->
50
- <meta name='viewport' content='width=device-width, initial-scale=1' />
51
- <style>
52
- body {
53
- padding: 0;
54
- margin: 0;
55
- }
56
- </style>
57
- ${googleFont}
58
- </head>
59
-
60
- <body>
61
- ${redocHTML}
62
- </body>
63
-
64
- </html>`
65
- }
package/src/types.ts DELETED
@@ -1,35 +0,0 @@
1
- import type { Exclude, Include, Output, Override, PluginFactoryOptions } from '@kubb/core'
2
-
3
- export type Options = {
4
- /**
5
- * Output location of the generated Redoc HTML file. The path is resolved
6
- * against the global `output.path` set on `defineConfig`.
7
- */
8
- output?: {
9
- /**
10
- * File path of the generated HTML, relative to the global `output.path`.
11
- * Unlike most plugins, this points at a single file rather than a directory.
12
- *
13
- * @default 'docs.html'
14
- */
15
- path: string
16
- }
17
- }
18
-
19
- type ResolveOptions = {
20
- output: Output<never>
21
- name: string
22
- exclude: Array<Exclude>
23
- include?: Array<Include>
24
- override: Array<Override<ResolveOptions>>
25
- }
26
-
27
- export type PluginRedoc = PluginFactoryOptions<'plugin-redoc', Options, ResolveOptions>
28
-
29
- declare global {
30
- namespace Kubb {
31
- interface PluginRegistry {
32
- 'plugin-redoc': PluginRedoc
33
- }
34
- }
35
- }