@kubb/plugin-redoc 5.0.0-alpha.3 → 5.0.0-alpha.31
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 +16 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +15 -5
- package/dist/index.js +17 -10
- package/dist/index.js.map +1 -1
- package/package.json +8 -9
- package/src/plugin.ts +26 -9
- package/src/redoc.tsx +2 -2
- package/src/types.ts +14 -3
package/dist/index.cjs
CHANGED
|
@@ -23,13 +23,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
//#endregion
|
|
24
24
|
let node_path = require("node:path");
|
|
25
25
|
node_path = __toESM(node_path);
|
|
26
|
+
let _kubb_adapter_oas = require("@kubb/adapter-oas");
|
|
26
27
|
let _kubb_core = require("@kubb/core");
|
|
27
|
-
let _kubb_plugin_oas = require("@kubb/plugin-oas");
|
|
28
28
|
let node_fs = require("node:fs");
|
|
29
29
|
node_fs = __toESM(node_fs);
|
|
30
30
|
let node_url = require("node:url");
|
|
31
31
|
let handlebars = require("handlebars");
|
|
32
32
|
handlebars = __toESM(handlebars);
|
|
33
|
+
//#region package.json
|
|
34
|
+
var version = "5.0.0-alpha.31";
|
|
35
|
+
//#endregion
|
|
33
36
|
//#region src/redoc.tsx
|
|
34
37
|
const __filename$1 = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
|
|
35
38
|
const __dirname$1 = node_path.default.dirname(__filename$1);
|
|
@@ -57,20 +60,24 @@ function trimExtName(text) {
|
|
|
57
60
|
return text.replace(/\.[^/.]+$/, "");
|
|
58
61
|
}
|
|
59
62
|
const pluginRedocName = "plugin-redoc";
|
|
60
|
-
const pluginRedoc = (0, _kubb_core.
|
|
63
|
+
const pluginRedoc = (0, _kubb_core.createPlugin)((options) => {
|
|
61
64
|
const { output = { path: "docs.html" } } = options;
|
|
62
65
|
return {
|
|
63
66
|
name: pluginRedocName,
|
|
67
|
+
version,
|
|
64
68
|
options: {
|
|
65
69
|
output,
|
|
66
|
-
name: trimExtName(output.path)
|
|
70
|
+
name: trimExtName(output.path),
|
|
71
|
+
exclude: [],
|
|
72
|
+
override: []
|
|
67
73
|
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
+
async buildStart() {
|
|
75
|
+
const adapter = this.adapter;
|
|
76
|
+
if (adapter?.name !== _kubb_adapter_oas.adapterOasName) throw new Error(`[${pluginRedocName}] plugin-redoc requires the OpenAPI adapter. Make sure you are using adapterOas (e.g. \`adapter: adapterOas()\`) in your Kubb config.`);
|
|
77
|
+
const document = adapter.document;
|
|
78
|
+
if (!document) throw new Error(`[${pluginRedocName}] No OpenAPI document found. The adapterOas did not produce a document — ensure the adapter has run before this plugin.`);
|
|
79
|
+
const root = this.root;
|
|
80
|
+
const pageHTML = await getPageHTML(document);
|
|
74
81
|
await this.addFile({
|
|
75
82
|
baseName: "docs.html",
|
|
76
83
|
path: node_path.default.resolve(root, output.path || "./docs.html"),
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["__filename","__dirname","path","pkg","fs","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["__filename","__dirname","path","pkg","fs","adapterOasName","path"],"sources":["../package.json","../src/redoc.tsx","../src/plugin.ts"],"sourcesContent":["","import fs from 'node:fs'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport type { AdapterOas } from '@kubb/adapter-oas'\nimport pkg from 'handlebars'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\n\ntype BuildDocsOptions = {\n title?: string\n disableGoogleFont?: boolean\n templateOptions?: any\n}\n\nexport async function getPageHTML(api: AdapterOas['document'], { title, disableGoogleFont, templateOptions }: BuildDocsOptions = {}) {\n const templateFileName = path.join(__dirname, '../static/redoc.hbs')\n const template = pkg.compile(fs.readFileSync(templateFileName).toString())\n return template({\n title: title || api.info.title || 'ReDoc documentation',\n 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 disableGoogleFont,\n templateOptions,\n })\n}\n","import path from 'node:path'\nimport type { AdapterOas } from '@kubb/adapter-oas'\nimport { adapterOasName } from '@kubb/adapter-oas'\nimport { type Adapter, createPlugin } from '@kubb/core'\nimport { version } from '../package.json'\nimport { getPageHTML } from './redoc.tsx'\nimport type { PluginRedoc } from './types.ts'\n\nfunction trimExtName(text: string): string {\n return text.replace(/\\.[^/.]+$/, '')\n}\n\nexport const pluginRedocName = 'plugin-redoc' satisfies PluginRedoc['name']\n\nexport const pluginRedoc = createPlugin<PluginRedoc>((options) => {\n const { output = { path: 'docs.html' } } = options\n\n return {\n name: pluginRedocName,\n version,\n options: {\n output,\n name: trimExtName(output.path),\n exclude: [],\n override: [],\n },\n async buildStart() {\n const adapter = this.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 = this.root\n const pageHTML = await getPageHTML(document)\n\n await this.addFile({\n baseName: 'docs.html',\n path: path.resolve(root, output.path || './docs.html'),\n sources: [\n {\n name: 'docs.html',\n value: pageHTML,\n },\n ],\n imports: [],\n exports: [],\n })\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACMA,MAAMA,gBAAAA,GAAAA,SAAAA,eAAAA,QAAAA,MAAAA,CAAAA,cAAAA,WAAAA,CAAAA,KAA2C;AACjD,MAAMC,cAAYC,UAAAA,QAAK,QAAQF,aAAW;AAQ1C,eAAsB,YAAY,KAA6B,EAAE,OAAO,mBAAmB,oBAAsC,EAAE,EAAE;CACnI,MAAM,mBAAmBE,UAAAA,QAAK,KAAKD,aAAW,sBAAsB;AAEpE,QADiBE,WAAAA,QAAI,QAAQC,QAAAA,QAAG,aAAa,iBAAiB,CAAC,UAAU,CAAC,CAC1D;EACd,OAAO,SAAS,IAAI,KAAK,SAAS;EAClC,WAAW;;;;kBAIG,KAAK,UAAU,KAAK,MAAM,EAAE,CAAC;;;;;;EAM3C;EACA;EACD,CAAC;;;;ACxBJ,SAAS,YAAY,MAAsB;AACzC,QAAO,KAAK,QAAQ,aAAa,GAAG;;AAGtC,MAAa,kBAAkB;AAE/B,MAAa,eAAA,GAAA,WAAA,eAAyC,YAAY;CAChE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,KAAK;AAE3C,QAAO;EACL,MAAM;EACN;EACA,SAAS;GACP;GACA,MAAM,YAAY,OAAO,KAAK;GAC9B,SAAS,EAAE;GACX,UAAU,EAAE;GACb;EACD,MAAM,aAAa;GACjB,MAAM,UAAU,KAAK;AAErB,OAAI,SAAS,SAASC,kBAAAA,eACpB,OAAM,IAAI,MACR,IAAI,gBAAgB,uIACrB;GAGH,MAAM,WAAY,QAAgC;AAElD,OAAI,CAAC,SACH,OAAM,IAAI,MACR,IAAI,gBAAgB,yHACrB;GAGH,MAAM,OAAO,KAAK;GAClB,MAAM,WAAW,MAAM,YAAY,SAAS;AAE5C,SAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAMC,UAAAA,QAAK,QAAQ,MAAM,OAAO,QAAQ,cAAc;IACtD,SAAS,CACP;KACE,MAAM;KACN,OAAO;KACR,CACF;IACD,SAAS,EAAE;IACX,SAAS,EAAE;IACZ,CAAC;;EAEL;EACD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import * as _kubb_core0 from "@kubb/core";
|
|
3
|
-
import { Output, PluginFactoryOptions } from "@kubb/core";
|
|
4
|
-
import { Oas } from "@kubb/oas";
|
|
2
|
+
import * as _$_kubb_core0 from "@kubb/core";
|
|
3
|
+
import { Exclude, Include, Output, Override, PluginFactoryOptions } from "@kubb/core";
|
|
5
4
|
|
|
6
5
|
//#region src/types.d.ts
|
|
7
6
|
type Options = {
|
|
@@ -14,13 +13,24 @@ type Options = {
|
|
|
14
13
|
};
|
|
15
14
|
};
|
|
16
15
|
type ResolveOptions = {
|
|
17
|
-
output: Output<
|
|
16
|
+
output: Output<never>;
|
|
17
|
+
name: string;
|
|
18
|
+
exclude: Array<Exclude>;
|
|
19
|
+
include?: Array<Include>;
|
|
20
|
+
override: Array<Override<ResolveOptions>>;
|
|
18
21
|
};
|
|
19
22
|
type PluginRedoc = PluginFactoryOptions<'plugin-redoc', Options, ResolveOptions, never>;
|
|
23
|
+
declare global {
|
|
24
|
+
namespace Kubb {
|
|
25
|
+
interface PluginRegistry {
|
|
26
|
+
'plugin-redoc': PluginRedoc;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
20
30
|
//#endregion
|
|
21
31
|
//#region src/plugin.d.ts
|
|
22
32
|
declare const pluginRedocName = "plugin-redoc";
|
|
23
|
-
declare const pluginRedoc: (options?: Options | undefined) => _kubb_core0.UserPluginWithLifeCycle<PluginRedoc>;
|
|
33
|
+
declare const pluginRedoc: (options?: Options | undefined) => _$_kubb_core0.UserPluginWithLifeCycle<PluginRedoc>;
|
|
24
34
|
//#endregion
|
|
25
35
|
export { type PluginRedoc, pluginRedoc, pluginRedocName };
|
|
26
36
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { adapterOasName } from "@kubb/adapter-oas";
|
|
4
|
+
import { createPlugin } from "@kubb/core";
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import pkg from "handlebars";
|
|
8
|
+
//#region package.json
|
|
9
|
+
var version = "5.0.0-alpha.31";
|
|
10
|
+
//#endregion
|
|
8
11
|
//#region src/redoc.tsx
|
|
9
12
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
13
|
const __dirname = path.dirname(__filename);
|
|
@@ -32,20 +35,24 @@ function trimExtName(text) {
|
|
|
32
35
|
return text.replace(/\.[^/.]+$/, "");
|
|
33
36
|
}
|
|
34
37
|
const pluginRedocName = "plugin-redoc";
|
|
35
|
-
const pluginRedoc =
|
|
38
|
+
const pluginRedoc = createPlugin((options) => {
|
|
36
39
|
const { output = { path: "docs.html" } } = options;
|
|
37
40
|
return {
|
|
38
41
|
name: pluginRedocName,
|
|
42
|
+
version,
|
|
39
43
|
options: {
|
|
40
44
|
output,
|
|
41
|
-
name: trimExtName(output.path)
|
|
45
|
+
name: trimExtName(output.path),
|
|
46
|
+
exclude: [],
|
|
47
|
+
override: []
|
|
42
48
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
+
async buildStart() {
|
|
50
|
+
const adapter = this.adapter;
|
|
51
|
+
if (adapter?.name !== adapterOasName) throw new Error(`[${pluginRedocName}] plugin-redoc requires the OpenAPI adapter. Make sure you are using adapterOas (e.g. \`adapter: adapterOas()\`) in your Kubb config.`);
|
|
52
|
+
const document = adapter.document;
|
|
53
|
+
if (!document) throw new Error(`[${pluginRedocName}] No OpenAPI document found. The adapterOas did not produce a document — ensure the adapter has run before this plugin.`);
|
|
54
|
+
const root = this.root;
|
|
55
|
+
const pageHTML = await getPageHTML(document);
|
|
49
56
|
await this.addFile({
|
|
50
57
|
baseName: "docs.html",
|
|
51
58
|
path: path.resolve(root, output.path || "./docs.html"),
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/redoc.tsx","../src/plugin.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport type {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../package.json","../src/redoc.tsx","../src/plugin.ts"],"sourcesContent":["","import fs from 'node:fs'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport type { AdapterOas } from '@kubb/adapter-oas'\nimport pkg from 'handlebars'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\n\ntype BuildDocsOptions = {\n title?: string\n disableGoogleFont?: boolean\n templateOptions?: any\n}\n\nexport async function getPageHTML(api: AdapterOas['document'], { title, disableGoogleFont, templateOptions }: BuildDocsOptions = {}) {\n const templateFileName = path.join(__dirname, '../static/redoc.hbs')\n const template = pkg.compile(fs.readFileSync(templateFileName).toString())\n return template({\n title: title || api.info.title || 'ReDoc documentation',\n 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 disableGoogleFont,\n templateOptions,\n })\n}\n","import path from 'node:path'\nimport type { AdapterOas } from '@kubb/adapter-oas'\nimport { adapterOasName } from '@kubb/adapter-oas'\nimport { type Adapter, createPlugin } from '@kubb/core'\nimport { version } from '../package.json'\nimport { getPageHTML } from './redoc.tsx'\nimport type { PluginRedoc } from './types.ts'\n\nfunction trimExtName(text: string): string {\n return text.replace(/\\.[^/.]+$/, '')\n}\n\nexport const pluginRedocName = 'plugin-redoc' satisfies PluginRedoc['name']\n\nexport const pluginRedoc = createPlugin<PluginRedoc>((options) => {\n const { output = { path: 'docs.html' } } = options\n\n return {\n name: pluginRedocName,\n version,\n options: {\n output,\n name: trimExtName(output.path),\n exclude: [],\n override: [],\n },\n async buildStart() {\n const adapter = this.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 = this.root\n const pageHTML = await getPageHTML(document)\n\n await this.addFile({\n baseName: 'docs.html',\n path: path.resolve(root, output.path || './docs.html'),\n sources: [\n {\n name: 'docs.html',\n value: pageHTML,\n },\n ],\n imports: [],\n exports: [],\n })\n },\n }\n})\n"],"mappings":";;;;;;;;;;;ACMA,MAAM,aAAa,cAAc,OAAO,KAAK,IAAI;AACjD,MAAM,YAAY,KAAK,QAAQ,WAAW;AAQ1C,eAAsB,YAAY,KAA6B,EAAE,OAAO,mBAAmB,oBAAsC,EAAE,EAAE;CACnI,MAAM,mBAAmB,KAAK,KAAK,WAAW,sBAAsB;AAEpE,QADiB,IAAI,QAAQ,GAAG,aAAa,iBAAiB,CAAC,UAAU,CAAC,CAC1D;EACd,OAAO,SAAS,IAAI,KAAK,SAAS;EAClC,WAAW;;;;kBAIG,KAAK,UAAU,KAAK,MAAM,EAAE,CAAC;;;;;;EAM3C;EACA;EACD,CAAC;;;;ACxBJ,SAAS,YAAY,MAAsB;AACzC,QAAO,KAAK,QAAQ,aAAa,GAAG;;AAGtC,MAAa,kBAAkB;AAE/B,MAAa,cAAc,cAA2B,YAAY;CAChE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,KAAK;AAE3C,QAAO;EACL,MAAM;EACN;EACA,SAAS;GACP;GACA,MAAM,YAAY,OAAO,KAAK;GAC9B,SAAS,EAAE;GACX,UAAU,EAAE;GACb;EACD,MAAM,aAAa;GACjB,MAAM,UAAU,KAAK;AAErB,OAAI,SAAS,SAAS,eACpB,OAAM,IAAI,MACR,IAAI,gBAAgB,uIACrB;GAGH,MAAM,WAAY,QAAgC;AAElD,OAAI,CAAC,SACH,OAAM,IAAI,MACR,IAAI,gBAAgB,yHACrB;GAGH,MAAM,OAAO,KAAK;GAClB,MAAM,WAAW,MAAM,YAAY,SAAS;AAE5C,SAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM,OAAO,QAAQ,cAAc;IACtD,SAAS,CACP;KACE,MAAM;KACN,OAAO;KACR,CACF;IACD,SAAS,EAAE;IACX,SAAS,EAAE;IACZ,CAAC;;EAEL;EACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-redoc",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.31",
|
|
4
4
|
"description": "Redoc documentation generator plugin for Kubb, creating beautiful, interactive API documentation from OpenAPI specifications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"redoc",
|
|
@@ -51,16 +51,15 @@
|
|
|
51
51
|
}
|
|
52
52
|
],
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@kubb/fabric-core": "0.
|
|
55
|
-
"@kubb/react-fabric": "0.
|
|
56
|
-
"handlebars": "^4.7.
|
|
57
|
-
"@kubb/
|
|
58
|
-
"@kubb/
|
|
59
|
-
"@kubb/plugin-oas": "5.0.0-alpha.3"
|
|
54
|
+
"@kubb/fabric-core": "0.15.1",
|
|
55
|
+
"@kubb/react-fabric": "0.15.1",
|
|
56
|
+
"handlebars": "^4.7.9",
|
|
57
|
+
"@kubb/adapter-oas": "5.0.0-alpha.31",
|
|
58
|
+
"@kubb/core": "5.0.0-alpha.31"
|
|
60
59
|
},
|
|
61
60
|
"peerDependencies": {
|
|
62
|
-
"@kubb/fabric-core": "0.
|
|
63
|
-
"@kubb/react-fabric": "0.
|
|
61
|
+
"@kubb/fabric-core": "0.15.1",
|
|
62
|
+
"@kubb/react-fabric": "0.15.1"
|
|
64
63
|
},
|
|
65
64
|
"engines": {
|
|
66
65
|
"node": ">=22"
|
package/src/plugin.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { AdapterOas } from '@kubb/adapter-oas'
|
|
3
|
+
import { adapterOasName } from '@kubb/adapter-oas'
|
|
4
|
+
import { type Adapter, createPlugin } from '@kubb/core'
|
|
5
|
+
import { version } from '../package.json'
|
|
4
6
|
import { getPageHTML } from './redoc.tsx'
|
|
5
7
|
import type { PluginRedoc } from './types.ts'
|
|
6
8
|
|
|
@@ -10,22 +12,37 @@ function trimExtName(text: string): string {
|
|
|
10
12
|
|
|
11
13
|
export const pluginRedocName = 'plugin-redoc' satisfies PluginRedoc['name']
|
|
12
14
|
|
|
13
|
-
export const pluginRedoc =
|
|
15
|
+
export const pluginRedoc = createPlugin<PluginRedoc>((options) => {
|
|
14
16
|
const { output = { path: 'docs.html' } } = options
|
|
15
17
|
|
|
16
18
|
return {
|
|
17
19
|
name: pluginRedocName,
|
|
20
|
+
version,
|
|
18
21
|
options: {
|
|
19
22
|
output,
|
|
20
23
|
name: trimExtName(output.path),
|
|
24
|
+
exclude: [],
|
|
25
|
+
override: [],
|
|
21
26
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const oas = await this.getOas()
|
|
25
|
-
await oas.dereference()
|
|
27
|
+
async buildStart() {
|
|
28
|
+
const adapter = this.adapter
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
if (adapter?.name !== adapterOasName) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
`[${pluginRedocName}] plugin-redoc requires the OpenAPI adapter. Make sure you are using adapterOas (e.g. \`adapter: adapterOas()\`) in your Kubb config.`,
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const document = (adapter as Adapter<AdapterOas>).document
|
|
37
|
+
|
|
38
|
+
if (!document) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
`[${pluginRedocName}] No OpenAPI document found. The adapterOas did not produce a document — ensure the adapter has run before this plugin.`,
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const root = this.root
|
|
45
|
+
const pageHTML = await getPageHTML(document)
|
|
29
46
|
|
|
30
47
|
await this.addFile({
|
|
31
48
|
baseName: 'docs.html',
|
package/src/redoc.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
2
|
import path from 'node:path'
|
|
3
3
|
import { fileURLToPath } from 'node:url'
|
|
4
|
-
import type {
|
|
4
|
+
import type { AdapterOas } from '@kubb/adapter-oas'
|
|
5
5
|
import pkg from 'handlebars'
|
|
6
6
|
|
|
7
7
|
const __filename = fileURLToPath(import.meta.url)
|
|
@@ -13,7 +13,7 @@ type BuildDocsOptions = {
|
|
|
13
13
|
templateOptions?: any
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export async function getPageHTML(api:
|
|
16
|
+
export async function getPageHTML(api: AdapterOas['document'], { title, disableGoogleFont, templateOptions }: BuildDocsOptions = {}) {
|
|
17
17
|
const templateFileName = path.join(__dirname, '../static/redoc.hbs')
|
|
18
18
|
const template = pkg.compile(fs.readFileSync(templateFileName).toString())
|
|
19
19
|
return template({
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Output, PluginFactoryOptions } from '@kubb/core'
|
|
2
|
-
import type { Oas } from '@kubb/oas'
|
|
1
|
+
import type { Exclude, Include, Output, Override, PluginFactoryOptions } from '@kubb/core'
|
|
3
2
|
|
|
4
3
|
export type Options = {
|
|
5
4
|
output?: {
|
|
@@ -12,7 +11,19 @@ export type Options = {
|
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
type ResolveOptions = {
|
|
15
|
-
output: Output<
|
|
14
|
+
output: Output<never>
|
|
15
|
+
name: string
|
|
16
|
+
exclude: Array<Exclude>
|
|
17
|
+
include?: Array<Include>
|
|
18
|
+
override: Array<Override<ResolveOptions>>
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
export type PluginRedoc = PluginFactoryOptions<'plugin-redoc', Options, ResolveOptions, never>
|
|
22
|
+
|
|
23
|
+
declare global {
|
|
24
|
+
namespace Kubb {
|
|
25
|
+
interface PluginRegistry {
|
|
26
|
+
'plugin-redoc': PluginRedoc
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|