@kubb/plugin-redoc 2.18.2 → 2.18.3
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 +4 -167
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -177
- package/dist/index.js.map +1 -1
- package/package.json +8 -11
- package/src/plugin.ts +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
2
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
3
|
}) : x)(function(x) {
|
|
4
4
|
if (typeof require !== "undefined")
|
|
@@ -10,170 +10,7 @@
|
|
|
10
10
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
11
11
|
var _core = require('@kubb/core');
|
|
12
12
|
var _transformers = require('@kubb/core/transformers');
|
|
13
|
-
|
|
14
|
-
// ../swagger/src/plugin.ts
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// ../swagger/src/utils/getSchemas.ts
|
|
20
|
-
function getSchemas({ oas, contentType, includes = ["schemas", "requestBodies", "responses"] }) {
|
|
21
|
-
const components = oas.getDefinition().components;
|
|
22
|
-
let schemas = {};
|
|
23
|
-
if (includes.includes("schemas")) {
|
|
24
|
-
schemas = {
|
|
25
|
-
...schemas,
|
|
26
|
-
..._optionalChain([components, 'optionalAccess', _ => _.schemas]) || {}
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
const requestBodies = _optionalChain([components, 'optionalAccess', _2 => _2.requestBodies]) || {};
|
|
30
|
-
if (includes.includes("responses")) {
|
|
31
|
-
const responses = _optionalChain([components, 'optionalAccess', _3 => _3.responses]) || {};
|
|
32
|
-
Object.entries(responses).forEach(([name, response]) => {
|
|
33
|
-
if (response.content && !schemas[name]) {
|
|
34
|
-
const firstContentType = Object.keys(response.content)[0] || "application/json";
|
|
35
|
-
schemas[name] = _optionalChain([response, 'access', _4 => _4.content, 'optionalAccess', _5 => _5[contentType || firstContentType], 'optionalAccess', _6 => _6.schema]);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
if (includes.includes("requestBodies")) {
|
|
40
|
-
Object.entries(requestBodies).forEach(([name, request]) => {
|
|
41
|
-
if (request.content && !schemas[name]) {
|
|
42
|
-
const firstContentType = Object.keys(request.content)[0] || "application/json";
|
|
43
|
-
schemas[name] = _optionalChain([request, 'access', _7 => _7.content, 'optionalAccess', _8 => _8[contentType || firstContentType], 'optionalAccess', _9 => _9.schema]);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
return schemas;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// ../swagger/src/utils/parseFromConfig.ts
|
|
51
|
-
|
|
52
|
-
var _utils = require('@kubb/core/utils');
|
|
53
|
-
var _parser = require('@kubb/oas/parser');
|
|
54
|
-
var _yaml = require('@stoplight/yaml'); var _yaml2 = _interopRequireDefault(_yaml);
|
|
55
|
-
function parseFromConfig(config, options = {}) {
|
|
56
|
-
if ("data" in config.input) {
|
|
57
|
-
if (typeof config.input.data === "object") {
|
|
58
|
-
const api2 = JSON.parse(JSON.stringify(config.input.data));
|
|
59
|
-
return _parser.parse.call(void 0, api2, options);
|
|
60
|
-
}
|
|
61
|
-
try {
|
|
62
|
-
const api2 = _yaml2.default.parse(config.input.data);
|
|
63
|
-
return _parser.parse.call(void 0, api2, options);
|
|
64
|
-
} catch (e) {
|
|
65
|
-
}
|
|
66
|
-
const api = JSON.parse(JSON.stringify(config.input.data));
|
|
67
|
-
return _parser.parse.call(void 0, api, options);
|
|
68
|
-
}
|
|
69
|
-
if (new (0, _utils.URLPath)(config.input.path).isURL) {
|
|
70
|
-
return _parser.parse.call(void 0, config.input.path, options);
|
|
71
|
-
}
|
|
72
|
-
return _parser.parse.call(void 0, _path.resolve.call(void 0, config.root, config.input.path), options);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// ../swagger/src/plugin.ts
|
|
76
|
-
var pluginSwaggerName = "swagger";
|
|
77
|
-
var pluginSwagger = _core.createPlugin.call(void 0, (options) => {
|
|
78
|
-
const {
|
|
79
|
-
output = { path: "schemas", export: false },
|
|
80
|
-
experimentalFilter: filter,
|
|
81
|
-
experimentalSort: sort,
|
|
82
|
-
validate = true,
|
|
83
|
-
serverIndex = 0,
|
|
84
|
-
contentType
|
|
85
|
-
} = options;
|
|
86
|
-
const getOas = async ({ config, logger, formatOptions }) => {
|
|
87
|
-
try {
|
|
88
|
-
const oas = await parseFromConfig(config, formatOptions);
|
|
89
|
-
if (validate) {
|
|
90
|
-
await oas.valdiate();
|
|
91
|
-
}
|
|
92
|
-
return oas;
|
|
93
|
-
} catch (e) {
|
|
94
|
-
const error = e;
|
|
95
|
-
logger.emit("warning", _optionalChain([error, 'optionalAccess', _10 => _10.message]));
|
|
96
|
-
return parseFromConfig(config);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
return {
|
|
100
|
-
name: pluginSwaggerName,
|
|
101
|
-
options,
|
|
102
|
-
api() {
|
|
103
|
-
const { config, logger } = this;
|
|
104
|
-
return {
|
|
105
|
-
getOas(formatOptions) {
|
|
106
|
-
return getOas({ config, logger, formatOptions });
|
|
107
|
-
},
|
|
108
|
-
async getSchemas({ includes } = {}) {
|
|
109
|
-
const oas = await this.getOas();
|
|
110
|
-
return getSchemas({ oas, contentType, includes });
|
|
111
|
-
},
|
|
112
|
-
async getBaseURL() {
|
|
113
|
-
const oasInstance = await this.getOas();
|
|
114
|
-
const baseURL = _optionalChain([oasInstance, 'access', _11 => _11.api, 'access', _12 => _12.servers, 'optionalAccess', _13 => _13.at, 'call', _14 => _14(serverIndex), 'optionalAccess', _15 => _15.url]);
|
|
115
|
-
return baseURL;
|
|
116
|
-
},
|
|
117
|
-
contentType
|
|
118
|
-
};
|
|
119
|
-
},
|
|
120
|
-
resolvePath(baseName) {
|
|
121
|
-
if (output === false) {
|
|
122
|
-
return void 0;
|
|
123
|
-
}
|
|
124
|
-
const root = _path2.default.resolve(this.config.root, this.config.output.path);
|
|
125
|
-
return _path2.default.resolve(root, output.path, baseName);
|
|
126
|
-
},
|
|
127
|
-
resolveName(name, type) {
|
|
128
|
-
return _transformers.camelCase.call(void 0, name, { isFile: type === "file" });
|
|
129
|
-
},
|
|
130
|
-
async writeFile(source, writePath) {
|
|
131
|
-
if (!writePath.endsWith(".json") || !source) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
return this.fileManager.write(source, writePath, { sanity: false });
|
|
135
|
-
},
|
|
136
|
-
async buildStart() {
|
|
137
|
-
if (!output) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
const oas = await getOas({
|
|
141
|
-
config: this.config,
|
|
142
|
-
logger: this.logger,
|
|
143
|
-
formatOptions: {
|
|
144
|
-
filterSet: filter,
|
|
145
|
-
sortSet: sort
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
await oas.dereference();
|
|
149
|
-
const schemas = getSchemas({ oas, contentType });
|
|
150
|
-
const mapSchema = async ([name, schema]) => {
|
|
151
|
-
const resolvedPath = this.resolvePath({
|
|
152
|
-
baseName: `${name}.json`,
|
|
153
|
-
pluginKey: this.plugin.key
|
|
154
|
-
});
|
|
155
|
-
const resvoledFileName = this.resolveName({
|
|
156
|
-
name: `${name}.json`,
|
|
157
|
-
pluginKey: [pluginSwaggerName],
|
|
158
|
-
type: "file"
|
|
159
|
-
});
|
|
160
|
-
if (!resolvedPath) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
await this.addFile({
|
|
164
|
-
path: resolvedPath,
|
|
165
|
-
baseName: resvoledFileName,
|
|
166
|
-
source: JSON.stringify(schema),
|
|
167
|
-
meta: {
|
|
168
|
-
pluginKey: this.plugin.key
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
};
|
|
172
|
-
const promises = Object.entries(schemas).map(mapSchema);
|
|
173
|
-
await Promise.all(promises);
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
});
|
|
13
|
+
var _pluginoas = require('@kubb/plugin-oas');
|
|
177
14
|
|
|
178
15
|
// src/redoc.tsx
|
|
179
16
|
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
@@ -238,7 +75,7 @@ var pluginRedoc = _core.createPlugin.call(void 0, (options) => {
|
|
|
238
75
|
name: _transformers.trimExtName.call(void 0, output.path),
|
|
239
76
|
baseURL: void 0
|
|
240
77
|
},
|
|
241
|
-
pre: [
|
|
78
|
+
pre: [_pluginoas.pluginOasName],
|
|
242
79
|
resolvePath(baseName) {
|
|
243
80
|
const root = _path2.default.resolve(this.config.root, this.config.output.path);
|
|
244
81
|
return _path2.default.resolve(root, baseName);
|
|
@@ -253,7 +90,7 @@ var pluginRedoc = _core.createPlugin.call(void 0, (options) => {
|
|
|
253
90
|
return this.fileManager.write(source, writePath, { sanity: false });
|
|
254
91
|
},
|
|
255
92
|
async buildStart() {
|
|
256
|
-
const [swaggerPlugin] = _core.PluginManager.getDependedPlugins(this.plugins, [
|
|
93
|
+
const [swaggerPlugin] = _core.PluginManager.getDependedPlugins(this.plugins, [_pluginoas.pluginOasName]);
|
|
257
94
|
const oas = await swaggerPlugin.api.getOas();
|
|
258
95
|
await oas.dereference();
|
|
259
96
|
const root = _path2.default.resolve(this.config.root, this.config.output.path);
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts","../../swagger/src/plugin.ts","../../swagger/src/utils/getSchemas.ts","../../swagger/src/utils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,OAAO,OAAO,IAAI;AAEnE,aAAOA,MAAK,QAAQ,MAAM,QAAQ;AAAA,IACpC;AAAA,IACA,YAAY,MAAM,MAAM;AACtB,aAAOE,WAAU,MAAM,EAAE,QAAQ,SAAS,OAAO,CAAC;AAAA,IACpD;AAAA,IACA,MAAM,UAAU,QAAQ,WAAW;AACjC,UAAI,CAAC,UAAU,SAAS,KAAK,KAAK,CAAC,QAAQ;AACzC;AAAA,MACF;AAEA,aAAO,KAAK,YAAY,MAAM,QAAQ,WAAW,EAAE,QAAQ,MAAM,CAAC;AAAA,IACpE;AAAA,IACA,MAAM,aAAa;AACjB,YAAM,CAAC,aAAa,IAA6B,cAAc,mBAAkC,KAAK,SAAS,CAAC,iBAAiB,CAAC;AAClI,YAAM,MAAM,MAAM,cAAc,IAAI,OAAO;AAE3C,YAAM,IAAI,YAAY;AAEtB,YAAM,OAAOF,MAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,IAAI;AACnE,YAAM,WAAW,MAAM,YAAY,IAAI,GAAG;AAE1C,YAAM,KAAK,YAAY,MAAM,UAAUA,MAAK,QAAQ,MAAM,OAAO,QAAQ,aAAa,CAAC;AAAA,IACzF;AAAA,EACF;AACF,CAAC","sourcesContent":["import path from 'node:path'\n\nimport { PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, trimExtName } from '@kubb/core/transformers'\nimport { pluginSwaggerName } from '@kubb/swagger'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginSwagger } from '@kubb/swagger'\nimport { getPageHTML } from './redoc.tsx'\nimport type { PluginRedoc } from './types.ts'\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 options: {\n name: trimExtName(output.path),\n baseURL: undefined,\n },\n pre: [pluginSwaggerName],\n resolvePath(baseName) {\n const root = path.resolve(this.config.root, this.config.output.path)\n\n return path.resolve(root, baseName)\n },\n resolveName(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n async writeFile(source, writePath) {\n if (!writePath.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(source, writePath, { sanity: false })\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginSwagger>] = PluginManager.getDependedPlugins<PluginSwagger>(this.plugins, [pluginSwaggerName])\n const oas = await swaggerPlugin.api.getOas()\n\n await oas.dereference()\n\n const root = path.resolve(this.config.root, this.config.output.path)\n const pageHTML = await getPageHTML(oas.api)\n\n await this.fileManager.write(pageHTML, path.resolve(root, output.path || './docs.html'))\n },\n }\n})\n","import path from 'node:path'\n\nimport { createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\n\nimport { getSchemas } from './utils/getSchemas.ts'\n\nimport type { Config } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport type { Oas, OasTypes } from '@kubb/oas'\nimport type { FormatOptions } from '@kubb/oas/parser'\nimport type { PluginSwagger } from './types.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nexport const pluginSwaggerName = 'swagger' satisfies PluginSwagger['name']\n\nexport const pluginSwagger = createPlugin<PluginSwagger>((options) => {\n const {\n output = { path: 'schemas', export: false },\n experimentalFilter: filter,\n experimentalSort: sort,\n validate = true,\n serverIndex = 0,\n contentType,\n } = options\n\n const getOas = async ({ config, logger, formatOptions }: { config: Config; logger: Logger; formatOptions?: FormatOptions }): Promise<Oas> => {\n try {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n const oas = await parseFromConfig(config, formatOptions)\n\n if (validate) {\n await oas.valdiate()\n }\n\n return oas\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n return parseFromConfig(config)\n }\n }\n\n return {\n name: pluginSwaggerName,\n options,\n\n api() {\n const { config, logger } = this\n\n return {\n getOas(formatOptions) {\n return getOas({ config, logger, formatOptions })\n },\n async getSchemas({ includes } = {}) {\n const oas = await this.getOas()\n return getSchemas({ oas, contentType, includes })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n const baseURL = oasInstance.api.servers?.at(serverIndex)?.url\n return baseURL\n },\n contentType,\n }\n },\n resolvePath(baseName) {\n if (output === false) {\n return undefined\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n async writeFile(source, writePath) {\n if (!writePath.endsWith('.json') || !source) {\n return\n }\n\n return this.fileManager.write(source, writePath, { sanity: false })\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n formatOptions: {\n filterSet: filter,\n sortSet: sort,\n },\n })\n await oas.dereference()\n const schemas = getSchemas({ oas, contentType })\n\n const mapSchema = async ([name, schema]: [string, OasTypes.SchemaObject]) => {\n const resolvedPath = this.resolvePath({\n baseName: `${name}.json`,\n pluginKey: this.plugin.key,\n })\n\n const resvoledFileName = this.resolveName({\n name: `${name}.json`,\n pluginKey: [pluginSwaggerName],\n type: 'file',\n }) as `${string}.json`\n\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: resvoledFileName,\n source: JSON.stringify(schema),\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const promises = Object.entries(schemas).map(mapSchema)\n await Promise.all(promises)\n },\n }\n})\n","import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\nexport type GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n}\n\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'] }: GetSchemasProps): Record<string, OasTypes.SchemaObject> {\n const components = oas.getDefinition().components\n\n let schemas: Record<string, OasTypes.SchemaObject> = {}\n\n if (includes.includes('schemas')) {\n schemas = {\n ...schemas,\n ...((components?.schemas as Record<string, OasTypes.SchemaObject>) || {}),\n }\n }\n\n const requestBodies = components?.requestBodies || {}\n if (includes.includes('responses')) {\n const responses = components?.responses || {}\n\n Object.entries(responses).forEach(([name, response]: [string, OasTypes.ResponseObject]) => {\n if (response.content && !schemas[name]) {\n const firstContentType = Object.keys(response.content)[0] || 'application/json'\n schemas[name] = response.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n if (includes.includes('requestBodies')) {\n Object.entries(requestBodies).forEach(([name, request]: [string, OasTypes.RequestBodyObject]) => {\n if (request.content && !schemas[name]) {\n const firstContentType = Object.keys(request.content)[0] || 'application/json'\n schemas[name] = request.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n return schemas\n}\n","import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { type FormatOptions, parse } from '@kubb/oas/parser'\n\nimport type { Config } from '@kubb/core'\nimport type { Oas, OasTypes } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, options: FormatOptions = {}): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, options)\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, options)\n } catch (e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, options)\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, options)\n }\n\n return parse(resolve(config.root, config.input.path), options)\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport type { OasTypes } from '@kubb/oas'\nimport pkg from 'handlebars'\nimport { renderToString } from 'react-dom/server'\nimport { ServerStyleSheet } from 'styled-components'\nimport redoc from 'redoc'\n\ntype BuildDocsOptions = {\n title?: string\n disableGoogleFont?: boolean\n templateOptions?: any\n redocOptions?: any\n}\n\n// see http://www.thespanner.co.uk/2011/07/25/the-json-specification-is-now-wrong/\nfunction escapeClosingScriptTag(str: string): string {\n return str.replace(/<\\/script>/g, '<\\\\/script>')\n}\n\n// see http://www.thespanner.co.uk/2011/07/25/the-json-specification-is-now-wrong/\nfunction escapeUnicode(str: string): string {\n // biome-ignore lint/style/useTemplate: <explanation>\n return str.replace(/\\u2028|\\u2029/g, (m) => '\\\\u202' + (m === '\\u2028' ? '8' : '9'))\n}\n\nfunction sanitizeJSONString(str: string): string {\n return escapeClosingScriptTag(escapeUnicode(str))\n}\n\nexport async function getPageHTML(api: OasTypes.OASDocument, { title, disableGoogleFont, templateOptions, redocOptions = {} }: BuildDocsOptions = {}) {\n const apiUrl = redocOptions.specUrl\n const { Redoc, createStore } = redoc || require('redoc')\n const store = await createStore(api, apiUrl, redocOptions)\n const sheet = new ServerStyleSheet()\n\n const error = console.error\n console.error = (...args: any) => {\n if (/defaultProps/.test(args[0])) return\n error(...args)\n }\n\n const html = renderToString(sheet.collectStyles(<Redoc store={store} />))\n const state = await store.toJS()\n const css = sheet.getStyleTags()\n\n const templateFileName = path.join(__dirname, '../static/redoc.hbs')\n const template = pkg.compile(fs.readFileSync(templateFileName).toString())\n return template({\n redocHTML: `\n <div id=\"redoc\">${html || ''}</div>\n <script>\n ${`const __redoc_state = ${sanitizeJSONString(JSON.stringify(state))};` || ''}\n\n var container = document.getElementById('redoc');\n Redoc.${'hydrate(__redoc_state, container)'};\n\n </script>`,\n redocHead:\n // biome-ignore lint/style/useTemplate: <explanation>\n `<script src=\"https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js\"></script>` + css,\n title: title || api.info.title || 'ReDoc documentation',\n disableGoogleFont,\n templateOptions,\n })\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts","../src/redoc.tsx"],"names":["path"],"mappings":";;;;;;;;;AAAA,OAAOA,WAAU;AAEjB,SAAS,eAAe,oBAAoB;AAC5C,SAAS,WAAW,mBAAmB;A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CAAC","sourcesContent":["import path from 'node:path'\n\nimport { PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, trimExtName } from '@kubb/core/transformers'\nimport { pluginOasName } from '@kubb/plugin-oas'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { getPageHTML } from './redoc.tsx'\nimport type { PluginRedoc } from './types.ts'\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 options: {\n name: trimExtName(output.path),\n baseURL: undefined,\n },\n pre: [pluginOasName],\n resolvePath(baseName) {\n const root = path.resolve(this.config.root, this.config.output.path)\n\n return path.resolve(root, baseName)\n },\n resolveName(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n async writeFile(source, writePath) {\n if (!writePath.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(source, writePath, { sanity: false })\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n const oas = await swaggerPlugin.api.getOas()\n\n await oas.dereference()\n\n const root = path.resolve(this.config.root, this.config.output.path)\n const pageHTML = await getPageHTML(oas.api)\n\n await this.fileManager.write(pageHTML, path.resolve(root, output.path || './docs.html'))\n },\n }\n})\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport type { OasTypes } from '@kubb/oas'\nimport pkg from 'handlebars'\nimport { renderToString } from 'react-dom/server'\nimport { ServerStyleSheet } from 'styled-components'\nimport redoc from 'redoc'\n\ntype BuildDocsOptions = {\n title?: string\n disableGoogleFont?: boolean\n templateOptions?: any\n redocOptions?: any\n}\n\n// see http://www.thespanner.co.uk/2011/07/25/the-json-specification-is-now-wrong/\nfunction escapeClosingScriptTag(str: string): string {\n return str.replace(/<\\/script>/g, '<\\\\/script>')\n}\n\n// see http://www.thespanner.co.uk/2011/07/25/the-json-specification-is-now-wrong/\nfunction escapeUnicode(str: string): string {\n // biome-ignore lint/style/useTemplate: <explanation>\n return str.replace(/\\u2028|\\u2029/g, (m) => '\\\\u202' + (m === '\\u2028' ? '8' : '9'))\n}\n\nfunction sanitizeJSONString(str: string): string {\n return escapeClosingScriptTag(escapeUnicode(str))\n}\n\nexport async function getPageHTML(api: OasTypes.OASDocument, { title, disableGoogleFont, templateOptions, redocOptions = {} }: BuildDocsOptions = {}) {\n const apiUrl = redocOptions.specUrl\n const { Redoc, createStore } = redoc || require('redoc')\n const store = await createStore(api, apiUrl, redocOptions)\n const sheet = new ServerStyleSheet()\n\n const error = console.error\n console.error = (...args: any) => {\n if (/defaultProps/.test(args[0])) return\n error(...args)\n }\n\n const html = renderToString(sheet.collectStyles(<Redoc store={store} />))\n const state = await store.toJS()\n const css = sheet.getStyleTags()\n\n const templateFileName = path.join(__dirname, '../static/redoc.hbs')\n const template = pkg.compile(fs.readFileSync(templateFileName).toString())\n return template({\n redocHTML: `\n <div id=\"redoc\">${html || ''}</div>\n <script>\n ${`const __redoc_state = ${sanitizeJSONString(JSON.stringify(state))};` || ''}\n\n var container = document.getElementById('redoc');\n Redoc.${'hydrate(__redoc_state, container)'};\n\n </script>`,\n redocHead:\n // biome-ignore lint/style/useTemplate: <explanation>\n `<script src=\"https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js\"></script>` + css,\n title: title || api.info.title || 'ReDoc documentation',\n disableGoogleFont,\n templateOptions,\n })\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -14,177 +14,14 @@ var getDirname = () => path.dirname(getFilename());
|
|
|
14
14
|
var __dirname = /* @__PURE__ */ getDirname();
|
|
15
15
|
|
|
16
16
|
// src/plugin.ts
|
|
17
|
-
import
|
|
18
|
-
import { PluginManager, createPlugin
|
|
19
|
-
import { camelCase
|
|
20
|
-
|
|
21
|
-
// ../swagger/src/plugin.ts
|
|
22
|
-
import path2 from "path";
|
|
23
|
-
import { createPlugin } from "@kubb/core";
|
|
24
|
-
import { camelCase } from "@kubb/core/transformers";
|
|
25
|
-
|
|
26
|
-
// ../swagger/src/utils/getSchemas.ts
|
|
27
|
-
function getSchemas({ oas, contentType, includes = ["schemas", "requestBodies", "responses"] }) {
|
|
28
|
-
const components = oas.getDefinition().components;
|
|
29
|
-
let schemas = {};
|
|
30
|
-
if (includes.includes("schemas")) {
|
|
31
|
-
schemas = {
|
|
32
|
-
...schemas,
|
|
33
|
-
...components?.schemas || {}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
const requestBodies = components?.requestBodies || {};
|
|
37
|
-
if (includes.includes("responses")) {
|
|
38
|
-
const responses = components?.responses || {};
|
|
39
|
-
Object.entries(responses).forEach(([name, response]) => {
|
|
40
|
-
if (response.content && !schemas[name]) {
|
|
41
|
-
const firstContentType = Object.keys(response.content)[0] || "application/json";
|
|
42
|
-
schemas[name] = response.content?.[contentType || firstContentType]?.schema;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
if (includes.includes("requestBodies")) {
|
|
47
|
-
Object.entries(requestBodies).forEach(([name, request]) => {
|
|
48
|
-
if (request.content && !schemas[name]) {
|
|
49
|
-
const firstContentType = Object.keys(request.content)[0] || "application/json";
|
|
50
|
-
schemas[name] = request.content?.[contentType || firstContentType]?.schema;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return schemas;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// ../swagger/src/utils/parseFromConfig.ts
|
|
58
|
-
import { resolve } from "path";
|
|
59
|
-
import { URLPath } from "@kubb/core/utils";
|
|
60
|
-
import { parse } from "@kubb/oas/parser";
|
|
61
|
-
import yaml from "@stoplight/yaml";
|
|
62
|
-
function parseFromConfig(config, options = {}) {
|
|
63
|
-
if ("data" in config.input) {
|
|
64
|
-
if (typeof config.input.data === "object") {
|
|
65
|
-
const api2 = JSON.parse(JSON.stringify(config.input.data));
|
|
66
|
-
return parse(api2, options);
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
const api2 = yaml.parse(config.input.data);
|
|
70
|
-
return parse(api2, options);
|
|
71
|
-
} catch (e) {
|
|
72
|
-
}
|
|
73
|
-
const api = JSON.parse(JSON.stringify(config.input.data));
|
|
74
|
-
return parse(api, options);
|
|
75
|
-
}
|
|
76
|
-
if (new URLPath(config.input.path).isURL) {
|
|
77
|
-
return parse(config.input.path, options);
|
|
78
|
-
}
|
|
79
|
-
return parse(resolve(config.root, config.input.path), options);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// ../swagger/src/plugin.ts
|
|
83
|
-
var pluginSwaggerName = "swagger";
|
|
84
|
-
var pluginSwagger = createPlugin((options) => {
|
|
85
|
-
const {
|
|
86
|
-
output = { path: "schemas", export: false },
|
|
87
|
-
experimentalFilter: filter,
|
|
88
|
-
experimentalSort: sort,
|
|
89
|
-
validate = true,
|
|
90
|
-
serverIndex = 0,
|
|
91
|
-
contentType
|
|
92
|
-
} = options;
|
|
93
|
-
const getOas = async ({ config, logger, formatOptions }) => {
|
|
94
|
-
try {
|
|
95
|
-
const oas = await parseFromConfig(config, formatOptions);
|
|
96
|
-
if (validate) {
|
|
97
|
-
await oas.valdiate();
|
|
98
|
-
}
|
|
99
|
-
return oas;
|
|
100
|
-
} catch (e) {
|
|
101
|
-
const error = e;
|
|
102
|
-
logger.emit("warning", error?.message);
|
|
103
|
-
return parseFromConfig(config);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
return {
|
|
107
|
-
name: pluginSwaggerName,
|
|
108
|
-
options,
|
|
109
|
-
api() {
|
|
110
|
-
const { config, logger } = this;
|
|
111
|
-
return {
|
|
112
|
-
getOas(formatOptions) {
|
|
113
|
-
return getOas({ config, logger, formatOptions });
|
|
114
|
-
},
|
|
115
|
-
async getSchemas({ includes } = {}) {
|
|
116
|
-
const oas = await this.getOas();
|
|
117
|
-
return getSchemas({ oas, contentType, includes });
|
|
118
|
-
},
|
|
119
|
-
async getBaseURL() {
|
|
120
|
-
const oasInstance = await this.getOas();
|
|
121
|
-
const baseURL = oasInstance.api.servers?.at(serverIndex)?.url;
|
|
122
|
-
return baseURL;
|
|
123
|
-
},
|
|
124
|
-
contentType
|
|
125
|
-
};
|
|
126
|
-
},
|
|
127
|
-
resolvePath(baseName) {
|
|
128
|
-
if (output === false) {
|
|
129
|
-
return void 0;
|
|
130
|
-
}
|
|
131
|
-
const root = path2.resolve(this.config.root, this.config.output.path);
|
|
132
|
-
return path2.resolve(root, output.path, baseName);
|
|
133
|
-
},
|
|
134
|
-
resolveName(name, type) {
|
|
135
|
-
return camelCase(name, { isFile: type === "file" });
|
|
136
|
-
},
|
|
137
|
-
async writeFile(source, writePath) {
|
|
138
|
-
if (!writePath.endsWith(".json") || !source) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
return this.fileManager.write(source, writePath, { sanity: false });
|
|
142
|
-
},
|
|
143
|
-
async buildStart() {
|
|
144
|
-
if (!output) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const oas = await getOas({
|
|
148
|
-
config: this.config,
|
|
149
|
-
logger: this.logger,
|
|
150
|
-
formatOptions: {
|
|
151
|
-
filterSet: filter,
|
|
152
|
-
sortSet: sort
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
await oas.dereference();
|
|
156
|
-
const schemas = getSchemas({ oas, contentType });
|
|
157
|
-
const mapSchema = async ([name, schema]) => {
|
|
158
|
-
const resolvedPath = this.resolvePath({
|
|
159
|
-
baseName: `${name}.json`,
|
|
160
|
-
pluginKey: this.plugin.key
|
|
161
|
-
});
|
|
162
|
-
const resvoledFileName = this.resolveName({
|
|
163
|
-
name: `${name}.json`,
|
|
164
|
-
pluginKey: [pluginSwaggerName],
|
|
165
|
-
type: "file"
|
|
166
|
-
});
|
|
167
|
-
if (!resolvedPath) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
await this.addFile({
|
|
171
|
-
path: resolvedPath,
|
|
172
|
-
baseName: resvoledFileName,
|
|
173
|
-
source: JSON.stringify(schema),
|
|
174
|
-
meta: {
|
|
175
|
-
pluginKey: this.plugin.key
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
};
|
|
179
|
-
const promises = Object.entries(schemas).map(mapSchema);
|
|
180
|
-
await Promise.all(promises);
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
});
|
|
17
|
+
import path3 from "path";
|
|
18
|
+
import { PluginManager, createPlugin } from "@kubb/core";
|
|
19
|
+
import { camelCase, trimExtName } from "@kubb/core/transformers";
|
|
20
|
+
import { pluginOasName } from "@kubb/plugin-oas";
|
|
184
21
|
|
|
185
22
|
// src/redoc.tsx
|
|
186
23
|
import fs from "fs";
|
|
187
|
-
import
|
|
24
|
+
import path2 from "path";
|
|
188
25
|
import pkg from "handlebars";
|
|
189
26
|
import { renderToString } from "react-dom/server";
|
|
190
27
|
import { ServerStyleSheet } from "styled-components";
|
|
@@ -213,7 +50,7 @@ async function getPageHTML(api, { title, disableGoogleFont, templateOptions, red
|
|
|
213
50
|
const html = renderToString(sheet.collectStyles(/* @__PURE__ */ jsx(Redoc, { store })));
|
|
214
51
|
const state = await store.toJS();
|
|
215
52
|
const css = sheet.getStyleTags();
|
|
216
|
-
const templateFileName =
|
|
53
|
+
const templateFileName = path2.join(__dirname, "../static/redoc.hbs");
|
|
217
54
|
const template = pkg.compile(fs.readFileSync(templateFileName).toString());
|
|
218
55
|
return template({
|
|
219
56
|
redocHTML: `
|
|
@@ -237,7 +74,7 @@ async function getPageHTML(api, { title, disableGoogleFont, templateOptions, red
|
|
|
237
74
|
|
|
238
75
|
// src/plugin.ts
|
|
239
76
|
var pluginRedocName = "plugin-redoc";
|
|
240
|
-
var pluginRedoc =
|
|
77
|
+
var pluginRedoc = createPlugin((options) => {
|
|
241
78
|
const { output = { path: "docs.html" } } = options;
|
|
242
79
|
return {
|
|
243
80
|
name: pluginRedocName,
|
|
@@ -245,13 +82,13 @@ var pluginRedoc = createPlugin2((options) => {
|
|
|
245
82
|
name: trimExtName(output.path),
|
|
246
83
|
baseURL: void 0
|
|
247
84
|
},
|
|
248
|
-
pre: [
|
|
85
|
+
pre: [pluginOasName],
|
|
249
86
|
resolvePath(baseName) {
|
|
250
|
-
const root =
|
|
251
|
-
return
|
|
87
|
+
const root = path3.resolve(this.config.root, this.config.output.path);
|
|
88
|
+
return path3.resolve(root, baseName);
|
|
252
89
|
},
|
|
253
90
|
resolveName(name, type) {
|
|
254
|
-
return
|
|
91
|
+
return camelCase(name, { isFile: type === "file" });
|
|
255
92
|
},
|
|
256
93
|
async writeFile(source, writePath) {
|
|
257
94
|
if (!writePath.endsWith(".ts") || !source) {
|
|
@@ -260,12 +97,12 @@ var pluginRedoc = createPlugin2((options) => {
|
|
|
260
97
|
return this.fileManager.write(source, writePath, { sanity: false });
|
|
261
98
|
},
|
|
262
99
|
async buildStart() {
|
|
263
|
-
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [
|
|
100
|
+
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
264
101
|
const oas = await swaggerPlugin.api.getOas();
|
|
265
102
|
await oas.dereference();
|
|
266
|
-
const root =
|
|
103
|
+
const root = path3.resolve(this.config.root, this.config.output.path);
|
|
267
104
|
const pageHTML = await getPageHTML(oas.api);
|
|
268
|
-
await this.fileManager.write(pageHTML,
|
|
105
|
+
await this.fileManager.write(pageHTML, path3.resolve(root, output.path || "./docs.html"));
|
|
269
106
|
}
|
|
270
107
|
};
|
|
271
108
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.0.2_@microsoft+api-extractor@7.43.3_@types+node@20.12.11__postcss@8.4.38_ts-node@10.9._m3ved7kneisj6uq6vsf2lw6r5q/node_modules/tsup/assets/esm_shims.js","../src/plugin.ts","../../swagger/src/plugin.ts","../../swagger/src/utils/getSchemas.ts","../../swagger/src/utils/parseFromConfig.ts","../src/redoc.tsx"],"sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import path from 'node:path'\n\nimport { PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, trimExtName } from '@kubb/core/transformers'\nimport { pluginSwaggerName } from '@kubb/swagger'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginSwagger } from '@kubb/swagger'\nimport { getPageHTML } from './redoc.tsx'\nimport type { PluginRedoc } from './types.ts'\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 options: {\n name: trimExtName(output.path),\n baseURL: undefined,\n },\n pre: [pluginSwaggerName],\n resolvePath(baseName) {\n const root = path.resolve(this.config.root, this.config.output.path)\n\n return path.resolve(root, baseName)\n },\n resolveName(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n async writeFile(source, writePath) {\n if (!writePath.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(source, writePath, { sanity: false })\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginSwagger>] = PluginManager.getDependedPlugins<PluginSwagger>(this.plugins, [pluginSwaggerName])\n const oas = await swaggerPlugin.api.getOas()\n\n await oas.dereference()\n\n const root = path.resolve(this.config.root, this.config.output.path)\n const pageHTML = await getPageHTML(oas.api)\n\n await this.fileManager.write(pageHTML, path.resolve(root, output.path || './docs.html'))\n },\n }\n})\n","import path from 'node:path'\n\nimport { createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\n\nimport { getSchemas } from './utils/getSchemas.ts'\n\nimport type { Config } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport type { Oas, OasTypes } from '@kubb/oas'\nimport type { FormatOptions } from '@kubb/oas/parser'\nimport type { PluginSwagger } from './types.ts'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nexport const pluginSwaggerName = 'swagger' satisfies PluginSwagger['name']\n\nexport const pluginSwagger = createPlugin<PluginSwagger>((options) => {\n const {\n output = { path: 'schemas', export: false },\n experimentalFilter: filter,\n experimentalSort: sort,\n validate = true,\n serverIndex = 0,\n contentType,\n } = options\n\n const getOas = async ({ config, logger, formatOptions }: { config: Config; logger: Logger; formatOptions?: FormatOptions }): Promise<Oas> => {\n try {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n const oas = await parseFromConfig(config, formatOptions)\n\n if (validate) {\n await oas.valdiate()\n }\n\n return oas\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n return parseFromConfig(config)\n }\n }\n\n return {\n name: pluginSwaggerName,\n options,\n\n api() {\n const { config, logger } = this\n\n return {\n getOas(formatOptions) {\n return getOas({ config, logger, formatOptions })\n },\n async getSchemas({ includes } = {}) {\n const oas = await this.getOas()\n return getSchemas({ oas, contentType, includes })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n const baseURL = oasInstance.api.servers?.at(serverIndex)?.url\n return baseURL\n },\n contentType,\n }\n },\n resolvePath(baseName) {\n if (output === false) {\n return undefined\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n async writeFile(source, writePath) {\n if (!writePath.endsWith('.json') || !source) {\n return\n }\n\n return this.fileManager.write(source, writePath, { sanity: false })\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n formatOptions: {\n filterSet: filter,\n sortSet: sort,\n },\n })\n await oas.dereference()\n const schemas = getSchemas({ oas, contentType })\n\n const mapSchema = async ([name, schema]: [string, OasTypes.SchemaObject]) => {\n const resolvedPath = this.resolvePath({\n baseName: `${name}.json`,\n pluginKey: this.plugin.key,\n })\n\n const resvoledFileName = this.resolveName({\n name: `${name}.json`,\n pluginKey: [pluginSwaggerName],\n type: 'file',\n }) as `${string}.json`\n\n if (!resolvedPath) {\n return\n }\n\n await this.addFile({\n path: resolvedPath,\n baseName: resvoledFileName,\n source: JSON.stringify(schema),\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n }\n\n const promises = Object.entries(schemas).map(mapSchema)\n await Promise.all(promises)\n },\n }\n})\n","import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\nexport type GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n}\n\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'] }: GetSchemasProps): Record<string, OasTypes.SchemaObject> {\n const components = oas.getDefinition().components\n\n let schemas: Record<string, OasTypes.SchemaObject> = {}\n\n if (includes.includes('schemas')) {\n schemas = {\n ...schemas,\n ...((components?.schemas as Record<string, OasTypes.SchemaObject>) || {}),\n }\n }\n\n const requestBodies = components?.requestBodies || {}\n if (includes.includes('responses')) {\n const responses = components?.responses || {}\n\n Object.entries(responses).forEach(([name, response]: [string, OasTypes.ResponseObject]) => {\n if (response.content && !schemas[name]) {\n const firstContentType = Object.keys(response.content)[0] || 'application/json'\n schemas[name] = response.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n if (includes.includes('requestBodies')) {\n Object.entries(requestBodies).forEach(([name, request]: [string, OasTypes.RequestBodyObject]) => {\n if (request.content && !schemas[name]) {\n const firstContentType = Object.keys(request.content)[0] || 'application/json'\n schemas[name] = request.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n return schemas\n}\n","import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { type FormatOptions, parse } from '@kubb/oas/parser'\n\nimport type { Config } from '@kubb/core'\nimport type { Oas, OasTypes } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, options: FormatOptions = {}): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, options)\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, options)\n } catch (e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, options)\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, options)\n }\n\n return parse(resolve(config.root, config.input.path), options)\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport type { OasTypes } from '@kubb/oas'\nimport pkg from 'handlebars'\nimport { renderToString } from 'react-dom/server'\nimport { ServerStyleSheet } from 'styled-components'\nimport redoc from 'redoc'\n\ntype BuildDocsOptions = {\n title?: string\n disableGoogleFont?: boolean\n templateOptions?: any\n redocOptions?: any\n}\n\n// see http://www.thespanner.co.uk/2011/07/25/the-json-specification-is-now-wrong/\nfunction escapeClosingScriptTag(str: string): string {\n return str.replace(/<\\/script>/g, '<\\\\/script>')\n}\n\n// see http://www.thespanner.co.uk/2011/07/25/the-json-specification-is-now-wrong/\nfunction escapeUnicode(str: string): string {\n // biome-ignore lint/style/useTemplate: <explanation>\n return str.replace(/\\u2028|\\u2029/g, (m) => '\\\\u202' + (m === '\\u2028' ? '8' : '9'))\n}\n\nfunction sanitizeJSONString(str: string): string {\n return escapeClosingScriptTag(escapeUnicode(str))\n}\n\nexport async function getPageHTML(api: OasTypes.OASDocument, { title, disableGoogleFont, templateOptions, redocOptions = {} }: BuildDocsOptions = {}) {\n const apiUrl = redocOptions.specUrl\n const { Redoc, createStore } = redoc || require('redoc')\n const store = await createStore(api, apiUrl, redocOptions)\n const sheet = new ServerStyleSheet()\n\n const error = console.error\n console.error = (...args: any) => {\n if (/defaultProps/.test(args[0])) return\n error(...args)\n }\n\n const html = renderToString(sheet.collectStyles(<Redoc store={store} />))\n const state = await store.toJS()\n const css = sheet.getStyleTags()\n\n const templateFileName = path.join(__dirname, '../static/redoc.hbs')\n const template = pkg.compile(fs.readFileSync(templateFileName).toString())\n return template({\n redocHTML: `\n <div id=\"redoc\">${html || ''}</div>\n <script>\n ${`const __redoc_state = ${sanitizeJSONString(JSON.stringify(state))};` || ''}\n\n var container = document.getElementById('redoc');\n Redoc.${'hydrate(__redoc_state, container)'};\n\n </script>`,\n redocHead:\n // biome-ignore lint/style/useTemplate: <explanation>\n `<script src=\"https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js\"></script>` + css,\n title: title || api.info.title || 'ReDoc documentation',\n disableGoogleFont,\n templateOptions,\n })\n}\n"],"mappings":";;;;;;;;;AACA,SAAS,qBAAqB;AAC9B,OAAO,UAAU;AAEjB,IAAM,cAAc,MAAM,cAAc,YAAY,GAAG;AACvD,IAAM,aAAa,MAAM,KAAK,QAAQ,YAAY,CAAC;AAE5C,IAAM,YAA4B,2BAAW;;;ACPpD,OAAOA,WAAU;AAEjB,SAAS,eAAe,gBAAAC,qBAAoB;AAC5C,SAAS,aAAAC,YAAW,mBAAmB;;;ACHvC,OAAOC,WAAU;AAEjB,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;;;ACOnB,SAAS,WAAW,EAAE,KAAK,aAAa,WAAW,CAAC,WAAW,iBAAiB,WAAW,EAAE,GAA2D;AAC7J,QAAM,aAAa,IAAI,cAAc,EAAE;AAEvC,MAAI,UAAiD,CAAC;AAEtD,MAAI,SAAS,SAAS,SAAS,GAAG;AAChC,cAAU;AAAA,MACR,GAAG;AAAA,MACH,GAAK,YAAY,WAAqD,CAAC;AAAA,IACzE;AAAA,EACF;AAEA,QAAM,gBAAgB,YAAY,iBAAiB,CAAC;AACpD,MAAI,SAAS,SAAS,WAAW,GA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O,MAAM,KAAK,OAAO,OAAO,IAAI;AACnE,YAAM,WAAW,MAAM,YAAY,IAAI,GAAG;AAE1C,YAAM,KAAK,YAAY,MAAM,UAAUA,MAAK,QAAQ,MAAM,OAAO,QAAQ,aAAa,CAAC;AAAA,IACzF;AAAA,EACF;AACF,CAAC;","names":["path","createPlugin","camelCase","path","api","path","path","createPlugin","path","camelCase"]}
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.0.2_@microsoft+api-extractor@7.43.3_@types+node@20.12.11__postcss@8.4.38_ts-node@10.9._m3ved7kneisj6uq6vsf2lw6r5q/node_modules/tsup/assets/esm_shims.js","../src/plugin.ts","../src/redoc.tsx"],"sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import path from 'node:path'\n\nimport { PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, trimExtName } from '@kubb/core/transformers'\nimport { pluginOasName } from '@kubb/plugin-oas'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { getPageHTML } from './redoc.tsx'\nimport type { PluginRedoc } from './types.ts'\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 options: {\n name: trimExtName(output.path),\n baseURL: undefined,\n },\n pre: [pluginOasName],\n resolvePath(baseName) {\n const root = path.resolve(this.config.root, this.config.output.path)\n\n return path.resolve(root, baseName)\n },\n resolveName(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n async writeFile(source, writePath) {\n if (!writePath.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(source, writePath, { sanity: false })\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n const oas = await swaggerPlugin.api.getOas()\n\n await oas.dereference()\n\n const root = path.resolve(this.config.root, this.config.output.path)\n const pageHTML = await getPageHTML(oas.api)\n\n await this.fileManager.write(pageHTML, path.resolve(root, output.path || './docs.html'))\n },\n }\n})\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport type { OasTypes } from '@kubb/oas'\nimport pkg from 'handlebars'\nimport { renderToString } from 'react-dom/server'\nimport { ServerStyleSheet } from 'styled-components'\nimport redoc from 'redoc'\n\ntype BuildDocsOptions = {\n title?: string\n disableGoogleFont?: boolean\n templateOptions?: any\n redocOptions?: any\n}\n\n// see http://www.thespanner.co.uk/2011/07/25/the-json-specification-is-now-wrong/\nfunction escapeClosingScriptTag(str: string): string {\n return str.replace(/<\\/script>/g, '<\\\\/script>')\n}\n\n// see http://www.thespanner.co.uk/2011/07/25/the-json-specification-is-now-wrong/\nfunction escapeUnicode(str: string): string {\n // biome-ignore lint/style/useTemplate: <explanation>\n return str.replace(/\\u2028|\\u2029/g, (m) => '\\\\u202' + (m === '\\u2028' ? '8' : '9'))\n}\n\nfunction sanitizeJSONString(str: string): string {\n return escapeClosingScriptTag(escapeUnicode(str))\n}\n\nexport async function getPageHTML(api: OasTypes.OASDocument, { title, disableGoogleFont, templateOptions, redocOptions = {} }: BuildDocsOptions = {}) {\n const apiUrl = redocOptions.specUrl\n const { Redoc, createStore } = redoc || require('redoc')\n const store = await createStore(api, apiUrl, redocOptions)\n const sheet = new ServerStyleSheet()\n\n const error = console.error\n console.error = (...args: any) => {\n if (/defaultProps/.test(args[0])) return\n error(...args)\n }\n\n const html = renderToString(sheet.collectStyles(<Redoc store={store} />))\n const state = await store.toJS()\n const css = sheet.getStyleTags()\n\n const templateFileName = path.join(__dirname, '../static/redoc.hbs')\n const template = pkg.compile(fs.readFileSync(templateFileName).toString())\n return template({\n redocHTML: `\n <div id=\"redoc\">${html || ''}</div>\n <script>\n ${`const __redoc_state = ${sanitizeJSONString(JSON.stringify(state))};` || ''}\n\n var container = document.getElementById('redoc');\n Redoc.${'hydrate(__redoc_state, container)'};\n\n </script>`,\n redocHead:\n // biome-ignore lint/style/useTemplate: <explanation>\n `<script src=\"https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js\"></script>` + css,\n title: title || api.info.title || 'ReDoc documentation',\n disableGoogleFont,\n templateOptions,\n })\n}\n"],"mappings":";;;;;;;;;AACA,SAAS,qBAAqB;AAC9B,OAAO,UAAU;AAEjB,IAAM,cAAc,MAAM,cAAc,YAAY,GAAG;AACvD,IAAM,aAAa,MAAM,KAAK,QAAQ,YAAY,CAAC;AAE5C,IAAM,YAA4B,2BAAW;;;ACPpD,OAAOA,WAAU;AAEjB,SAAS,eAAe,oBAAoB;AAC5C,SAAS,WAAW,mBAAmB;AACvC,SAAS,qBAAqB;;;ACJ9B,OAAO,QAAQ;AACf,OAAOC,WAAU;AAEjB,OAAO,SAAS;AAChB,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,OAAO,WAAW;AAoCgC;AA1BlD,SAAS,uBAAuB,KAAqB;AACnD,SAAO,IAAI,QAAQ,eAAe,aAAa;AACjD;AAGA,SAAS,cAAc,KAAqB;AAE1C,SAAO,IAAI,QAAQ,kBAAkB,CAAC,MAAM,YAAY,MAAM,WAAW,MAAM,IAAI;AACrF;AAEA,SAAS,mBAAmB,KAAqB;AAC/C,SAAO,uBAAuB,cAAc,GAAG,CAAC;AAClD;AAEA,eAAsB,YAAY,KAA2B,EAAE,OAAO,mBAAmB,iBAAiB,eAAe,CAAC,EAAE,IAAsB,CAAC,GAAG;AACpJ,QAAM,SAAS,aAAa;AAC5B,QAAM,EAAE,OAAO,YAAY,IAAI,SAAS,UAAQ,OAAO;AACvD,QAAM,QAAQ,MAAM,YAAY,KAAK,QAAQ,YAAY;AACzD,QAAM,QAAQ,IAAI,iBAAiB;AAEnC,Q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U,QAAQ,WAAW;AACjC,UAAI,CAAC,UAAU,SAAS,KAAK,KAAK,CAAC,QAAQ;AACzC;AAAA,MACF;AAEA,aAAO,KAAK,YAAY,MAAM,QAAQ,WAAW,EAAE,QAAQ,MAAM,CAAC;AAAA,IACpE;AAAA,IACA,MAAM,aAAa;AACjB,YAAM,CAAC,aAAa,IAAyB,cAAc,mBAA8B,KAAK,SAAS,CAAC,aAAa,CAAC;AACtH,YAAM,MAAM,MAAM,cAAc,IAAI,OAAO;AAE3C,YAAM,IAAI,YAAY;AAEtB,YAAM,OAAOA,MAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,IAAI;AACnE,YAAM,WAAW,MAAM,YAAY,IAAI,GAAG;AAE1C,YAAM,KAAK,YAAY,MAAM,UAAUA,MAAK,QAAQ,MAAM,OAAO,QAAQ,aAAa,CAAC;AAAA,IACzF;AAAA,EACF;AACF,CAAC;","names":["path","path","path"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-redoc",
|
|
3
|
-
"version": "2.18.
|
|
3
|
+
"version": "2.18.3",
|
|
4
4
|
"description": "Beautiful docs with Redoc",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -41,30 +41,27 @@
|
|
|
41
41
|
"!/**/__tests__/**"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@stoplight/yaml": "^4.3.0",
|
|
45
44
|
"handlebars": "^4.7.8",
|
|
46
45
|
"mobx": "^6.12.3",
|
|
47
46
|
"react": "^18.3.1",
|
|
48
47
|
"react-dom": "^18.3.1",
|
|
49
48
|
"redoc": "^2.1.4",
|
|
50
|
-
"remeda": "^1.61.0",
|
|
51
49
|
"styled-components": "^6.1.10",
|
|
52
|
-
"@kubb/core": "2.18.
|
|
53
|
-
"@kubb/oas": "2.18.
|
|
54
|
-
"@kubb/
|
|
50
|
+
"@kubb/core": "2.18.3",
|
|
51
|
+
"@kubb/oas": "2.18.3",
|
|
52
|
+
"@kubb/plugin-oas": "2.18.3"
|
|
55
53
|
},
|
|
56
54
|
"devDependencies": {
|
|
57
55
|
"@types/react": "^18.3.1",
|
|
58
56
|
"@types/react-dom": "^18.3.0",
|
|
59
|
-
"react": "^18.3.1",
|
|
60
57
|
"tsup": "^8.0.2",
|
|
61
58
|
"typescript": "^5.4.5",
|
|
62
|
-
"@kubb/config-biome": "2.18.
|
|
63
|
-
"@kubb/config-ts": "2.18.
|
|
64
|
-
"@kubb/config-tsup": "2.18.
|
|
59
|
+
"@kubb/config-biome": "2.18.3",
|
|
60
|
+
"@kubb/config-ts": "2.18.3",
|
|
61
|
+
"@kubb/config-tsup": "2.18.3"
|
|
65
62
|
},
|
|
66
63
|
"peerDependencies": {
|
|
67
|
-
"@kubb/react": "2.18.
|
|
64
|
+
"@kubb/react": "2.18.3"
|
|
68
65
|
},
|
|
69
66
|
"engines": {
|
|
70
67
|
"node": ">=18",
|
package/src/plugin.ts
CHANGED
|
@@ -2,10 +2,10 @@ import path from 'node:path'
|
|
|
2
2
|
|
|
3
3
|
import { PluginManager, createPlugin } from '@kubb/core'
|
|
4
4
|
import { camelCase, trimExtName } from '@kubb/core/transformers'
|
|
5
|
-
import {
|
|
5
|
+
import { pluginOasName } from '@kubb/plugin-oas'
|
|
6
6
|
|
|
7
7
|
import type { Plugin } from '@kubb/core'
|
|
8
|
-
import type {
|
|
8
|
+
import type { PluginOas } from '@kubb/plugin-oas'
|
|
9
9
|
import { getPageHTML } from './redoc.tsx'
|
|
10
10
|
import type { PluginRedoc } from './types.ts'
|
|
11
11
|
|
|
@@ -20,7 +20,7 @@ export const pluginRedoc = createPlugin<PluginRedoc>((options) => {
|
|
|
20
20
|
name: trimExtName(output.path),
|
|
21
21
|
baseURL: undefined,
|
|
22
22
|
},
|
|
23
|
-
pre: [
|
|
23
|
+
pre: [pluginOasName],
|
|
24
24
|
resolvePath(baseName) {
|
|
25
25
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
26
26
|
|
|
@@ -37,7 +37,7 @@ export const pluginRedoc = createPlugin<PluginRedoc>((options) => {
|
|
|
37
37
|
return this.fileManager.write(source, writePath, { sanity: false })
|
|
38
38
|
},
|
|
39
39
|
async buildStart() {
|
|
40
|
-
const [swaggerPlugin]: [Plugin<
|
|
40
|
+
const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])
|
|
41
41
|
const oas = await swaggerPlugin.api.getOas()
|
|
42
42
|
|
|
43
43
|
await oas.dereference()
|