-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dependabot/npm_and_yarn/esbuild-0.25.0' of github.com:e…
…ver-co/ever-gauzy into dependabot/npm_and_yarn/esbuild-0.25.0
- Loading branch information
Showing
7 changed files
with
63 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { INestApplication } from '@nestjs/common'; | ||
import { SwaggerModule, DocumentBuilder, SwaggerDocumentOptions, SwaggerCustomOptions } from '@nestjs/swagger'; | ||
|
||
/** | ||
* Sets up and configures Swagger API documentation for the given NestJS application. | ||
* | ||
* This function creates a Swagger configuration using the DocumentBuilder by setting the title, | ||
* description, version, and enabling bearer authentication. It then generates the Swagger document | ||
* with any additional options and sets up the Swagger UI at the specified endpoint. | ||
* | ||
* @param {INestApplication} app - The NestJS application instance. | ||
* @returns {Promise<string>} A promise that resolves to the Swagger documentation path. | ||
*/ | ||
export const setupSwagger = async (app: INestApplication): Promise<string> => { | ||
const config = new DocumentBuilder() | ||
.setTitle('Gauzy API') | ||
.setDescription('Gauzy API Documentation') | ||
.setVersion('1.0') | ||
.addBearerAuth() | ||
.build(); | ||
|
||
// Swagger document options (if needed, can add additional options here) | ||
const options: SwaggerDocumentOptions = {}; | ||
|
||
// Generate the Swagger document from the app instance and configuration | ||
const document = SwaggerModule.createDocument(app, config, options); | ||
|
||
// Custom options for the Swagger UI (e.g., custom CSS, custom site title, etc.) | ||
const customOptions: SwaggerCustomOptions = {}; | ||
|
||
// Define the Swagger endpoint path | ||
const swaggerPath = 'docs'; | ||
|
||
// Setup Swagger UI at the `/docs` endpoint | ||
SwaggerModule.setup(swaggerPath, app, document, customOptions); | ||
|
||
// Return the Swagger path | ||
return swaggerPath; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters