OpenAPI: Fix empty directory detection

This commit is contained in:
Fuma Nama
2025-05-02 21:19:58 +08:00
parent 16c7566c37
commit a7ef446231
6 changed files with 11 additions and 11 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-openapi': patch
---
Fix empty directory detection
+1 -1
View File
@@ -2,5 +2,5 @@
"title": "OpenAPI Example",
"description": "A demo for Fumadocs OpenAPI",
"root": true,
"icon": "Rocket"
"pages": ["index", "...(generated)"]
}
+3 -8
View File
@@ -2,18 +2,13 @@ import * as OpenAPI from 'fumadocs-openapi';
import { rimraf } from 'rimraf';
export async function generateDocs() {
await rimraf('./content/docs/openapi', {
filter(v) {
return !v.endsWith('index.mdx') && !v.endsWith('meta.json');
},
});
await rimraf('./content/docs/openapi/(generated)');
await Promise.all([
OpenAPI.generateFiles({
input: ['./museum.yaml'],
output: './content/docs/openapi',
input: ['./content/docs/openapi/museum.yaml'],
output: './content/docs/openapi/(generated)',
per: 'operation',
groupBy: 'tag',
}),
]);
}
+1 -1
View File
@@ -163,7 +163,7 @@ export async function generateFiles(options: Config): Promise<void> {
path.dirname(item) === path.dirname(outputPath),
);
if (!isSharedDir && path.dirname(outputPath).length > 0) {
if (!isSharedDir && path.dirname(outputPath) !== '.') {
outputPath = path.join(path.dirname(outputPath) + '.mdx');
}
@@ -1,7 +1,7 @@
import type { DereferenceMap, Document } from '@/types';
import type { NoReference } from '@/utils/schema';
import type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
import { load, dereference, upgrade } from '@scalar/openapi-parser';
import { dereference, load, upgrade } from '@scalar/openapi-parser';
import { fetchUrls } from '@scalar/openapi-parser/plugins/fetch-urls';
import { readFiles } from '@scalar/openapi-parser/plugins/read-files';