OpenAPI: Change generated file paths for documents

This commit is contained in:
Fuma Nama
2025-04-24 15:01:03 +08:00
parent 4dbb7fb7de
commit bd280c8088
3 changed files with 12 additions and 18 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-openapi': patch
---
Change generated file paths for documents
+4 -6
View File
@@ -90,12 +90,10 @@ export async function generateFiles(options: Config): Promise<void> {
if (result.pathItem.summary) {
file = getFilename(result.pathItem.summary);
} else if (result.type === 'operation') {
file = result.operation.operationId
? getFilename(result.operation.operationId)
: join(
getOutputPathFromRoute(result.item.path),
result.item.method.toLowerCase(),
);
file = join(
getOutputPathFromRoute(result.item.path),
result.item.method.toLowerCase(),
);
} else {
file = getFilename(result.item.name);
}
+3 -12
View File
@@ -125,26 +125,17 @@ describe('Generate documents', () => {
expect(fs.writeFile).toBeCalledTimes(3);
expect(fs.writeFile).toBeCalledWith(
join(cwd, './out/products/get-product-details.mdx'),
join(cwd, './out/products/products/get.mdx'),
expect.anything(),
);
expect(fs.writeFile).toBeCalledWith(
join(cwd, './out/products/get-inventory-for-product.mdx'),
join(cwd, './out/inventory/inventory/get.mdx'),
expect.anything(),
);
expect(fs.writeFile).toBeCalledWith(
join(cwd, './out/inventory/get-inventory-for-product.mdx'),
expect.anything(),
);
expect(fs.mkdir).toBeCalledWith(
join(cwd, './out/inventory'),
expect.anything(),
);
expect(fs.mkdir).toBeCalledWith(
join(cwd, './out/products'),
join(cwd, './out/products/inventory/get.mdx'),
expect.anything(),
);
});