forked from DEVRhylme-Foundation/expressify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance API documentation with Swagger
Fixes DEVRhylme-Foundation#5 Add Swagger API documentation to the project. * **internal/structure/structure.go** - Add a new function `AddSwaggerDocs` to set up Swagger documentation. - Call `AddSwaggerDocs` in `CreateBaseFileStructure` after copying the directory. * **.templates/jsbase/src/app.js** - Import `swagger-ui-express` and `swagger-jsdoc`. - Define Swagger documentation in JSDoc format. - Set up Swagger UI to serve at `/api-docs`. * **.templates/tsbase/src/app.ts** - Import `swagger-ui-express` and `swagger-jsdoc`. - Define Swagger documentation in JSDoc format. - Set up Swagger UI to serve at `/api-docs`. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/DEVRhylme-Foundation/expressify/issues/5?shareId=XXXX-XXXX-XXXX-XXXX).
- Loading branch information
1 parent
7e57b5d
commit 2fe4a63
Showing
3 changed files
with
88 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const express = require('express'); | ||
const swaggerUi = require('swagger-ui-express'); | ||
const swaggerJsdoc = require('swagger-jsdoc'); | ||
|
||
const app = express(); | ||
|
||
const options = { | ||
definition: { | ||
openapi: '3.0.0', | ||
info: { | ||
title: 'Express API with Swagger', | ||
version: '1.0.0', | ||
}, | ||
}, | ||
apis: ['./src/routes/*.js'], // files containing annotations as above | ||
}; | ||
|
||
const specs = swaggerJsdoc(options); | ||
|
||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs)); | ||
|
||
module.exports = app; |
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,22 @@ | ||
import express from 'express'; | ||
import swaggerUi from 'swagger-ui-express'; | ||
import swaggerJsdoc from 'swagger-jsdoc'; | ||
|
||
const app = express(); | ||
|
||
const options = { | ||
definition: { | ||
openapi: '3.0.0', | ||
info: { | ||
title: 'Express API with Swagger', | ||
version: '1.0.0', | ||
}, | ||
}, | ||
apis: ['./src/routes/*.ts'], // files containing annotations as above | ||
}; | ||
|
||
const specs = swaggerJsdoc(options); | ||
|
||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs)); | ||
|
||
export default app; |
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