Merge pull request #1465 from mrzmyr/feat/throw-when-input-not-found

feat: throw when input not found
This commit is contained in:
Moritz
2025-02-22 21:27:46 +08:00
committed by GitHub
parent 090edb1f5b
commit 3d211f3f34
3 changed files with 40 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-openapi': minor
---
throw error, when input file is not found
+8
View File
@@ -75,6 +75,14 @@ export async function generateFiles(options: Config): Promise<void> {
...urlInputs,
];
if (resolvedInputs.length === 0) {
throw new Error(
`No input files found. Tried resolving: ${
typeof input === 'string' ? input : input.join(', ')
}`,
);
}
function getOutputPaths(result: GeneratePageOutput): string[] {
let file;
+27
View File
@@ -84,6 +84,33 @@ describe('Generate documents', () => {
expect(fs.mkdir).toBeCalledWith(join(cwd, './out'), expect.anything());
});
test('Generate Files - throws error when no input files found', async () => {
await expect(
generateFiles({
input: ['./fixtures/non-existent-*.yaml'],
output: './out',
per: 'file',
cwd,
}),
).rejects.toThrow(
'No input files found. Tried resolving: ./fixtures/non-existent-*.yaml',
);
await expect(
generateFiles({
input: [
'./fixtures/non-existent-1.yaml',
'./fixtures/non-existent-2.yaml',
],
output: './out',
per: 'file',
cwd,
}),
).rejects.toThrow(
'No input files found. Tried resolving: ./fixtures/non-existent-1.yaml, ./fixtures/non-existent-2.yaml',
);
});
test('Generate Files - groupBy tag per operation', async () => {
await generateFiles({
input: ['./fixtures/products.yaml'],