fumadocs-openapi 1.0.0 → 1.1.0
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/bin.js +2 -2
- package/dist/{chunk-6NCGY6WV.js → chunk-COCHYFC7.js} +8 -6
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/dist/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
generateFiles
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-COCHYFC7.js";
|
|
5
5
|
|
|
6
6
|
// src/bin.ts
|
|
7
7
|
import { resolve } from "node:path";
|
|
@@ -13,7 +13,7 @@ async function main() {
|
|
|
13
13
|
}
|
|
14
14
|
async function readConfig(name = "openapi.config.js") {
|
|
15
15
|
const path = resolve(process.cwd(), name);
|
|
16
|
-
const result = await import(pathToFileURL(path).
|
|
16
|
+
const result = await import(pathToFileURL(path).href);
|
|
17
17
|
if (typeof result.default !== "object")
|
|
18
18
|
throw new Error("Invalid configuration");
|
|
19
19
|
return result.default;
|
|
@@ -491,21 +491,23 @@ function buildOperation(method, operation) {
|
|
|
491
491
|
|
|
492
492
|
// src/generate-file.ts
|
|
493
493
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
494
|
-
import {
|
|
494
|
+
import { dirname, join, parse } from "node:path";
|
|
495
|
+
import fg from "fast-glob";
|
|
495
496
|
async function generateFiles({
|
|
496
497
|
input,
|
|
497
498
|
output,
|
|
498
499
|
name: nameFn,
|
|
499
500
|
per = "file",
|
|
500
|
-
render: render2
|
|
501
|
+
render: render2,
|
|
502
|
+
cwd = process.cwd()
|
|
501
503
|
}) {
|
|
502
|
-
const outputDir =
|
|
504
|
+
const outputDir = join(cwd, output);
|
|
503
505
|
const options = {
|
|
504
506
|
render: render2
|
|
505
507
|
};
|
|
508
|
+
const resolvedInputs = await fg.glob(input, { absolute: true, cwd });
|
|
506
509
|
await Promise.all(
|
|
507
|
-
|
|
508
|
-
const path = resolve(file);
|
|
510
|
+
resolvedInputs.map(async (path) => {
|
|
509
511
|
let filename = parse(path).name;
|
|
510
512
|
filename = nameFn?.("file", filename) ?? filename;
|
|
511
513
|
if (per === "file") {
|
|
@@ -518,7 +520,7 @@ async function generateFiles({
|
|
|
518
520
|
results.forEach((result) => {
|
|
519
521
|
let tagName = result.tag;
|
|
520
522
|
tagName = nameFn?.("tag", tagName) ?? tagName.toLowerCase().replace(/\s+/g, "-");
|
|
521
|
-
const outPath = join(outputDir, `${
|
|
523
|
+
const outPath = join(outputDir, filename, `${tagName}.mdx`);
|
|
522
524
|
write(outPath, result.content);
|
|
523
525
|
console.log(`Generated: ${outPath}`);
|
|
524
526
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ interface Config {
|
|
|
26
26
|
/**
|
|
27
27
|
* Schema files
|
|
28
28
|
*/
|
|
29
|
-
input: string[];
|
|
29
|
+
input: string[] | string;
|
|
30
30
|
/**
|
|
31
31
|
* Output directory
|
|
32
32
|
*/
|
|
@@ -47,8 +47,9 @@ interface Config {
|
|
|
47
47
|
* Modify output file
|
|
48
48
|
*/
|
|
49
49
|
render?: NonNullable<GenerateOptions['render']>;
|
|
50
|
+
cwd?: string;
|
|
50
51
|
}
|
|
51
|
-
declare function generateFiles({ input, output, name: nameFn, per, render, }: Config): Promise<void>;
|
|
52
|
+
declare function generateFiles({ input, output, name: nameFn, per, render, cwd, }: Config): Promise<void>;
|
|
52
53
|
|
|
53
54
|
interface RouteInformation {
|
|
54
55
|
path: string;
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
7
7
|
"Docs"
|
|
8
8
|
],
|
|
9
9
|
"homepage": "https://fumadocs.vercel.app",
|
|
10
|
-
"repository": "github:fuma-nama/
|
|
10
|
+
"repository": "github:fuma-nama/fumadocs",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Fuma Nama",
|
|
13
13
|
"type": "module",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
24
|
+
"fast-glob": "^3.3.1",
|
|
24
25
|
"json-schema-to-typescript": "^13.1.1",
|
|
25
26
|
"openapi-sampler": "^1.4.0"
|
|
26
27
|
},
|
|
@@ -39,7 +40,6 @@
|
|
|
39
40
|
"clean": "rimraf dist",
|
|
40
41
|
"dev": "tsup --watch",
|
|
41
42
|
"lint": "eslint .",
|
|
42
|
-
"test": "vitest",
|
|
43
43
|
"types:check": "tsc --noEmit"
|
|
44
44
|
}
|
|
45
45
|
}
|