fix(api): swagger docs not all endpoints listed
This commit is contained in:
parent
9045eedf9c
commit
c39d0fb14b
1 changed files with 3 additions and 31 deletions
|
@ -1,36 +1,8 @@
|
||||||
import {
|
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||||
OpenAPIRegistry,
|
|
||||||
OpenApiGeneratorV3,
|
|
||||||
} from '@asteasolutions/zod-to-openapi';
|
|
||||||
|
|
||||||
export const registry = new OpenAPIRegistry();
|
export const registry = new OpenAPIRegistry();
|
||||||
|
import swaggerFile from '@/generated/swagger.json';
|
||||||
|
|
||||||
export const getApiDocs = async () => {
|
export const getApiDocs = async () => {
|
||||||
const swaggerFiles = require.context('../app', true, /swagger\.ts$/);
|
return swaggerFile;
|
||||||
|
|
||||||
swaggerFiles
|
|
||||||
.keys()
|
|
||||||
.sort((a, b) => b.length - a.length)
|
|
||||||
.forEach((file) => {
|
|
||||||
console.log(`Registering Swagger file: ${file}`);
|
|
||||||
swaggerFiles(file).default?.(registry);
|
|
||||||
});
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
||||||
require('@/app/api/validation');
|
|
||||||
|
|
||||||
try {
|
|
||||||
const generator = new OpenApiGeneratorV3(registry.definitions);
|
|
||||||
const spec = generator.generateDocument({
|
|
||||||
openapi: '3.0.0',
|
|
||||||
info: {
|
|
||||||
version: '1.0.0',
|
|
||||||
title: 'MeetUP',
|
|
||||||
description: 'API documentation for MeetUP application',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return spec;
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error generating API docs:', error);
|
|
||||||
throw new Error('Failed to generate API documentation');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue