fix swagger json
This commit is contained in:
parent
bc47bca6b5
commit
ca698e1c8a
12
src/main.ts
12
src/main.ts
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||||
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
import { NestFactory } from '@nestjs/core';
|
import { NestFactory } from '@nestjs/core';
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
import { ValidationPipe, Logger } from '@nestjs/common';
|
import { ValidationPipe, Logger } from '@nestjs/common';
|
||||||
@ -27,12 +29,18 @@ async function bootstrap() {
|
|||||||
.build();
|
.build();
|
||||||
const document = SwaggerModule.createDocument(app, config);
|
const document = SwaggerModule.createDocument(app, config);
|
||||||
SwaggerModule.setup('api-docs', app, document);
|
SwaggerModule.setup('api-docs', app, document);
|
||||||
app.enableCors({ origin: '*' })
|
app.enableCors({ origin: '*' });
|
||||||
|
app.getHttpAdapter().get('/api/swagger-json', (req, res) => {
|
||||||
|
res.json(document);
|
||||||
|
});
|
||||||
|
|
||||||
const port = process.env.PORT || 3000;
|
const port = process.env.PORT || 3000;
|
||||||
await app.listen(port);
|
await app.listen(port);
|
||||||
|
|
||||||
logger.log(`Application running on http://localhost:${port}`);
|
logger.log(`Application running on http://localhost:${port}`);
|
||||||
logger.log(`Swagger documentation available at http://localhost:${port}/api/docs`);
|
logger.log(
|
||||||
|
`Swagger documentation available at http://localhost:${port}/api-docs`,
|
||||||
|
);
|
||||||
|
console.log(`Swagger docs: http://localhost:${port}/api/swagger-json`);
|
||||||
}
|
}
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user