Package Exports
- @didik-mulyadi/nodejs-api-doc
- @didik-mulyadi/nodejs-api-doc/package.json
Readme
⚡️@didik-mulyadi/nodejs-api-docs
A package to generate the API docs based on the open API file.
Installation 🚀
Install @didik-mulyadi/nodejs-api-docs using pnpm/npm/yarn:
pnpm add @didik-mulyadi/nodejs-api-docs
# OR
npm install @didik-mulyadi/nodejs-api-docs
# OR
yarn add @didik-mulyadi/nodejs-api-docsUsage 💻
Here's an example of how to use this package:
nodejs-api-doc with @nest/swagger
Step:
- Modify your
src/main.ts - Create a swagger config with
new DocumentBuilder() - Generate open api document object with
SwaggerModule.createDocument(app, config) - Setup nodejs-api-doc with
new NodejsApiDoc - Start nodejs-api-doc with
nodejsApiDoc.start()
// swagger
const config = new DocumentBuilder()
.setTitle('Node.js API Docs')
.setDescription('This API provides ...')
.setVersion('0.0.1')
.build()
const document = SwaggerModule.createDocument(app, config)
// nodejs-api-doc
const nodejsApiDoc = new NodejsApiDoc(app, document, {
defaultUI: 'redoc',
customPath: '/api-docs',
})
nodejsApiDoc.start()
// Run the nestjs
await app.listen(8080, '0.0.0.0')Configuration options ⚙️
Working with Helmet
Nest.JS Fastify Helmet
import { NodejsApiDoc, helmetConfig } from '@didik-mulyadi/nodejs-api-doc';
async function bootstrap() {
...
await app.register(helmet, helmetConfig.nodeApiDocHelmetOption);
...
}Bugs or Requests 🐛
If you found any issue or have a good suggestion, feel free to open an issue